blob: 21e390785df561597eeb82e99f6d32aa6cb424f2 [file] [log] [blame]
Chris Lattner75879be2010-02-12 18:17:23 +00001; RUN: opt < %s -constmerge -S | FileCheck %s
Chris Lattnerf118a412006-03-07 17:56:31 +00002
Chris Lattner75879be2010-02-12 18:17:23 +00003; Don't merge constants with specified sections.
Chris Lattnerf118a412006-03-07 17:56:31 +00004
Chris Lattner75879be2010-02-12 18:17:23 +00005@T1G1 = internal constant i32 1, section "foo"
6@T1G2 = internal constant i32 1, section "bar"
7@T1G3 = internal constant i32 1, section "bar"
Chris Lattnerf118a412006-03-07 17:56:31 +00008
Chris Lattner75879be2010-02-12 18:17:23 +00009; CHECK: @T1G1
10; CHECK: @T1G2
11; CHECK: @T1G3
12
13define void @test1(i32** %P1, i32** %P2, i32** %P3) {
14 store i32* @T1G1, i32** %P1
15 store i32* @T1G2, i32** %P2
16 store i32* @T1G3, i32** %P3
Tanya Lattner5640bd12008-03-01 09:15:35 +000017 ret void
Chris Lattnerf118a412006-03-07 17:56:31 +000018}
Tanya Lattner5640bd12008-03-01 09:15:35 +000019
Chris Lattner75879be2010-02-12 18:17:23 +000020@T2a = internal constant i32 224
21@T2b = internal addrspace(30) constant i32 224
22
23; CHECK: @T2a
24; CHECK: @T2b
25
26define void @test2(i32** %P1, i32 addrspace(30)** %P2) {
27 store i32* @T2a, i32** %P1
28 store i32 addrspace(30)* @T2b, i32 addrspace(30)** %P2
29 ret void
30}
Chris Lattner67e53452010-09-15 00:30:11 +000031
32; PR8144 - Don't merge globals marked attribute(used)
33; CHECK: @T3A =
34; CHECK: @T3B =
35
36@T3A = internal constant i32 0
37@T3B = internal constant i32 0
38@llvm.used = appending global [2 x i32*] [i32* @T3A, i32* @T3B], section
39"llvm.metadata"
40
41define void @test3() {
42 call void asm sideeffect "T3A, T3B",""() ; invisible use of T3A and T3B
43 ret void
44}
Evgeniy Stepanov8537d992017-03-09 00:03:37 +000045
46; Don't merge constants with !type annotations.
47
48@T4A1 = internal constant i32 2, !type !0
49@T4A2 = internal unnamed_addr constant i32 2, !type !1
50
51@T4B1 = internal constant i32 3, !type !0
52@T4B2 = internal unnamed_addr constant i32 3, !type !0
53
54@T4C1 = internal constant i32 4, !type !0
55@T4C2 = unnamed_addr constant i32 4
56
57@T4D1 = unnamed_addr constant i32 5, !type !0
58@T4D2 = internal constant i32 5
59
60!0 = !{i64 0, !"typeinfo name for A"}
61!1 = !{i64 0, !"typeinfo name for B"}
62
63; CHECK: @T4A1
64; CHECK: @T4A2
65; CHECK: @T4B1
66; CHECK: @T4B2
67; CHECK: @T4C1
68; CHECK: @T4C2
69; CHECK: @T4D1
70; CHECK: @T4D2
71
72define void @test4(i32** %P1, i32** %P2, i32** %P3, i32** %P4, i32** %P5, i32** %P6, i32** %P7, i32** %P8) {
73 store i32* @T4A1, i32** %P1
74 store i32* @T4A2, i32** %P2
75 store i32* @T4B1, i32** %P3
76 store i32* @T4B2, i32** %P4
77 store i32* @T4C1, i32** %P5
78 store i32* @T4C2, i32** %P6
79 store i32* @T4D1, i32** %P7
80 store i32* @T4D2, i32** %P8
81 ret void
82}