1 ; RUN: opt -O2 -S < %s | FileCheck %s
3 ; Run global DCE to eliminate unused ctor and dtor.
7 ; CHECK-NOT: _ZN4BaseC1Ev
8 ; CHECK-NOT: _ZN4BaseD1Ev
9 ; CHECK-NOT: _ZN4BaseD2Ev
10 ; CHECK-NOT: _ZN4BaseC2Ev
11 ; CHECK-NOT: _ZN4BaseD0Ev
13 %class.Base = type { ptr }
15 @_ZTV4Base = linkonce_odr unnamed_addr constant [4 x ptr] [ptr null, ptr @_ZTI4Base, ptr @_ZN4BaseD1Ev, ptr @_ZN4BaseD0Ev]
16 @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr
17 @_ZTS4Base = linkonce_odr constant [6 x i8] c"4Base\00"
18 @_ZTI4Base = linkonce_odr unnamed_addr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS4Base }
20 define i32 @main() uwtable ssp {
22 %retval = alloca i32, align 4
23 %b = alloca %class.Base, align 8
24 %cleanup.dest.slot = alloca i32
25 store i32 0, ptr %retval
26 call void @_ZN4BaseC1Ev(ptr %b)
27 store i32 0, ptr %retval
28 store i32 1, ptr %cleanup.dest.slot
29 call void @_ZN4BaseD1Ev(ptr %b)
30 %0 = load i32, ptr %retval
34 define linkonce_odr void @_ZN4BaseC1Ev(ptr %this) unnamed_addr uwtable ssp align 2 {
36 %this.addr = alloca ptr, align 8
37 store ptr %this, ptr %this.addr, align 8
38 %this1 = load ptr, ptr %this.addr
39 call void @_ZN4BaseC2Ev(ptr %this1)
43 define linkonce_odr void @_ZN4BaseD1Ev(ptr %this) unnamed_addr uwtable ssp align 2 {
45 %this.addr = alloca ptr, align 8
46 store ptr %this, ptr %this.addr, align 8
47 %this1 = load ptr, ptr %this.addr
48 call void @_ZN4BaseD2Ev(ptr %this1)
52 define linkonce_odr void @_ZN4BaseD2Ev(ptr %this) unnamed_addr nounwind uwtable ssp align 2 {
54 %this.addr = alloca ptr, align 8
55 store ptr %this, ptr %this.addr, align 8
56 %this1 = load ptr, ptr %this.addr
60 define linkonce_odr void @_ZN4BaseC2Ev(ptr %this) unnamed_addr nounwind uwtable ssp align 2 {
62 %this.addr = alloca ptr, align 8
63 store ptr %this, ptr %this.addr, align 8
64 %this1 = load ptr, ptr %this.addr
65 store ptr getelementptr inbounds ([4 x ptr], ptr @_ZTV4Base, i64 0, i64 2), ptr %this1
69 define linkonce_odr void @_ZN4BaseD0Ev(ptr %this) unnamed_addr uwtable ssp align 2 personality ptr @__gxx_personality_v0 {
71 %this.addr = alloca ptr, align 8
72 %exn.slot = alloca ptr
73 %ehselector.slot = alloca i32
74 store ptr %this, ptr %this.addr, align 8
75 %this1 = load ptr, ptr %this.addr
76 invoke void @_ZN4BaseD1Ev(ptr %this1)
77 to label %invoke.cont unwind label %lpad
79 invoke.cont: ; preds = %entry
80 call void @_ZdlPv(ptr %this1) nounwind
83 lpad: ; preds = %entry
84 %0 = landingpad { ptr, i32 }
86 %1 = extractvalue { ptr, i32 } %0, 0
87 store ptr %1, ptr %exn.slot
88 %2 = extractvalue { ptr, i32 } %0, 1
89 store i32 %2, ptr %ehselector.slot
90 call void @_ZdlPv(ptr %this1) nounwind
93 eh.resume: ; preds = %lpad
94 %exn = load ptr, ptr %exn.slot
95 %sel = load i32, ptr %ehselector.slot
96 %lpad.val = insertvalue { ptr, i32 } undef, ptr %exn, 0
97 %lpad.val2 = insertvalue { ptr, i32 } %lpad.val, i32 %sel, 1
98 resume { ptr, i32 } %lpad.val2
101 declare i32 @__gxx_personality_v0(...)
103 declare void @_ZdlPv(ptr) nounwind