merge-both.ll 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ; RUN: opt -constmerge -S < %s | FileCheck %s
  2. ; Test that in one run var3 is merged into var2 and var1 into var4.
  3. ; Test that we merge @var5 and @var6 into one with the higher alignment
  4. declare void @zed(%struct.foobar*, %struct.foobar*)
  5. %struct.foobar = type { i32 }
  6. @var1 = internal constant %struct.foobar { i32 2 }
  7. @var2 = unnamed_addr constant %struct.foobar { i32 2 }
  8. @var3 = internal constant %struct.foobar { i32 2 }
  9. @var4 = unnamed_addr constant %struct.foobar { i32 2 }
  10. ; CHECK: %struct.foobar = type { i32 }
  11. ; CHECK-NOT: @
  12. ; CHECK: @var2 = constant %struct.foobar { i32 2 }
  13. ; CHECK-NEXT: @var4 = constant %struct.foobar { i32 2 }
  14. declare void @helper([16 x i8]*)
  15. @var5 = internal constant [16 x i8] c"foo1bar2foo3bar\00", align 16
  16. @var6 = private unnamed_addr constant [16 x i8] c"foo1bar2foo3bar\00", align 1
  17. @var7 = internal constant [16 x i8] c"foo1bar2foo3bar\00"
  18. @var8 = private unnamed_addr constant [16 x i8] c"foo1bar2foo3bar\00"
  19. ; CHECK-NEXT: @var7 = internal constant [16 x i8] c"foo1bar2foo3bar\00"
  20. ; CHECK-NEXT: @var8 = private constant [16 x i8] c"foo1bar2foo3bar\00", align 16
  21. @var4a = alias %struct.foobar* @var4
  22. @llvm.used = appending global [1 x %struct.foobar*] [%struct.foobar* @var4a], section "llvm.metadata"
  23. define i32 @main() {
  24. entry:
  25. call void @zed(%struct.foobar* @var1, %struct.foobar* @var2)
  26. call void @zed(%struct.foobar* @var3, %struct.foobar* @var4)
  27. call void @helper([16 x i8]* @var5)
  28. call void @helper([16 x i8]* @var6)
  29. call void @helper([16 x i8]* @var7)
  30. call void @helper([16 x i8]* @var8)
  31. ret i32 0
  32. }