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
5declare void @zed(%struct.foobar*, %struct.foobar*)
6
7%struct.foobar = type { i32 }
8
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 }
13
14; CHECK:      %struct.foobar = type { i32 }
15; CHECK-NOT: @
16; CHECK: @var2 = constant %struct.foobar { i32 2 }
17; CHECK-NEXT: @var4 = constant %struct.foobar { i32 2 }
18
19declare void @helper([16 x i8]*)
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"
24
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
27
28@var4a = alias %struct.foobar* @var4
29@llvm.used = appending global [1 x %struct.foobar*] [%struct.foobar* @var4a], section "llvm.metadata"
30
31define i32 @main() {
32entry:
33  call void @zed(%struct.foobar* @var1, %struct.foobar* @var2)
34  call void @zed(%struct.foobar* @var3, %struct.foobar* @var4)
35  call void @helper([16 x i8]* @var5)
36  call void @helper([16 x i8]* @var6)
37  call void @helper([16 x i8]* @var7)
38  call void @helper([16 x i8]* @var8)
39  ret i32 0
40}
41
42