global_ctors_integration.ll 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ; RUN: opt -S -O2 < %s | FileCheck %s
  2. ; This test checks that -O2 is able to delete constructors that become empty
  3. ; only after some optimization passes have run, even if the pass structure
  4. ; changes.
  5. ; CHECK-NOT: @_GLOBAL__I_a
  6. %class.Foo = type { i32 }
  7. @foo = global %class.Foo zeroinitializer, align 4
  8. @_ZN3Bar18LINKER_INITIALIZEDE = external constant i32
  9. @llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
  10. define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" {
  11. %1 = load i32, i32* @_ZN3Bar18LINKER_INITIALIZEDE, align 4
  12. call void @_ZN3FooC1E17LinkerInitialized(%class.Foo* @foo, i32 %1)
  13. ret void
  14. }
  15. ; Function Attrs: ssp uwtable
  16. define linkonce_odr void @_ZN3FooC1E17LinkerInitialized(%class.Foo* %this, i32) unnamed_addr #0 align 2 {
  17. %2 = alloca %class.Foo*, align 8
  18. %3 = alloca i32, align 4
  19. store %class.Foo* %this, %class.Foo** %2, align 8
  20. store i32 %0, i32* %3, align 4
  21. %4 = load %class.Foo*, %class.Foo** %2
  22. %5 = load i32, i32* %3, align 4
  23. call void @_ZN3FooC2E17LinkerInitialized(%class.Foo* %4, i32 %5)
  24. ret void
  25. }
  26. ; Function Attrs: nounwind ssp uwtable
  27. define linkonce_odr void @_ZN3FooC2E17LinkerInitialized(%class.Foo* %this, i32) unnamed_addr #1 align 2 {
  28. %2 = alloca %class.Foo*, align 8
  29. %3 = alloca i32, align 4
  30. store %class.Foo* %this, %class.Foo** %2, align 8
  31. store i32 %0, i32* %3, align 4
  32. %4 = load %class.Foo*, %class.Foo** %2
  33. ret void
  34. }
  35. define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
  36. call void @__cxx_global_var_init()
  37. ret void
  38. }