mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:20:10 +01:00
Import C++ vtables (#7174)
This correctly renders the vtable in SemIR, including allowing overrides in Carbon-derived-from-C++ classes. It doesn't work in lowering because clang walks the methods of the CXXRecordDecl - and we currently don't export anything into the CXXRecordDecl's methods (we do export the fields) - so that's next. This also doesn't teach Clang to affirmatively emit the vtable regardless of the types use in C++ code - or to have Carbon use the vtable in an object's initialization.
This commit is contained in:
+303
-32
@@ -18,49 +18,297 @@ import Cpp;
|
||||
|
||||
inline Cpp '''
|
||||
|
||||
struct Base {
|
||||
int i;
|
||||
virtual void func();
|
||||
struct FurtherBase {
|
||||
virtual auto further_base_func() -> int {
|
||||
return 11;
|
||||
}
|
||||
};
|
||||
|
||||
struct Base: FurtherBase {
|
||||
int i;
|
||||
virtual auto func() -> int {
|
||||
return 7;
|
||||
}
|
||||
};
|
||||
|
||||
auto Use(Base& b) -> int {
|
||||
return b.func();
|
||||
}
|
||||
|
||||
''';
|
||||
|
||||
base class Derived {
|
||||
extend base: Cpp.Base;
|
||||
virtual fn other_func[self: Self]();
|
||||
// TODO: `other_func` should appear in the vtable (it currently
|
||||
// doesn't because the CXXRecordDecl we export has no CXXMethodDecl
|
||||
// children - those need to be added, and in the right order)
|
||||
virtual fn other_func[unused self: Self]() -> i32 {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
fn Use(d: Derived) -> i32 {
|
||||
d.other_func();
|
||||
return d.i;
|
||||
inline Cpp '''
|
||||
|
||||
// TODO: Carbon lowering should request clang to generate the vtable.
|
||||
void WorkaroundToEmitCtorAndVtable() {
|
||||
Carbon::Derived d;
|
||||
}
|
||||
|
||||
// TODO: Carbon lowering should emit initialization that refers to the
|
||||
// Clang-lowered vtable.
|
||||
auto DoThing() -> int {
|
||||
Carbon::Derived d;
|
||||
return Use(d);
|
||||
}
|
||||
|
||||
''';
|
||||
|
||||
// CHECK:STDOUT: ; ModuleID = 'dynamic_base_from_cpp.carbon'
|
||||
// CHECK:STDOUT: source_filename = "dynamic_base_from_cpp.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: @"_CDerived.Main.$vtable" = unnamed_addr constant [1 x i32] [i32 trunc (i64 sub (i64 ptrtoint (ptr @_Cother_func.Derived.Main to i64), i64 ptrtoint (ptr @"_CDerived.Main.$vtable" to i64)) to i32)]
|
||||
// CHECK:STDOUT: %"class.Carbon::Derived" = type { %struct.Base.base, [4 x i8] }
|
||||
// CHECK:STDOUT: %struct.Base.base = type <{ %struct.FurtherBase, i32 }>
|
||||
// CHECK:STDOUT: %struct.FurtherBase = type { ptr }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare void @_Cother_func.Derived.Main(ptr)
|
||||
// CHECK:STDOUT: $_ZN6Carbon7DerivedC2Ev = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define i32 @_CUse.Main(ptr %d) #0 !dbg !11 {
|
||||
// CHECK:STDOUT: $_ZN6Carbon7DerivedD2Ev = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $__clang_call_terminate = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZN11FurtherBase17further_base_funcEv = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZN4Base4funcEv = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZN4BaseC2Ev = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZN11FurtherBaseC2Ev = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTVN6Carbon7DerivedE = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTIN6Carbon7DerivedE = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTSN6Carbon7DerivedE = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTI4Base = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTS4Base = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTI11FurtherBase = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTS11FurtherBase = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTV4Base = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZTV11FurtherBase = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: @"_CDerived.Main.$vtable" = unnamed_addr constant [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZN11FurtherBase17further_base_funcEv to i64), i64 ptrtoint (ptr @"_CDerived.Main.$vtable" to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZN4Base4funcEv to i64), i64 ptrtoint (ptr @"_CDerived.Main.$vtable" to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @_Cother_func.Derived.Main to i64), i64 ptrtoint (ptr @"_CDerived.Main.$vtable" to i64)) to i32)]
|
||||
// CHECK:STDOUT: @_ZTVN6Carbon7DerivedE = linkonce_odr dso_local unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTIN6Carbon7DerivedE, ptr @_ZN11FurtherBase17further_base_funcEv, ptr @_ZN4Base4funcEv] }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTIN6Carbon7DerivedE = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr @_ZTSN6Carbon7DerivedE, ptr @_ZTI4Base }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr]
|
||||
// CHECK:STDOUT: @_ZTSN6Carbon7DerivedE = linkonce_odr dso_local constant [18 x i8] c"N6Carbon7DerivedE\00", comdat, align 1
|
||||
// CHECK:STDOUT: @_ZTI4Base = linkonce_odr dso_local constant { ptr, ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr @_ZTS4Base, ptr @_ZTI11FurtherBase }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTS4Base = linkonce_odr dso_local constant [6 x i8] c"4Base\00", comdat, align 1
|
||||
// CHECK:STDOUT: @_ZTI11FurtherBase = linkonce_odr dso_local constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS11FurtherBase }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
|
||||
// CHECK:STDOUT: @_ZTS11FurtherBase = linkonce_odr dso_local constant [14 x i8] c"11FurtherBase\00", comdat, align 1
|
||||
// CHECK:STDOUT: @_ZTV4Base = linkonce_odr dso_local unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI4Base, ptr @_ZN11FurtherBase17further_base_funcEv, ptr @_ZN4Base4funcEv] }, comdat, align 8
|
||||
// CHECK:STDOUT: @_ZTV11FurtherBase = linkonce_odr dso_local unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI11FurtherBase, ptr @_ZN11FurtherBase17further_base_funcEv] }, comdat, align 8
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress uwtable
|
||||
// CHECK:STDOUT: define dso_local noundef i32 @_Z3UseR4Base(ptr noundef nonnull align 8 dereferenceable(12) %b) #0 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %Derived.other_func.call.vtable = load ptr, ptr %d, align 8, !dbg !18
|
||||
// CHECK:STDOUT: %Derived.other_func.call = call ptr @llvm.load.relative.i32(ptr %Derived.other_func.call.vtable, i32 0), !dbg !18
|
||||
// CHECK:STDOUT: call void %Derived.other_func.call(ptr %d), !dbg !18
|
||||
// CHECK:STDOUT: %.loc22_11.1.base = getelementptr inbounds nuw { [16 x i8] }, ptr %d, i32 0, i32 0, !dbg !19
|
||||
// CHECK:STDOUT: %.loc22_11.3.i = getelementptr inbounds nuw [16 x i8], ptr %.loc22_11.1.base, i32 0, i32 8, !dbg !19
|
||||
// CHECK:STDOUT: %.loc22_11.4 = load i32, ptr %.loc22_11.3.i, align 4, !dbg !19
|
||||
// CHECK:STDOUT: ret i32 %.loc22_11.4, !dbg !20
|
||||
// CHECK:STDOUT: %b.addr = alloca ptr, align 8
|
||||
// CHECK:STDOUT: store ptr %b, ptr %b.addr, align 8, !tbaa !11
|
||||
// CHECK:STDOUT: %0 = load ptr, ptr %b.addr, align 8, !tbaa !11, !nonnull !14, !align !15
|
||||
// CHECK:STDOUT: %vtable = load ptr, ptr %0, align 8, !tbaa !16
|
||||
// CHECK:STDOUT: %vfn = getelementptr inbounds ptr, ptr %vtable, i64 1
|
||||
// CHECK:STDOUT: %1 = load ptr, ptr %vfn, align 8
|
||||
// CHECK:STDOUT: %call = call noundef i32 %1(ptr noundef nonnull align 8 dereferenceable(12) %0)
|
||||
// CHECK:STDOUT: ret i32 %call
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: read)
|
||||
// CHECK:STDOUT: declare ptr @llvm.load.relative.i32(ptr, i32) #1
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress uwtable
|
||||
// CHECK:STDOUT: define dso_local void @_Z29WorkaroundToEmitCtorAndVtablev() #0 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %d = alloca %"class.Carbon::Derived", align 8
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %d) #5
|
||||
// CHECK:STDOUT: call void @_ZN6Carbon7DerivedC2Ev(ptr noundef nonnull align 8 dereferenceable(12) %d) #5
|
||||
// CHECK:STDOUT: call void @_ZN6Carbon7DerivedD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %d)
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %d) #5
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { nounwind }
|
||||
// CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) }
|
||||
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
||||
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon7DerivedC2Ev(ptr noundef nonnull align 8 dereferenceable(12) %this) unnamed_addr #2 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 !18
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: call void @_ZN4BaseC2Ev(ptr noundef nonnull align 8 dereferenceable(12) %this1) #5
|
||||
// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN6Carbon7DerivedE, i32 0, i32 0, i32 2), ptr %this1, align 8, !tbaa !16
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon7DerivedD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %this) unnamed_addr #2 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 !18
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN6Carbon7DerivedE, i32 0, i32 0, i32 2), ptr %this1, align 8, !tbaa !16
|
||||
// CHECK:STDOUT: call void @"_C__destroy_thunk:thunk.Derived.Main"(ptr noundef nonnull align 8 dereferenceable(12) %this1)
|
||||
// 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.end.p0(ptr captures(none)) #1
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress uwtable
|
||||
// CHECK:STDOUT: define dso_local noundef i32 @_Z7DoThingv() #0 personality ptr @__gxx_personality_v0 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %d = alloca %"class.Carbon::Derived", align 8
|
||||
// CHECK:STDOUT: %exn.slot = alloca ptr, align 8
|
||||
// CHECK:STDOUT: %ehselector.slot = alloca i32, align 4
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %d) #5
|
||||
// CHECK:STDOUT: call void @_ZN6Carbon7DerivedC2Ev(ptr noundef nonnull align 8 dereferenceable(12) %d) #5
|
||||
// CHECK:STDOUT: %call = invoke noundef i32 @_Z3UseR4Base(ptr noundef nonnull align 8 dereferenceable(12) %d)
|
||||
// CHECK:STDOUT: to label %invoke.cont unwind label %lpad
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: invoke.cont: ; preds = %entry
|
||||
// CHECK:STDOUT: call void @_ZN6Carbon7DerivedD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %d)
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %d) #5
|
||||
// CHECK:STDOUT: ret i32 %call
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: lpad: ; preds = %entry
|
||||
// CHECK:STDOUT: %0 = landingpad { ptr, i32 }
|
||||
// CHECK:STDOUT: cleanup
|
||||
// CHECK:STDOUT: %1 = extractvalue { ptr, i32 } %0, 0
|
||||
// CHECK:STDOUT: store ptr %1, ptr %exn.slot, align 8
|
||||
// CHECK:STDOUT: %2 = extractvalue { ptr, i32 } %0, 1
|
||||
// CHECK:STDOUT: store i32 %2, ptr %ehselector.slot, align 4
|
||||
// CHECK:STDOUT: invoke void @_ZN6Carbon7DerivedD2Ev(ptr noundef nonnull align 8 dead_on_return(12) dereferenceable(12) %d)
|
||||
// CHECK:STDOUT: to label %invoke.cont1 unwind label %terminate.lpad
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: invoke.cont1: ; preds = %lpad
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.end.p0(ptr %d) #5
|
||||
// CHECK:STDOUT: br label %eh.resume
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: eh.resume: ; preds = %invoke.cont1
|
||||
// CHECK:STDOUT: %exn = load ptr, ptr %exn.slot, align 8
|
||||
// CHECK:STDOUT: %sel = load i32, ptr %ehselector.slot, align 4
|
||||
// CHECK:STDOUT: %lpad.val = insertvalue { ptr, i32 } poison, ptr %exn, 0
|
||||
// CHECK:STDOUT: %lpad.val2 = insertvalue { ptr, i32 } %lpad.val, i32 %sel, 1
|
||||
// CHECK:STDOUT: resume { ptr, i32 } %lpad.val2
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: terminate.lpad: ; preds = %lpad
|
||||
// CHECK:STDOUT: %3 = landingpad { ptr, i32 }
|
||||
// CHECK:STDOUT: catch ptr null
|
||||
// CHECK:STDOUT: %4 = extractvalue { ptr, i32 } %3, 0
|
||||
// CHECK:STDOUT: call void @__clang_call_terminate(ptr %4) #7
|
||||
// CHECK:STDOUT: unreachable
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; uselistorder directives
|
||||
// CHECK:STDOUT: uselistorder ptr %d, { 0, 2, 1, 3, 4, 5, 6 }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare i32 @__gxx_personality_v0(...)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: noinline noreturn nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr hidden void @__clang_call_terminate(ptr noundef %0) #3 comdat {
|
||||
// CHECK:STDOUT: %2 = call ptr @__cxa_begin_catch(ptr %0) #5
|
||||
// CHECK:STDOUT: call void @_ZSt9terminatev() #7
|
||||
// CHECK:STDOUT: unreachable
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare ptr @__cxa_begin_catch(ptr)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare void @_ZSt9terminatev()
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local noundef i32 @_ZN11FurtherBase17further_base_funcEv(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #4 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 !20
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: ret i32 11
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local noundef i32 @_ZN4Base4funcEv(ptr noundef nonnull align 8 dereferenceable(12) %this) unnamed_addr #4 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 !11
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: ret i32 7
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define i32 @_Cother_func.Derived.Main(ptr %self) #5 !dbg !22 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret i32 3, !dbg !29
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define void @"_C__destroy_thunk:thunk.Derived.Main"(ptr %self) #6 !dbg !30 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @"_COp.12e0d0434542305a:core.Destroy.Core"(ptr %self), !dbg !35
|
||||
// CHECK:STDOUT: ret void, !dbg !35
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.bfe31446004e2b71:core.Destroy.Core"(ptr %self) #5 !dbg !36 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !39
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.12e0d0434542305a:core.Destroy.Core"(ptr %self) #5 !dbg !40 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !43
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN4BaseC2Ev(ptr noundef nonnull align 8 dereferenceable(12) %this) unnamed_addr #2 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 !11
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: call void @_ZN11FurtherBaseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this1) #5
|
||||
// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV4Base, i32 0, i32 0, i32 2), ptr %this1, align 8, !tbaa !16
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: inlinehint mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN11FurtherBaseC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %this) unnamed_addr #2 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 !20
|
||||
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
|
||||
// CHECK:STDOUT: store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV11FurtherBase, i32 0, i32 0, i32 2), ptr %this1, align 8, !tbaa !16
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; uselistorder directives
|
||||
// CHECK:STDOUT: uselistorder ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon7DerivedC2Ev, { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_ZN6Carbon7DerivedD2Ev, { 2, 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_ZN11FurtherBase17further_base_funcEv, { 3, 2, 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_ZN4Base4funcEv, { 2, 1, 0 }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
||||
// CHECK:STDOUT: attributes #2 = { 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: attributes #3 = { noinline noreturn nounwind uwtable "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 = { 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 = { nounwind }
|
||||
// CHECK:STDOUT: attributes #6 = { alwaysinline nounwind }
|
||||
// CHECK:STDOUT: attributes #7 = { noreturn nounwind }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
|
||||
// CHECK:STDOUT: !llvm.dbg.cu = !{!5}
|
||||
@@ -77,13 +325,36 @@ fn Use(d: Derived) -> i32 {
|
||||
// CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
|
||||
// CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
|
||||
// CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
|
||||
// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "Use", linkageName: "_CUse.Main", scope: null, file: !6, line: 20, type: !12, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !16)
|
||||
// CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
|
||||
// CHECK:STDOUT: !13 = !{!14, !15}
|
||||
// CHECK:STDOUT: !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
// CHECK:STDOUT: !15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||
// CHECK:STDOUT: !16 = !{!17}
|
||||
// CHECK:STDOUT: !17 = !DILocalVariable(arg: 1, scope: !11, type: !15)
|
||||
// CHECK:STDOUT: !18 = !DILocation(line: 21, column: 3, scope: !11)
|
||||
// CHECK:STDOUT: !19 = !DILocation(line: 22, column: 10, scope: !11)
|
||||
// CHECK:STDOUT: !20 = !DILocation(line: 22, column: 3, scope: !11)
|
||||
// CHECK:STDOUT: !11 = !{!12, !12, i64 0}
|
||||
// CHECK:STDOUT: !12 = !{!"p1 _ZTS4Base", !13, i64 0}
|
||||
// CHECK:STDOUT: !13 = !{!"any pointer", !9, i64 0}
|
||||
// CHECK:STDOUT: !14 = !{}
|
||||
// CHECK:STDOUT: !15 = !{i64 8}
|
||||
// CHECK:STDOUT: !16 = !{!17, !17, i64 0}
|
||||
// CHECK:STDOUT: !17 = !{!"vtable pointer", !10, i64 0}
|
||||
// CHECK:STDOUT: !18 = !{!19, !19, i64 0}
|
||||
// CHECK:STDOUT: !19 = !{!"p1 _ZTSN6Carbon7DerivedE", !13, i64 0}
|
||||
// CHECK:STDOUT: !20 = !{!21, !21, i64 0}
|
||||
// CHECK:STDOUT: !21 = !{!"p1 _ZTS11FurtherBase", !13, i64 0}
|
||||
// CHECK:STDOUT: !22 = distinct !DISubprogram(name: "other_func", linkageName: "_Cother_func.Derived.Main", scope: null, file: !6, line: 32, type: !23, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !27)
|
||||
// CHECK:STDOUT: !23 = !DISubroutineType(types: !24)
|
||||
// CHECK:STDOUT: !24 = !{!25, !26}
|
||||
// CHECK:STDOUT: !25 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
// CHECK:STDOUT: !26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||
// CHECK:STDOUT: !27 = !{!28}
|
||||
// CHECK:STDOUT: !28 = !DILocalVariable(arg: 1, scope: !22, type: !26)
|
||||
// CHECK:STDOUT: !29 = !DILocation(line: 33, column: 5, scope: !22)
|
||||
// CHECK:STDOUT: !30 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.Derived.Main", scope: null, file: !6, line: 27, type: !31, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !33)
|
||||
// CHECK:STDOUT: !31 = !DISubroutineType(types: !32)
|
||||
// CHECK:STDOUT: !32 = !{null, !26}
|
||||
// CHECK:STDOUT: !33 = !{!34}
|
||||
// CHECK:STDOUT: !34 = !DILocalVariable(arg: 1, scope: !30, type: !26)
|
||||
// CHECK:STDOUT: !35 = !DILocation(line: 27, column: 1, scope: !30)
|
||||
// CHECK:STDOUT: !36 = distinct !DISubprogram(name: "Op", linkageName: "_COp.bfe31446004e2b71:core.Destroy.Core", scope: null, file: !6, line: 27, type: !31, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !37)
|
||||
// CHECK:STDOUT: !37 = !{!38}
|
||||
// CHECK:STDOUT: !38 = !DILocalVariable(arg: 1, scope: !36, type: !26)
|
||||
// CHECK:STDOUT: !39 = !DILocation(line: 27, column: 1, scope: !36)
|
||||
// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp.12e0d0434542305a:core.Destroy.Core", scope: null, file: !6, line: 27, type: !31, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !41)
|
||||
// CHECK:STDOUT: !41 = !{!42}
|
||||
// CHECK:STDOUT: !42 = !DILocalVariable(arg: 1, scope: !40, type: !26)
|
||||
// CHECK:STDOUT: !43 = !DILocation(line: 27, column: 1, scope: !40)
|
||||
|
||||
Reference in New Issue
Block a user