1; RUN: opt -O2 -S < %s | FileCheck %s 2 3; Run global DCE to eliminate unused ctor and dtor. 4; rdar://9142819 5 6; CHECK: main 7; CHECK-NOT: _ZN4BaseC1Ev 8; CHECK-NOT: _ZN4BaseD1Ev 9; CHECK-NOT: _ZN4BaseD2Ev 10; CHECK-NOT: _ZN4BaseC2Ev 11; CHECK-NOT: _ZN4BaseD0Ev 12 13%class.Base = type { i32 (...)** } 14 15@_ZTV4Base = linkonce_odr unnamed_addr constant [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI4Base to i8*), i8* bitcast (void (%class.Base*)* @_ZN4BaseD1Ev to i8*), i8* bitcast (void (%class.Base*)* @_ZN4BaseD0Ev to i8*)] 16@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* 17@_ZTS4Base = linkonce_odr constant [6 x i8] c"4Base\00" 18@_ZTI4Base = linkonce_odr unnamed_addr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Base, i32 0, i32 0) } 19 20define i32 @main() uwtable ssp { 21entry: 22 %retval = alloca i32, align 4 23 %b = alloca %class.Base, align 8 24 %cleanup.dest.slot = alloca i32 25 store i32 0, i32* %retval 26 call void @_ZN4BaseC1Ev(%class.Base* %b) 27 store i32 0, i32* %retval 28 store i32 1, i32* %cleanup.dest.slot 29 call void @_ZN4BaseD1Ev(%class.Base* %b) 30 %0 = load i32, i32* %retval 31 ret i32 %0 32} 33 34define linkonce_odr void @_ZN4BaseC1Ev(%class.Base* %this) unnamed_addr uwtable ssp align 2 { 35entry: 36 %this.addr = alloca %class.Base*, align 8 37 store %class.Base* %this, %class.Base** %this.addr, align 8 38 %this1 = load %class.Base*, %class.Base** %this.addr 39 call void @_ZN4BaseC2Ev(%class.Base* %this1) 40 ret void 41} 42 43define linkonce_odr void @_ZN4BaseD1Ev(%class.Base* %this) unnamed_addr uwtable ssp align 2 { 44entry: 45 %this.addr = alloca %class.Base*, align 8 46 store %class.Base* %this, %class.Base** %this.addr, align 8 47 %this1 = load %class.Base*, %class.Base** %this.addr 48 call void @_ZN4BaseD2Ev(%class.Base* %this1) 49 ret void 50} 51 52define linkonce_odr void @_ZN4BaseD2Ev(%class.Base* %this) unnamed_addr nounwind uwtable ssp align 2 { 53entry: 54 %this.addr = alloca %class.Base*, align 8 55 store %class.Base* %this, %class.Base** %this.addr, align 8 56 %this1 = load %class.Base*, %class.Base** %this.addr 57 ret void 58} 59 60define linkonce_odr void @_ZN4BaseC2Ev(%class.Base* %this) unnamed_addr nounwind uwtable ssp align 2 { 61entry: 62 %this.addr = alloca %class.Base*, align 8 63 store %class.Base* %this, %class.Base** %this.addr, align 8 64 %this1 = load %class.Base*, %class.Base** %this.addr 65 %0 = bitcast %class.Base* %this1 to i8*** 66 store i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTV4Base, i64 0, i64 2), i8*** %0 67 ret void 68} 69 70define linkonce_odr void @_ZN4BaseD0Ev(%class.Base* %this) unnamed_addr uwtable ssp align 2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 71entry: 72 %this.addr = alloca %class.Base*, align 8 73 %exn.slot = alloca i8* 74 %ehselector.slot = alloca i32 75 store %class.Base* %this, %class.Base** %this.addr, align 8 76 %this1 = load %class.Base*, %class.Base** %this.addr 77 invoke void @_ZN4BaseD1Ev(%class.Base* %this1) 78 to label %invoke.cont unwind label %lpad 79 80invoke.cont: ; preds = %entry 81 %0 = bitcast %class.Base* %this1 to i8* 82 call void @_ZdlPv(i8* %0) nounwind 83 ret void 84 85lpad: ; preds = %entry 86 %1 = landingpad { i8*, i32 } 87 cleanup 88 %2 = extractvalue { i8*, i32 } %1, 0 89 store i8* %2, i8** %exn.slot 90 %3 = extractvalue { i8*, i32 } %1, 1 91 store i32 %3, i32* %ehselector.slot 92 %4 = bitcast %class.Base* %this1 to i8* 93 call void @_ZdlPv(i8* %4) nounwind 94 br label %eh.resume 95 96eh.resume: ; preds = %lpad 97 %exn = load i8*, i8** %exn.slot 98 %sel = load i32, i32* %ehselector.slot 99 %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn, 0 100 %lpad.val2 = insertvalue { i8*, i32 } %lpad.val, i32 %sel, 1 101 resume { i8*, i32 } %lpad.val2 102} 103 104declare i32 @__gxx_personality_v0(...) 105 106declare void @_ZdlPv(i8*) nounwind 107