blob: ec5f7eceb972ef7a7a0b145f4e8404dfa4ca295d [file] [log] [blame]
Duncan P. N. Exon Smithc8eccd12014-08-19 21:08:27 +00001; RUN: verify-uselistorder < %s
Duncan P. N. Exon Smith6b6fdc92014-07-25 14:49:26 +00002
3@a = global [4 x i1] [i1 0, i1 1, i1 0, i1 1]
David Blaikie2f408302015-09-11 03:22:04 +00004@b = alias i1, getelementptr ([4 x i1], [4 x i1]* @a, i64 0, i64 2)
Duncan P. N. Exon Smith6b6fdc92014-07-25 14:49:26 +00005
Duncan P. N. Exon Smith3cbca202014-07-30 01:22:16 +00006; Check use-list order of constants used by globals.
7@glob1 = global i5 7
8@glob2 = global i5 7
9@glob3 = global i5 7
10
11; Check use-list order between variables and aliases.
12@target = global i3 zeroinitializer
David Blaikie2f408302015-09-11 03:22:04 +000013@alias1 = alias i3, i3* @target
14@alias2 = alias i3, i3* @target
15@alias3 = alias i3, i3* @target
Duncan P. N. Exon Smith3cbca202014-07-30 01:22:16 +000016@var1 = global i3* @target
17@var2 = global i3* @target
18@var3 = global i3* @target
19
Duncan P. N. Exon Smithc69b5162014-07-30 17:51:09 +000020; Check use-list order for a global when used both by a global and in a
21; function.
22@globalAndFunction = global i4 4
23@globalAndFunctionGlobalUser = global i4* @globalAndFunction
24
Duncan P. N. Exon Smith91778672014-07-31 00:13:28 +000025; Check use-list order for constants used by globals that are themselves used
26; as aliases. This confirms that this globals are recognized as GlobalValues
27; (not general constants).
28@const.global = global i63 0
29@const.global.ptr = global i63* @const.global
30@const.global.2 = global i63 0
31
32; Same as above, but for aliases.
33@const.target = global i62 1
David Blaikie2f408302015-09-11 03:22:04 +000034@const.alias = alias i62, i62* @const.target
35@const.alias.ptr = alias i62, i62* @const.alias
36@const.alias.2 = alias i62, i62* @const.target
Duncan P. N. Exon Smith91778672014-07-31 00:13:28 +000037
Duncan P. N. Exon Smith6b6fdc92014-07-25 14:49:26 +000038define i64 @f(i64 %f) {
39entry:
40 %sum = add i64 %f, 0
41 ret i64 %sum
42}
43
44define i64 @g(i64 %g) {
45entry:
46 %sum = add i64 %g, 0
47 ret i64 %sum
48}
49
50define i64 @h(i64 %h) {
51entry:
52 %sum = add i64 %h, 0
53 ret i64 %sum
54}
55
56define i64 @i(i64 %i) {
57entry:
58 %sum = add i64 %i, 1
59 ret i64 %sum
60}
61
62define i64 @j(i64 %j) {
63entry:
64 %sum = add i64 %j, 1
65 ret i64 %sum
66}
67
68define i64 @k(i64 %k) {
69entry:
70 %sum = add i64 %k, 1
71 ret i64 %sum
72}
73
74define i64 @l(i64 %l) {
75entry:
76 %sum = add i64 %l, 1
77 ret i64 %sum
78}
79
80define i1 @loadb() {
81entry:
David Blaikiea79ac142015-02-27 21:17:42 +000082 %b = load i1, i1* @b
Duncan P. N. Exon Smith6b6fdc92014-07-25 14:49:26 +000083 ret i1 %b
84}
85
86define i1 @loada() {
87entry:
David Blaikief72d05b2015-03-13 18:20:45 +000088 %a = load i1, i1* getelementptr ([4 x i1], [4 x i1]* @a, i64 0, i64 2)
Duncan P. N. Exon Smith6b6fdc92014-07-25 14:49:26 +000089 ret i1 %a
90}
91
92define i32 @f32(i32 %a, i32 %b, i32 %c, i32 %d) {
93entry:
94 br label %first
95
96second:
97 %eh = mul i32 %e, %h
98 %sum = add i32 %eh, %ef
99 br label %exit
100
101exit:
102 %product = phi i32 [%ef, %first], [%sum, %second]
103 ret i32 %product
104
105first:
106 %e = add i32 %a, 7
107 %f = add i32 %b, 7
108 %g = add i32 %c, 8
109 %h = add i32 %d, 8
110 %ef = mul i32 %e, %f
111 %gh = mul i32 %g, %h
112 %gotosecond = icmp slt i32 %gh, -9
113 br i1 %gotosecond, label %second, label %exit
114}
Duncan P. N. Exon Smithc69b5162014-07-30 17:51:09 +0000115
116define i4 @globalAndFunctionFunctionUser() {
117entry:
David Blaikiea79ac142015-02-27 21:17:42 +0000118 %local = load i4, i4* @globalAndFunction
Duncan P. N. Exon Smithc69b5162014-07-30 17:51:09 +0000119 ret i4 %local
120}
Duncan P. N. Exon Smithab6adeb2014-07-31 18:33:12 +0000121
122; Check for when an instruction is its own user.
Duncan P. N. Exon Smith8e366952014-08-18 23:44:14 +0000123define void @selfUser(i1 %a) {
Duncan P. N. Exon Smithab6adeb2014-07-31 18:33:12 +0000124entry:
125 ret void
126
127loop1:
128 br label %loop2
129
130loop2:
131 %var = phi i32 [ %var, %loop1 ], [ %var, %loop2 ]
Duncan P. N. Exon Smith8e366952014-08-18 23:44:14 +0000132 br label %loop2
Duncan P. N. Exon Smithab6adeb2014-07-31 18:33:12 +0000133}
Duncan P. N. Exon Smith6e1009b2014-08-01 22:27:19 +0000134
135; Check that block addresses work.
136@ba1 = constant i8* blockaddress (@bafunc1, %bb)
David Blaikief72d05b2015-03-13 18:20:45 +0000137@ba2 = constant i8* getelementptr (i8, i8* blockaddress (@bafunc2, %bb), i61 0)
138@ba3 = constant i8* getelementptr (i8, i8* blockaddress (@bafunc2, %bb), i61 0)
Duncan P. N. Exon Smith6e1009b2014-08-01 22:27:19 +0000139
140define i8* @babefore() {
David Blaikief72d05b2015-03-13 18:20:45 +0000141 ret i8* getelementptr (i8, i8* blockaddress (@bafunc2, %bb), i61 0)
Duncan P. N. Exon Smith6e1009b2014-08-01 22:27:19 +0000142bb1:
143 ret i8* blockaddress (@bafunc1, %bb)
144bb2:
145 ret i8* blockaddress (@bafunc3, %bb)
146}
147define void @bafunc1() {
148 unreachable
149bb:
150 unreachable
151}
152define void @bafunc2() {
153 unreachable
154bb:
155 unreachable
156}
157define void @bafunc3() {
158 unreachable
159bb:
160 unreachable
161}
162define i8* @baafter() {
163 ret i8* blockaddress (@bafunc2, %bb)
164bb1:
165 ret i8* blockaddress (@bafunc1, %bb)
166bb2:
167 ret i8* blockaddress (@bafunc3, %bb)
168}