mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 13:50:10 +01:00
Fix crash when lowering Carbon derived class with C++ virtual base class (#7745)
If a Carbon class overrides virtual functions from a C++ base class but is never referenced from C++, it is never exported to Clang. During lowering, `BuildVtable` then fails to find a `CXXRecordDecl` and crashes when attempting to get the vtable from Clang's code generator. Ensure dynamic classes with foreign vtables are exported to Clang when completing the class definition in `CheckCompleteClassType`, and look up `first_decl_id()` in `BuildVtable`. Fixes #7721 --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
@@ -174,13 +174,15 @@ static auto CompareVirtualWithOverrider(const SemIR::Function& base_fn,
|
||||
return OverrideMatchResult::Match;
|
||||
}
|
||||
|
||||
// Builds and returns a vtable for the current class. Assumes that the virtual
|
||||
// functions for the class are listed as the top element of the `vtable_stack`.
|
||||
// Builds and returns a vtable for the current class, along with a bool
|
||||
// indicating whether it is a Carbon-native vtable (false for a foreign vtable
|
||||
// inherited from a C++ base class). Assumes that the virtual functions for the
|
||||
// class are listed as the top element of the `vtable_stack`.
|
||||
static auto BuildVtable(Context& context, Parse::ClassDefinitionId node_id,
|
||||
SemIR::ClassId class_id,
|
||||
std::optional<SemIR::ClassType> base_class_type,
|
||||
llvm::ArrayRef<SemIR::InstId> vtable_contents)
|
||||
-> SemIR::VtableId {
|
||||
-> std::pair<SemIR::VtableId, bool> {
|
||||
auto base_vtable_id = SemIR::VtableId::None;
|
||||
auto base_class_specific_id = SemIR::SpecificId::None;
|
||||
|
||||
@@ -358,10 +360,11 @@ static auto BuildVtable(Context& context, Parse::ClassDefinitionId node_id,
|
||||
}
|
||||
}
|
||||
|
||||
return context.vtables().Add(
|
||||
auto vtable_id = context.vtables().Add(
|
||||
{{.class_id = class_id,
|
||||
.virtual_functions_id = context.inst_blocks().Add(vtable),
|
||||
.carbon_native_vtable = carbon_native_vtable}});
|
||||
return {vtable_id, carbon_native_vtable};
|
||||
}
|
||||
|
||||
// Checks that the specified finished class definition is valid and builds and
|
||||
@@ -411,9 +414,11 @@ static auto CheckCompleteClassType(
|
||||
{.name_id = SemIR::NameId::Base, .type_inst_id = base_type_inst_id});
|
||||
}
|
||||
|
||||
bool foreign_vtable = false;
|
||||
if (class_info.is_dynamic) {
|
||||
auto vtable_id = BuildVtable(context, node_id, class_id, base_class_type,
|
||||
vtable_contents);
|
||||
auto [vtable_id, carbon_native_vtable] = BuildVtable(
|
||||
context, node_id, class_id, base_class_type, vtable_contents);
|
||||
foreign_vtable = !carbon_native_vtable;
|
||||
auto vptr_type_id = GetPointerType(context, SemIR::VtableType::TypeInstId);
|
||||
class_info.vtable_decl_id = AddInst<SemIR::VtableDecl>(
|
||||
context, node_id, {.type_id = vptr_type_id, .vtable_id = vtable_id});
|
||||
@@ -422,11 +427,25 @@ static auto CheckCompleteClassType(
|
||||
auto struct_type_id = GetStructType(
|
||||
context, AddStructTypeFields(context, struct_type_fields, field_decls));
|
||||
|
||||
return AddInst<SemIR::CompleteTypeWitness>(
|
||||
auto complete_type_witness_id = AddInst<SemIR::CompleteTypeWitness>(
|
||||
context, node_id,
|
||||
{.type_id = GetSingletonType(context, SemIR::WitnessType::TypeInstId),
|
||||
.object_repr_type_inst_id =
|
||||
context.types().GetTypeInstId(struct_type_id)});
|
||||
class_info.complete_type_witness_id = complete_type_witness_id;
|
||||
|
||||
if (foreign_vtable) {
|
||||
if (class_info.generic_id.has_value()) {
|
||||
context.TODO(class_info.first_decl_id(),
|
||||
"generic class deriving from C++ virtual class");
|
||||
} else {
|
||||
ExportAndCompleteClassToCpp(
|
||||
context,
|
||||
context.types().GetAs<SemIR::ClassType>(class_info.self_type_id));
|
||||
}
|
||||
}
|
||||
|
||||
return complete_type_witness_id;
|
||||
}
|
||||
|
||||
auto ComputeClassObjectRepr(Context& context, Parse::ClassDefinitionId node_id,
|
||||
|
||||
@@ -293,6 +293,16 @@ auto ExportClassToCpp(Context& context, SemIR::ClassType class_type)
|
||||
return record_decl;
|
||||
}
|
||||
|
||||
auto ExportAndCompleteClassToCpp(Context& context, SemIR::ClassType class_type)
|
||||
-> clang::TagDecl* {
|
||||
auto* tag_decl = ExportClassToCpp(context, class_type);
|
||||
if (tag_decl && context.cpp_context() &&
|
||||
context.ast_context().getExternalSource()) {
|
||||
context.ast_context().getExternalSource()->CompleteType(tag_decl);
|
||||
}
|
||||
return tag_decl;
|
||||
}
|
||||
|
||||
// Export the bindings in a generic as a `clang::TemplateParameterList`.
|
||||
static auto ExportGenericBindings(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::GenericId generic_id,
|
||||
|
||||
@@ -36,6 +36,11 @@ auto ExportNameScopeToCpp(Context& context, SemIR::LocId loc_id,
|
||||
auto ExportClassToCpp(Context& context, SemIR::ClassType class_type)
|
||||
-> clang::TagDecl*;
|
||||
|
||||
// Exports a dynamic Carbon class with a foreign (C++) vtable into C++ as a
|
||||
// class, and completes its definition.
|
||||
auto ExportAndCompleteClassToCpp(Context& context, SemIR::ClassType class_type)
|
||||
-> clang::TagDecl*;
|
||||
|
||||
// Exports a generic Carbon class into C++ as a templated class.
|
||||
//
|
||||
// If the generic class has already been exported, returns the existing
|
||||
|
||||
@@ -57,3 +57,24 @@ void Test() {
|
||||
Carbon::Derived d;
|
||||
}
|
||||
''';
|
||||
|
||||
// --- fail_todo_generic.carbon
|
||||
// TODO: Test in `toolchain/lower/testdata/` once generic classes deriving from
|
||||
// C++ virtual classes pass check.
|
||||
library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
inline Cpp '''
|
||||
struct VBase {
|
||||
virtual void f() {}
|
||||
};
|
||||
''';
|
||||
|
||||
// CHECK:STDERR: fail_todo_generic.carbon:[[@LINE+4]]:1: error: semantics TODO: `generic class deriving from C++ virtual class` [SemanticsTodo]
|
||||
// CHECK:STDERR: class GenericZ(T: type) {
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
class GenericZ(T: type) {
|
||||
extend base: Cpp.VBase;
|
||||
override fn f(unused self) {}
|
||||
}
|
||||
|
||||
@@ -94,10 +94,16 @@ import Cpp library "overload.h";
|
||||
class OverloadX {
|
||||
extend base: Cpp.OverloadedBase;
|
||||
//
|
||||
// CHECK:STDERR: fail_overload_type.carbon:[[@LINE+16]]:23: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: override fn f(self, x: Cpp.X);
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_overload_type.carbon: error: cannot implicitly convert expression of type `Cpp.Y` to `Cpp.X` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_overload_type.carbon: note: type `Cpp.Y` does not implement interface `Core.ImplicitAs(Cpp.X)` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: fail_overload_type.carbon:[[@LINE+10]]:23: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: override fn f(self, x: Cpp.X);
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_overload_type.carbon:[[@LINE-8]]:10: in file included here [InCppInclude]
|
||||
// CHECK:STDERR: fail_overload_type.carbon:[[@LINE-14]]:10: in file included here [InCppInclude]
|
||||
// CHECK:STDERR: ./overload.h:7:16: note: while building thunk to match the signature of this function [ThunkSignature]
|
||||
// CHECK:STDERR: virtual void f(Y y);
|
||||
// CHECK:STDERR: ^
|
||||
@@ -110,10 +116,16 @@ class OverloadX {
|
||||
class OverloadY {
|
||||
extend base: Cpp.OverloadedBase;
|
||||
//
|
||||
// CHECK:STDERR: fail_overload_type.carbon:[[@LINE+14]]:23: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: override fn f(self, y: Cpp.Y);
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_overload_type.carbon: error: cannot implicitly convert expression of type `Cpp.X` to `Cpp.Y` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_overload_type.carbon: note: type `Cpp.X` does not implement interface `Core.ImplicitAs(Cpp.Y)` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: fail_overload_type.carbon:[[@LINE+8]]:23: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: override fn f(self, y: Cpp.Y);
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_overload_type.carbon:[[@LINE-24]]:10: in file included here [InCppInclude]
|
||||
// CHECK:STDERR: fail_overload_type.carbon:[[@LINE-36]]:10: in file included here [InCppInclude]
|
||||
// CHECK:STDERR: ./overload.h:6:16: note: while building thunk to match the signature of this function [ThunkSignature]
|
||||
// CHECK:STDERR: virtual void f(X x);
|
||||
// CHECK:STDERR: ^
|
||||
|
||||
@@ -773,8 +773,11 @@ auto FileContext::BuildVtable(const SemIR::Vtable& vtable,
|
||||
-> llvm::Constant* {
|
||||
const auto& class_info = sem_ir().classes().Get(vtable.class_id);
|
||||
if (!vtable.carbon_native_vtable) {
|
||||
auto* cxx_record_decl = cast<clang::CXXRecordDecl>(
|
||||
sem_ir().clang_decls().Lookup(class_info.latest_decl_id())->key.decl);
|
||||
const auto* clang_decl =
|
||||
sem_ir().clang_decls().Lookup(class_info.first_decl_id());
|
||||
CARBON_CHECK(clang_decl, "Missing Clang declaration for class {0}",
|
||||
class_info.name_id);
|
||||
auto* cxx_record_decl = cast<clang::CXXRecordDecl>(clang_decl->key.decl);
|
||||
// TODO: This code generator can be for the wrong AST if we're not using
|
||||
// --share-cpp-ast.
|
||||
return context().cpp_code_generator()->GetAddrOfVTable(
|
||||
|
||||
@@ -101,21 +101,56 @@ fn DoThing() {
|
||||
// CHECK:STDOUT: ret void, !dbg !58
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CDoThing.Main() #2 !dbg !60 {
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_C__destroy_thunk:thunk.Derived.Main"(ptr %self) #3 !dbg !60 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %d.var = alloca { [16 x i8] }, align 8, !dbg !61
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %d.var), !dbg !61
|
||||
// CHECK:STDOUT: %.loc31_44.1.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d.var, i32 0, i32 0, !dbg !62
|
||||
// CHECK:STDOUT: call void @_ZN4BaseC1Ev.carbon_thunk.(ptr %.loc31_44.1.base), !dbg !63
|
||||
// CHECK:STDOUT: %.loc31_44.7.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d.var, i32 0, i32 0, !dbg !62
|
||||
// CHECK:STDOUT: %.loc31_44.8.base = getelementptr inbounds nuw [16 x i8], ptr %.loc31_44.7.base, i32 0, i32 0, !dbg !62
|
||||
// CHECK:STDOUT: %.loc31_44.9.vptr = getelementptr inbounds nuw [8 x i8], ptr %.loc31_44.8.base, i32 0, i32 0, !dbg !62
|
||||
// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN6Carbon7DerivedE, i32 0, i32 0, i32 2), ptr %.loc31_44.9.vptr, align 8, !dbg !62
|
||||
// CHECK:STDOUT: %.loc32_11.2.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d.var, i32 0, i32 0, !dbg !66
|
||||
// CHECK:STDOUT: call void @_Z3UseR4Base(ptr %.loc32_11.2.base), !dbg !67
|
||||
// CHECK:STDOUT: call void @"_COp.b25525d21a9bd472:core.Destroy.Core"(ptr %d.var), !dbg !61
|
||||
// CHECK:STDOUT: ret void, !dbg !68
|
||||
// CHECK:STDOUT: call void @"_COp.b25525d21a9bd472:core.Destroy.Core"(ptr %self), !dbg !62
|
||||
// CHECK:STDOUT: ret void, !dbg !62
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.0a0b9df20a60c6f6:core.Destroy.Core"(ptr %self) #2 !dbg !64 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !66
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.b25525d21a9bd472:core.Destroy.Core"(ptr %self) #2 !dbg !68 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !70
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_Cfunc__carbon_thunk.Derived.Main(ptr %self) #2 !dbg !72 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_Cfunc.Derived.Main(ptr %self), !dbg !74
|
||||
// CHECK:STDOUT: ret void, !dbg !74
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_Cother_func__carbon_thunk.Derived.Main(ptr %self) #2 !dbg !76 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %Derived.other_func.call.vtable = load ptr, ptr %self, align 8, !dbg !78
|
||||
// CHECK:STDOUT: %Derived.other_func.call = call ptr @llvm.load.relative.i32(ptr %Derived.other_func.call.vtable, i32 8), !dbg !78
|
||||
// CHECK:STDOUT: call void %Derived.other_func.call(ptr %self), !dbg !78
|
||||
// CHECK:STDOUT: ret void, !dbg !78
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CDoThing.Main() #2 !dbg !80 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %d.var = alloca { [16 x i8] }, align 8, !dbg !81
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %d.var), !dbg !81
|
||||
// CHECK:STDOUT: %.loc31_44.1.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d.var, i32 0, i32 0, !dbg !82
|
||||
// CHECK:STDOUT: call void @_ZN4BaseC1Ev.carbon_thunk.(ptr %.loc31_44.1.base), !dbg !83
|
||||
// CHECK:STDOUT: %.loc31_44.7.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d.var, i32 0, i32 0, !dbg !82
|
||||
// CHECK:STDOUT: %.loc31_44.8.base = getelementptr inbounds nuw [16 x i8], ptr %.loc31_44.7.base, i32 0, i32 0, !dbg !82
|
||||
// CHECK:STDOUT: %.loc31_44.9.vptr = getelementptr inbounds nuw [8 x i8], ptr %.loc31_44.8.base, i32 0, i32 0, !dbg !82
|
||||
// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN6Carbon7DerivedE, i32 0, i32 0, i32 2), ptr %.loc31_44.9.vptr, align 8, !dbg !82
|
||||
// CHECK:STDOUT: %.loc32_11.2.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d.var, i32 0, i32 0, !dbg !86
|
||||
// CHECK:STDOUT: call void @_Z3UseR4Base(ptr %.loc32_11.2.base), !dbg !87
|
||||
// CHECK:STDOUT: call void @"_COp.b25525d21a9bd472:core.Destroy.Core"(ptr %d.var), !dbg !81
|
||||
// CHECK:STDOUT: ret void, !dbg !88
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
|
||||
@@ -128,46 +163,11 @@ fn DoThing() {
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_C__destroy_thunk:thunk.Derived.Main"(ptr %self) #3 !dbg !69 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @"_COp.b25525d21a9bd472:core.Destroy.Core"(ptr %self), !dbg !71
|
||||
// CHECK:STDOUT: ret void, !dbg !71
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.0a0b9df20a60c6f6:core.Destroy.Core"(ptr %self) #2 !dbg !73 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !75
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.b25525d21a9bd472:core.Destroy.Core"(ptr %self) #2 !dbg !77 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !79
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_Cfunc__carbon_thunk.Derived.Main(ptr %self) #2 !dbg !81 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_Cfunc.Derived.Main(ptr %self), !dbg !83
|
||||
// CHECK:STDOUT: ret void, !dbg !83
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_Cother_func__carbon_thunk.Derived.Main(ptr %self) #2 !dbg !85 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %Derived.other_func.call.vtable = load ptr, ptr %self, align 8, !dbg !87
|
||||
// CHECK:STDOUT: %Derived.other_func.call = call ptr @llvm.load.relative.i32(ptr %Derived.other_func.call.vtable, i32 8), !dbg !87
|
||||
// CHECK:STDOUT: call void %Derived.other_func.call(ptr %self), !dbg !87
|
||||
// CHECK:STDOUT: ret void, !dbg !87
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: read)
|
||||
// CHECK:STDOUT: declare ptr @llvm.load.relative.i32(ptr, i32) #5
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
||||
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #5
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: read)
|
||||
// CHECK:STDOUT: declare ptr @llvm.load.relative.i32(ptr, i32) #6
|
||||
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #6
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define internal void @_ZNR6Carbon7Derived4funcEv(ptr noundef nonnull align 8 dereferenceable(12) %this) unnamed_addr #4 align 2 {
|
||||
@@ -212,15 +212,14 @@ fn DoThing() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; uselistorder directives
|
||||
// CHECK:STDOUT: uselistorder ptr @_ZN11FurtherBase17further_base_funcEv, { 2, 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @"_COp.b25525d21a9bd472:core.Destroy.Core", { 1, 0 }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { mustprogress noinline nounwind optnone uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #2 = { nounwind }
|
||||
// CHECK:STDOUT: attributes #3 = { alwaysinline nounwind }
|
||||
// CHECK:STDOUT: attributes #4 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #5 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
||||
// CHECK:STDOUT: attributes #6 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) }
|
||||
// CHECK:STDOUT: attributes #5 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) }
|
||||
// CHECK:STDOUT: attributes #6 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
||||
// CHECK:STDOUT: attributes #7 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !llvm.dbg.cu = !{!38}
|
||||
@@ -253,33 +252,33 @@ fn DoThing() {
|
||||
// CHECK:STDOUT: !56 = !DILocalVariable(arg: 1, scope: !55, type: !40)
|
||||
// CHECK:STDOUT: !58 = !DILocation(line: 26, column: 3, scope: !55)
|
||||
// CHECK:STDOUT: !59 = !{!56}
|
||||
// CHECK:STDOUT: !60 = distinct !DISubprogram(name: "DoThing", linkageName: "_CDoThing.Main", scope: null, file: !37, line: 30, type: !44, spFlags: DISPFlagDefinition, unit: !38)
|
||||
// CHECK:STDOUT: !61 = !DILocation(line: 31, column: 3, scope: !60)
|
||||
// CHECK:STDOUT: !62 = !DILocation(line: 31, column: 20, scope: !60)
|
||||
// CHECK:STDOUT: !63 = !DILocation(line: 31, column: 29, scope: !60)
|
||||
// CHECK:STDOUT: !66 = !DILocation(line: 32, column: 11, scope: !60)
|
||||
// CHECK:STDOUT: !67 = !DILocation(line: 32, column: 3, scope: !60)
|
||||
// CHECK:STDOUT: !68 = !DILocation(line: 30, column: 1, scope: !60)
|
||||
// CHECK:STDOUT: !69 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.Derived.Main", scope: null, file: !37, line: 22, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !72)
|
||||
// CHECK:STDOUT: !70 = !DILocalVariable(arg: 1, scope: !69, type: !40)
|
||||
// CHECK:STDOUT: !71 = !DILocation(line: 22, column: 1, scope: !69)
|
||||
// CHECK:STDOUT: !72 = !{!70}
|
||||
// CHECK:STDOUT: !73 = distinct !DISubprogram(name: "Op", linkageName: "_COp.0a0b9df20a60c6f6:core.Destroy.Core", scope: null, file: !37, line: 22, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !76)
|
||||
// CHECK:STDOUT: !74 = !DILocalVariable(arg: 1, scope: !73, type: !40)
|
||||
// CHECK:STDOUT: !75 = !DILocation(line: 22, column: 1, scope: !73)
|
||||
// CHECK:STDOUT: !76 = !{!74}
|
||||
// CHECK:STDOUT: !77 = distinct !DISubprogram(name: "Op", linkageName: "_COp.b25525d21a9bd472:core.Destroy.Core", scope: null, file: !37, line: 22, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !80)
|
||||
// CHECK:STDOUT: !78 = !DILocalVariable(arg: 1, scope: !77, type: !40)
|
||||
// CHECK:STDOUT: !79 = !DILocation(line: 22, column: 1, scope: !77)
|
||||
// CHECK:STDOUT: !80 = !{!78}
|
||||
// CHECK:STDOUT: !81 = distinct !DISubprogram(name: "func__carbon_thunk", linkageName: "_Cfunc__carbon_thunk.Derived.Main", scope: null, file: !37, line: 26, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !84)
|
||||
// CHECK:STDOUT: !82 = !DILocalVariable(arg: 1, scope: !81, type: !40)
|
||||
// CHECK:STDOUT: !83 = !DILocation(line: 26, column: 3, scope: !81)
|
||||
// CHECK:STDOUT: !84 = !{!82}
|
||||
// CHECK:STDOUT: !85 = distinct !DISubprogram(name: "other_func__carbon_thunk", linkageName: "_Cother_func__carbon_thunk.Derived.Main", scope: null, file: !37, line: 24, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !88)
|
||||
// CHECK:STDOUT: !86 = !DILocalVariable(arg: 1, scope: !85, type: !40)
|
||||
// CHECK:STDOUT: !87 = !DILocation(line: 24, column: 3, scope: !85)
|
||||
// CHECK:STDOUT: !88 = !{!86}
|
||||
// CHECK:STDOUT: !60 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.Derived.Main", scope: null, file: !37, line: 22, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !63)
|
||||
// CHECK:STDOUT: !61 = !DILocalVariable(arg: 1, scope: !60, type: !40)
|
||||
// CHECK:STDOUT: !62 = !DILocation(line: 22, column: 1, scope: !60)
|
||||
// CHECK:STDOUT: !63 = !{!61}
|
||||
// CHECK:STDOUT: !64 = distinct !DISubprogram(name: "Op", linkageName: "_COp.0a0b9df20a60c6f6:core.Destroy.Core", scope: null, file: !37, line: 22, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !67)
|
||||
// CHECK:STDOUT: !65 = !DILocalVariable(arg: 1, scope: !64, type: !40)
|
||||
// CHECK:STDOUT: !66 = !DILocation(line: 22, column: 1, scope: !64)
|
||||
// CHECK:STDOUT: !67 = !{!65}
|
||||
// CHECK:STDOUT: !68 = distinct !DISubprogram(name: "Op", linkageName: "_COp.b25525d21a9bd472:core.Destroy.Core", scope: null, file: !37, line: 22, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !71)
|
||||
// CHECK:STDOUT: !69 = !DILocalVariable(arg: 1, scope: !68, type: !40)
|
||||
// CHECK:STDOUT: !70 = !DILocation(line: 22, column: 1, scope: !68)
|
||||
// CHECK:STDOUT: !71 = !{!69}
|
||||
// CHECK:STDOUT: !72 = distinct !DISubprogram(name: "func__carbon_thunk", linkageName: "_Cfunc__carbon_thunk.Derived.Main", scope: null, file: !37, line: 26, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !75)
|
||||
// CHECK:STDOUT: !73 = !DILocalVariable(arg: 1, scope: !72, type: !40)
|
||||
// CHECK:STDOUT: !74 = !DILocation(line: 26, column: 3, scope: !72)
|
||||
// CHECK:STDOUT: !75 = !{!73}
|
||||
// CHECK:STDOUT: !76 = distinct !DISubprogram(name: "other_func__carbon_thunk", linkageName: "_Cother_func__carbon_thunk.Derived.Main", scope: null, file: !37, line: 24, type: !42, spFlags: DISPFlagDefinition, unit: !38, retainedNodes: !79)
|
||||
// CHECK:STDOUT: !77 = !DILocalVariable(arg: 1, scope: !76, type: !40)
|
||||
// CHECK:STDOUT: !78 = !DILocation(line: 24, column: 3, scope: !76)
|
||||
// CHECK:STDOUT: !79 = !{!77}
|
||||
// CHECK:STDOUT: !80 = distinct !DISubprogram(name: "DoThing", linkageName: "_CDoThing.Main", scope: null, file: !37, line: 30, type: !44, spFlags: DISPFlagDefinition, unit: !38)
|
||||
// CHECK:STDOUT: !81 = !DILocation(line: 31, column: 3, scope: !80)
|
||||
// CHECK:STDOUT: !82 = !DILocation(line: 31, column: 20, scope: !80)
|
||||
// CHECK:STDOUT: !83 = !DILocation(line: 31, column: 29, scope: !80)
|
||||
// CHECK:STDOUT: !86 = !DILocation(line: 32, column: 11, scope: !80)
|
||||
// CHECK:STDOUT: !87 = !DILocation(line: 32, column: 3, scope: !80)
|
||||
// CHECK:STDOUT: !88 = !DILocation(line: 30, column: 1, scope: !80)
|
||||
// CHECK:STDOUT: !89 = !{!"vtable pointer", !0, i64 0}
|
||||
// CHECK:STDOUT: !90 = !{!89, !89, i64 0}
|
||||
// CHECK:STDOUT: !91 = !{!"p1 _ZTS11FurtherBase", !2, i64 0}
|
||||
|
||||
+37
-37
@@ -204,41 +204,41 @@ void delete_new_Base() {
|
||||
// CHECK:STDOUT: ret void, !dbg !35
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare void @_CF.Base.Main(ptr)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_CF:thunk:A.Cpp:Base.Main"(ptr %self) #6 !dbg !37 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_C__destroy_thunk:thunk.Final.Main"(ptr %self) #6 !dbg !37 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_CF.Base.Main(ptr %self), !dbg !40
|
||||
// CHECK:STDOUT: ret void, !dbg !40
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_C__destroy_thunk:thunk.Final.Main"(ptr %self) #6 !dbg !42 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @"_COp.28387b086eba9957:core.Destroy.Core"(ptr %self), !dbg !44
|
||||
// CHECK:STDOUT: ret void, !dbg !44
|
||||
// CHECK:STDOUT: call void @"_COp.28387b086eba9957:core.Destroy.Core"(ptr %self), !dbg !39
|
||||
// CHECK:STDOUT: ret void, !dbg !39
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: declare void @_ZN1AD1Ev(ptr noundef nonnull align 8 dead_on_return(8) dereferenceable(8)) unnamed_addr #7
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.e9cc9e95545cc62f:core.Destroy.Core"(ptr %self) #8 !dbg !46 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.e9cc9e95545cc62f:core.Destroy.Core"(ptr %self) #8 !dbg !41 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !48
|
||||
// CHECK:STDOUT: ret void, !dbg !43
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.28387b086eba9957:core.Destroy.Core"(ptr %self) #8 !dbg !50 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.28387b086eba9957:core.Destroy.Core"(ptr %self) #8 !dbg !45 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !52
|
||||
// CHECK:STDOUT: ret void, !dbg !47
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CF__carbon_thunk.Final.Main(ptr %self) #8 !dbg !54 {
|
||||
// CHECK:STDOUT: define void @_CF__carbon_thunk.Final.Main(ptr %self) #8 !dbg !49 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_CF.Final.Main(ptr %self), !dbg !56
|
||||
// CHECK:STDOUT: call void @_CF.Final.Main(ptr %self), !dbg !51
|
||||
// CHECK:STDOUT: ret void, !dbg !51
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare void @_CF.Base.Main(ptr)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_CF:thunk:A.Cpp:Base.Main"(ptr %self) #6 !dbg !53 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_CF.Base.Main(ptr %self), !dbg !56
|
||||
// CHECK:STDOUT: ret void, !dbg !56
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -377,26 +377,26 @@ void delete_new_Base() {
|
||||
// CHECK:STDOUT: !33 = !DILocalVariable(arg: 1, scope: !32, type: !29)
|
||||
// CHECK:STDOUT: !35 = !DILocation(line: 14, column: 3, scope: !32)
|
||||
// CHECK:STDOUT: !36 = !{!33}
|
||||
// CHECK:STDOUT: !37 = distinct !DISubprogram(name: "F", linkageName: "_CF:thunk:A.Cpp:Base.Main", scope: null, file: !27, line: 19, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !41)
|
||||
// CHECK:STDOUT: !37 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.Final.Main", scope: null, file: !27, line: 12, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !40)
|
||||
// CHECK:STDOUT: !38 = !DILocalVariable(arg: 1, scope: !37, type: !29)
|
||||
// CHECK:STDOUT: !40 = !DILocation(line: 19, column: 3, scope: !37)
|
||||
// CHECK:STDOUT: !41 = !{!38}
|
||||
// CHECK:STDOUT: !42 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.Final.Main", scope: null, file: !27, line: 12, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !45)
|
||||
// CHECK:STDOUT: !43 = !DILocalVariable(arg: 1, scope: !42, type: !29)
|
||||
// CHECK:STDOUT: !44 = !DILocation(line: 12, column: 1, scope: !42)
|
||||
// CHECK:STDOUT: !45 = !{!43}
|
||||
// CHECK:STDOUT: !46 = distinct !DISubprogram(name: "Op", linkageName: "_COp.e9cc9e95545cc62f:core.Destroy.Core", scope: null, file: !27, line: 12, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !49)
|
||||
// CHECK:STDOUT: !47 = !DILocalVariable(arg: 1, scope: !46, type: !29)
|
||||
// CHECK:STDOUT: !48 = !DILocation(line: 12, column: 1, scope: !46)
|
||||
// CHECK:STDOUT: !49 = !{!47}
|
||||
// CHECK:STDOUT: !50 = distinct !DISubprogram(name: "Op", linkageName: "_COp.28387b086eba9957:core.Destroy.Core", scope: null, file: !27, line: 12, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !53)
|
||||
// CHECK:STDOUT: !51 = !DILocalVariable(arg: 1, scope: !50, type: !29)
|
||||
// CHECK:STDOUT: !52 = !DILocation(line: 12, column: 1, scope: !50)
|
||||
// CHECK:STDOUT: !53 = !{!51}
|
||||
// CHECK:STDOUT: !54 = distinct !DISubprogram(name: "F__carbon_thunk", linkageName: "_CF__carbon_thunk.Final.Main", scope: null, file: !27, line: 14, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !57)
|
||||
// CHECK:STDOUT: !55 = !DILocalVariable(arg: 1, scope: !54, type: !29)
|
||||
// CHECK:STDOUT: !56 = !DILocation(line: 14, column: 3, scope: !54)
|
||||
// CHECK:STDOUT: !57 = !{!55}
|
||||
// CHECK:STDOUT: !39 = !DILocation(line: 12, column: 1, scope: !37)
|
||||
// CHECK:STDOUT: !40 = !{!38}
|
||||
// CHECK:STDOUT: !41 = distinct !DISubprogram(name: "Op", linkageName: "_COp.e9cc9e95545cc62f:core.Destroy.Core", scope: null, file: !27, line: 12, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !44)
|
||||
// CHECK:STDOUT: !42 = !DILocalVariable(arg: 1, scope: !41, type: !29)
|
||||
// CHECK:STDOUT: !43 = !DILocation(line: 12, column: 1, scope: !41)
|
||||
// CHECK:STDOUT: !44 = !{!42}
|
||||
// CHECK:STDOUT: !45 = distinct !DISubprogram(name: "Op", linkageName: "_COp.28387b086eba9957:core.Destroy.Core", scope: null, file: !27, line: 12, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !48)
|
||||
// CHECK:STDOUT: !46 = !DILocalVariable(arg: 1, scope: !45, type: !29)
|
||||
// CHECK:STDOUT: !47 = !DILocation(line: 12, column: 1, scope: !45)
|
||||
// CHECK:STDOUT: !48 = !{!46}
|
||||
// CHECK:STDOUT: !49 = distinct !DISubprogram(name: "F__carbon_thunk", linkageName: "_CF__carbon_thunk.Final.Main", scope: null, file: !27, line: 14, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !52)
|
||||
// CHECK:STDOUT: !50 = !DILocalVariable(arg: 1, scope: !49, type: !29)
|
||||
// CHECK:STDOUT: !51 = !DILocation(line: 14, column: 3, scope: !49)
|
||||
// CHECK:STDOUT: !52 = !{!50}
|
||||
// CHECK:STDOUT: !53 = distinct !DISubprogram(name: "F", linkageName: "_CF:thunk:A.Cpp:Base.Main", scope: null, file: !27, line: 19, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !57)
|
||||
// CHECK:STDOUT: !54 = !DILocalVariable(arg: 1, scope: !53, type: !29)
|
||||
// CHECK:STDOUT: !56 = !DILocation(line: 19, column: 3, scope: !53)
|
||||
// CHECK:STDOUT: !57 = !{!54}
|
||||
// CHECK:STDOUT: !58 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.Base.Main", scope: null, file: !27, line: 17, type: !31, spFlags: DISPFlagDefinition, unit: !28, retainedNodes: !61)
|
||||
// CHECK:STDOUT: !59 = !DILocalVariable(arg: 1, scope: !58, type: !29)
|
||||
// CHECK:STDOUT: !60 = !DILocation(line: 17, column: 1, scope: !58)
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/destroy.carbon
|
||||
// EXTRA-ARGS: --clang-arg=-fno-exceptions
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/interop/cpp/class/virtual_fn_carbon_only.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/class/virtual_fn_carbon_only.carbon
|
||||
|
||||
import Cpp inline '''
|
||||
struct X { virtual void f() {} };
|
||||
''';
|
||||
|
||||
class Z {
|
||||
extend base: Cpp.X;
|
||||
override fn f(unused self) {}
|
||||
}
|
||||
|
||||
fn F() {
|
||||
var _: Z = {.base = Cpp.X.X()};
|
||||
}
|
||||
|
||||
// CHECK:STDOUT: ; ---
|
||||
// CHECK:STDOUT: ; ModuleID = 'virtual_fn_carbon_only.carbon'
|
||||
// CHECK:STDOUT: source_filename = "virtual_fn_carbon_only.carbon"
|
||||
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
|
||||
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZN1X1fEv = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZN1XC2Ev = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTV1X = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTVN6Carbon1ZE = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTI1X = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTS1X = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTIN6Carbon1ZE = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTSN6Carbon1ZE = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: @_ZTV1X = linkonce_odr dso_local constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1X, ptr @_ZN1X1fEv] }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTVN6Carbon1ZE = linkonce_odr dso_local constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTIN6Carbon1ZE, ptr @_ZN6Carbon1Z1fEv] }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTI1X = linkonce_odr dso_local constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1X }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
|
||||
// CHECK:STDOUT: @_ZTS1X = linkonce_odr dso_local constant [3 x i8] c"1X\00", comdat, align 1
|
||||
// CHECK:STDOUT: @_ZTIN6Carbon1ZE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr @_ZTSN6Carbon1ZE, ptr @_ZTI1X }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr]
|
||||
// CHECK:STDOUT: @_ZTSN6Carbon1ZE = linkonce_odr dso_local constant [12 x i8] c"N6Carbon1ZE\00", comdat, align 1
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN1X1fEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #0 comdat align 2 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %this.addr = alloca ptr, align 8
|
||||
// CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !49
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_Cf.Z.Main(ptr %self) #1 !dbg !13 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !16
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_Cf:thunk:X.Cpp:Z.Main"(ptr %self) #2 !dbg !18 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_Cf.Z.Main(ptr %self), !dbg !21
|
||||
// CHECK:STDOUT: ret void, !dbg !21
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_C__destroy_thunk:thunk.Z.Main"(ptr %self) #2 !dbg !23 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @"_COp.680f7fa3ef86df7a:core.Destroy.Core"(ptr %self), !dbg !25
|
||||
// CHECK:STDOUT: ret void, !dbg !25
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.de73a19002e400c9:core.Destroy.Core"(ptr %self) #1 !dbg !27 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !29
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.680f7fa3ef86df7a:core.Destroy.Core"(ptr %self) #1 !dbg !31 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !33
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_Cf__carbon_thunk.Z.Main(ptr %self) #1 !dbg !35 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_Cf.Z.Main(ptr %self), !dbg !37
|
||||
// CHECK:STDOUT: ret void, !dbg !37
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CF.Main() #1 !dbg !39 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %_.var = alloca { [8 x i8] }, align 8, !dbg !40
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var), !dbg !40
|
||||
// CHECK:STDOUT: %.loc24_32.1.base = getelementptr inbounds nuw { [8 x i8] }, ptr %_.var, i32 0, i32 0, !dbg !41
|
||||
// CHECK:STDOUT: call void @_ZN1XC1Ev.carbon_thunk.(ptr %.loc24_32.1.base), !dbg !42
|
||||
// CHECK:STDOUT: %.loc24_32.7.base = getelementptr inbounds nuw { [8 x i8] }, ptr %_.var, i32 0, i32 0, !dbg !41
|
||||
// CHECK:STDOUT: %.loc24_32.8.vptr = getelementptr inbounds nuw [8 x i8], ptr %.loc24_32.7.base, i32 0, i32 0, !dbg !41
|
||||
// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTVN6Carbon1ZE, i32 0, i32 0, i32 2), ptr %.loc24_32.8.vptr, align 8, !dbg !41
|
||||
// CHECK:STDOUT: call void @"_COp.680f7fa3ef86df7a:core.Destroy.Core"(ptr %_.var), !dbg !40
|
||||
// CHECK:STDOUT: ret void, !dbg !44
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define internal void @_ZN1XC1Ev.carbon_thunk.(ptr noundef %return) #3 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %return.addr = alloca ptr, align 8
|
||||
// CHECK:STDOUT: store ptr %return, ptr %return.addr, align 8, !tbaa !49
|
||||
// CHECK:STDOUT: %0 = load ptr, ptr %return.addr, align 8, !tbaa !49
|
||||
// CHECK:STDOUT: call void @_ZN1XC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #1
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
||||
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #4
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define internal void @_ZN6Carbon1Z1fEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #3 align 2 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %this.addr = alloca ptr, align 8
|
||||
// CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !53
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: call void @_Cf__carbon_thunk.Z.Main(ptr noundef nonnull align 8 dereferenceable(8) %this1)
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN1XC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #5 comdat align 2 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %this.addr = alloca ptr, align 8
|
||||
// CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !49
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1X, i32 0, i32 0, i32 2), ptr %this1, align 8, !tbaa !51
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #1 = { nounwind }
|
||||
// CHECK:STDOUT: attributes #2 = { alwaysinline nounwind }
|
||||
// CHECK:STDOUT: attributes #3 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
||||
// CHECK:STDOUT: attributes #5 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !llvm.dbg.cu = !{!7}
|
||||
// CHECK:STDOUT: !llvm.module.flags = !{!56, !57, !58, !2, !3}
|
||||
// CHECK:STDOUT: !llvm.errno.tbaa = !{!61}
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
|
||||
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
// CHECK:STDOUT: !6 = !DIFile(filename: "virtual_fn_carbon_only.carbon", directory: "")
|
||||
// CHECK:STDOUT: !7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
||||
// CHECK:STDOUT: !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||
// CHECK:STDOUT: !9 = !{null, !8}
|
||||
// CHECK:STDOUT: !10 = !DISubroutineType(types: !9)
|
||||
// CHECK:STDOUT: !11 = !{null}
|
||||
// CHECK:STDOUT: !12 = !DISubroutineType(types: !11)
|
||||
// CHECK:STDOUT: !13 = distinct !DISubprogram(name: "f", linkageName: "_Cf.Z.Main", scope: null, file: !6, line: 20, type: !10, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !17)
|
||||
// CHECK:STDOUT: !14 = !DILocalVariable(arg: 1, scope: !13, type: !8)
|
||||
// CHECK:STDOUT: !16 = !DILocation(line: 20, column: 3, scope: !13)
|
||||
// CHECK:STDOUT: !17 = !{!14}
|
||||
// CHECK:STDOUT: !18 = distinct !DISubprogram(name: "f", linkageName: "_Cf:thunk:X.Cpp:Z.Main", scope: null, file: !6, line: 20, type: !10, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !22)
|
||||
// CHECK:STDOUT: !19 = !DILocalVariable(arg: 1, scope: !18, type: !8)
|
||||
// CHECK:STDOUT: !21 = !DILocation(line: 20, column: 3, scope: !18)
|
||||
// CHECK:STDOUT: !22 = !{!19}
|
||||
// CHECK:STDOUT: !23 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.Z.Main", scope: null, file: !6, line: 18, type: !10, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !26)
|
||||
// CHECK:STDOUT: !24 = !DILocalVariable(arg: 1, scope: !23, type: !8)
|
||||
// CHECK:STDOUT: !25 = !DILocation(line: 18, column: 1, scope: !23)
|
||||
// CHECK:STDOUT: !26 = !{!24}
|
||||
// CHECK:STDOUT: !27 = distinct !DISubprogram(name: "Op", linkageName: "_COp.de73a19002e400c9:core.Destroy.Core", scope: null, file: !6, line: 18, type: !10, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !30)
|
||||
// CHECK:STDOUT: !28 = !DILocalVariable(arg: 1, scope: !27, type: !8)
|
||||
// CHECK:STDOUT: !29 = !DILocation(line: 18, column: 1, scope: !27)
|
||||
// CHECK:STDOUT: !30 = !{!28}
|
||||
// CHECK:STDOUT: !31 = distinct !DISubprogram(name: "Op", linkageName: "_COp.680f7fa3ef86df7a:core.Destroy.Core", scope: null, file: !6, line: 18, type: !10, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !34)
|
||||
// CHECK:STDOUT: !32 = !DILocalVariable(arg: 1, scope: !31, type: !8)
|
||||
// CHECK:STDOUT: !33 = !DILocation(line: 18, column: 1, scope: !31)
|
||||
// CHECK:STDOUT: !34 = !{!32}
|
||||
// CHECK:STDOUT: !35 = distinct !DISubprogram(name: "f__carbon_thunk", linkageName: "_Cf__carbon_thunk.Z.Main", scope: null, file: !6, line: 20, type: !10, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !38)
|
||||
// CHECK:STDOUT: !36 = !DILocalVariable(arg: 1, scope: !35, type: !8)
|
||||
// CHECK:STDOUT: !37 = !DILocation(line: 20, column: 3, scope: !35)
|
||||
// CHECK:STDOUT: !38 = !{!36}
|
||||
// CHECK:STDOUT: !39 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !6, line: 23, type: !12, spFlags: DISPFlagDefinition, unit: !7)
|
||||
// CHECK:STDOUT: !40 = !DILocation(line: 24, column: 3, scope: !39)
|
||||
// CHECK:STDOUT: !41 = !DILocation(line: 24, column: 14, scope: !39)
|
||||
// CHECK:STDOUT: !42 = !DILocation(line: 24, column: 23, scope: !39)
|
||||
// CHECK:STDOUT: !44 = !DILocation(line: 23, column: 1, scope: !39)
|
||||
// CHECK:STDOUT: !45 = !{!"Simple C++ TBAA"}
|
||||
// CHECK:STDOUT: !46 = !{!"omnipotent char", !45, i64 0}
|
||||
// CHECK:STDOUT: !47 = !{!"any pointer", !46, i64 0}
|
||||
// CHECK:STDOUT: !48 = !{!"p1 _ZTS1X", !47, i64 0}
|
||||
// CHECK:STDOUT: !49 = !{!48, !48, i64 0}
|
||||
// CHECK:STDOUT: !50 = !{!"vtable pointer", !45, i64 0}
|
||||
// CHECK:STDOUT: !51 = !{!50, !50, i64 0}
|
||||
// CHECK:STDOUT: !52 = !{!"p1 _ZTSN6Carbon1ZE", !47, i64 0}
|
||||
// CHECK:STDOUT: !53 = !{!52, !52, i64 0}
|
||||
// CHECK:STDOUT: !56 = !{i32 8, !"PIC Level", i32 2}
|
||||
// CHECK:STDOUT: !57 = !{i32 7, !"PIE Level", i32 2}
|
||||
// CHECK:STDOUT: !58 = !{i32 7, !"uwtable", i32 2}
|
||||
// CHECK:STDOUT: !59 = !{!"int", !46, i64 0}
|
||||
// CHECK:STDOUT: !60 = !{!"__libc_errno", !59, i64 0}
|
||||
// CHECK:STDOUT: !61 = !{!60, !59, i64 0}
|
||||
// CHECK:STDOUT:
|
||||
Reference in New Issue
Block a user