1 ; RUN: opt -S < %s -passes=constmerge | 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
5 declare void @zed(ptr, ptr)
7 %struct.foobar = type { i32 }
9 @var1 = internal constant %struct.foobar { i32 2 }
10 @var2 = unnamed_addr constant %struct.foobar { i32 2 }
11 @var3 = internal constant %struct.foobar { i32 2 }
12 @var4 = unnamed_addr constant %struct.foobar { i32 2 }
14 ; CHECK: %struct.foobar = type { i32 }
16 ; CHECK: @var2 = constant %struct.foobar { i32 2 }
17 ; CHECK-NEXT: @var4 = constant %struct.foobar { i32 2 }
19 declare void @helper(ptr)
20 @var5 = internal constant [16 x i8] c"foo1bar2foo3bar\00", align 16
21 @var6 = private unnamed_addr constant [16 x i8] c"foo1bar2foo3bar\00", align 1
22 @var7 = internal constant [16 x i8] c"foo1bar2foo3bar\00"
23 @var8 = private unnamed_addr constant [16 x i8] c"foo1bar2foo3bar\00"
25 ; CHECK-NEXT: @var7 = internal constant [16 x i8] c"foo1bar2foo3bar\00"
26 ; CHECK-NEXT: @var8 = private constant [16 x i8] c"foo1bar2foo3bar\00", align 16
28 @var4a = alias %struct.foobar, ptr @var4
29 @llvm.used = appending global [1 x ptr] [ptr @var4a], section "llvm.metadata"
33 call void @zed(ptr @var1, ptr @var2)
34 call void @zed(ptr @var3, ptr @var4)
35 call void @helper(ptr @var5)
36 call void @helper(ptr @var6)
37 call void @helper(ptr @var7)
38 call void @helper(ptr @var8)