gdce.ll 3.9 KB

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