blob: 824ad5ab1443286734bd8fd4f61da4aeef1a066a [file] [log] [blame]
Davide Italiano164b9bc2016-05-05 00:51:09 +00001; RUN: opt -S < %s -passes=constmerge | FileCheck %s
Rafael Espindola751677a2011-01-16 17:05:09 +00002; Test that in one run var3 is merged into var2 and var1 into var4.
Mehdi Amini46a43552015-03-04 18:43:29 +00003; Test that we merge @var5 and @var6 into one with the higher alignment
Rafael Espindola751677a2011-01-16 17:05:09 +00004
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 }
Nick Lewycky8ac9ece2011-07-27 19:47:34 +000018
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
Mehdi Amini46a43552015-03-04 18:43:29 +000025; 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
Rafael Espindola751677a2011-01-16 17:05:09 +000027
David Blaikie2f408302015-09-11 03:22:04 +000028@var4a = alias %struct.foobar, %struct.foobar* @var4
Rafael Espindolac229a4f2013-05-06 01:48:55 +000029@llvm.used = appending global [1 x %struct.foobar*] [%struct.foobar* @var4a], section "llvm.metadata"
30
Rafael Espindola751677a2011-01-16 17:05:09 +000031define i32 @main() {
32entry:
33 call void @zed(%struct.foobar* @var1, %struct.foobar* @var2)
34 call void @zed(%struct.foobar* @var3, %struct.foobar* @var4)
Nick Lewycky8ac9ece2011-07-27 19:47:34 +000035 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)
Rafael Espindola751677a2011-01-16 17:05:09 +000039 ret i32 0
40}
41