1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
; RUN: opt < %s -aa-pipeline=tbaa,basic-aa -passes=aa-eval -evaluate-aa-metadata -print-no-aliases -print-may-aliases -disable-output 2>&1 | FileCheck %s
; RUN: opt < %s -aa-pipeline=tbaa,basic-aa -passes=gvn -S | FileCheck %s --check-prefix=OPT
; Generated from clang/test/CodeGen/tbaa.cpp with "-O1 -struct-path-tbaa -disable-llvm-optzns".
%struct.StructA = type { i16, i32, i16, i32 }
%struct.StructB = type { i16, %struct.StructA, i32 }
%struct.StructS = type { i16, i32 }
%struct.StructS2 = type { i16, i32 }
%struct.StructC = type { i16, %struct.StructB, i32 }
%struct.StructD = type { i16, %struct.StructB, i32, i8 }
define i32 @_Z1gPjP7StructAy(ptr %s, ptr %A, i64 %count) #0 {
entry:
; Access to ptr and &(A->f32).
; CHECK: Function
; CHECK: MayAlias: store i32 4, ptr %f32, align 4, !tbaa !8 <-> store i32 1, ptr %0, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i32 4
; OPT: %[[RET:.*]] = load i32, ptr
; OPT: ret i32 %[[RET]]
%s.addr = alloca ptr, align 8
%A.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %s, ptr %s.addr, align 8, !tbaa !0
store ptr %A, ptr %A.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %s.addr, align 8, !tbaa !0
store i32 1, ptr %0, align 4, !tbaa !6
%1 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructA, ptr %1, i32 0, i32 1
store i32 4, ptr %f32, align 4, !tbaa !8
%2 = load ptr, ptr %s.addr, align 8, !tbaa !0
%3 = load i32, ptr %2, align 4, !tbaa !6
ret i32 %3
}
define i32 @_Z2g2PjP7StructAy(ptr %s, ptr %A, i64 %count) #0 {
entry:
; Access to ptr and &(A->f16).
; CHECK: Function
; CHECK: NoAlias: store i16 4, ptr %1, align 2, !tbaa !8 <-> store i32 1, ptr %0, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i16 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%s.addr = alloca ptr, align 8
%A.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %s, ptr %s.addr, align 8, !tbaa !0
store ptr %A, ptr %A.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %s.addr, align 8, !tbaa !0
store i32 1, ptr %0, align 4, !tbaa !6
%1 = load ptr, ptr %A.addr, align 8, !tbaa !0
store i16 4, ptr %1, align 2, !tbaa !11
%2 = load ptr, ptr %s.addr, align 8, !tbaa !0
%3 = load i32, ptr %2, align 4, !tbaa !6
ret i32 %3
}
define i32 @_Z2g3P7StructAP7StructBy(ptr %A, ptr %B, i64 %count) #0 {
entry:
; Access to &(A->f32) and &(B->a.f32).
; CHECK: Function
; CHECK: MayAlias: store i32 4, ptr %f321, align 4, !tbaa !10 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i32 4
; OPT: %[[RET:.*]] = load i32, ptr
; OPT: ret i32 %[[RET]]
%A.addr = alloca ptr, align 8
%B.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %A, ptr %A.addr, align 8, !tbaa !0
store ptr %B, ptr %B.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructA, ptr %0, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !8
%1 = load ptr, ptr %B.addr, align 8, !tbaa !0
%a = getelementptr inbounds %struct.StructB, ptr %1, i32 0, i32 1
%f321 = getelementptr inbounds %struct.StructA, ptr %a, i32 0, i32 1
store i32 4, ptr %f321, align 4, !tbaa !12
%2 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f322 = getelementptr inbounds %struct.StructA, ptr %2, i32 0, i32 1
%3 = load i32, ptr %f322, align 4, !tbaa !8
ret i32 %3
}
define i32 @_Z2g4P7StructAP7StructBy(ptr %A, ptr %B, i64 %count) #0 {
entry:
; Access to &(A->f32) and &(B->a.f16).
; CHECK: Function
; CHECK: NoAlias: store i16 4, ptr %a, align 2, !tbaa !10 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i16 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%A.addr = alloca ptr, align 8
%B.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %A, ptr %A.addr, align 8, !tbaa !0
store ptr %B, ptr %B.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructA, ptr %0, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !8
%1 = load ptr, ptr %B.addr, align 8, !tbaa !0
%a = getelementptr inbounds %struct.StructB, ptr %1, i32 0, i32 1
store i16 4, ptr %a, align 2, !tbaa !14
%2 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f321 = getelementptr inbounds %struct.StructA, ptr %2, i32 0, i32 1
%3 = load i32, ptr %f321, align 4, !tbaa !8
ret i32 %3
}
define i32 @_Z2g5P7StructAP7StructBy(ptr %A, ptr %B, i64 %count) #0 {
entry:
; Access to &(A->f32) and &(B->f32).
; CHECK: Function
; CHECK: NoAlias: store i32 4, ptr %f321, align 4, !tbaa !10 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i32 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%A.addr = alloca ptr, align 8
%B.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %A, ptr %A.addr, align 8, !tbaa !0
store ptr %B, ptr %B.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructA, ptr %0, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !8
%1 = load ptr, ptr %B.addr, align 8, !tbaa !0
%f321 = getelementptr inbounds %struct.StructB, ptr %1, i32 0, i32 2
store i32 4, ptr %f321, align 4, !tbaa !15
%2 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f322 = getelementptr inbounds %struct.StructA, ptr %2, i32 0, i32 1
%3 = load i32, ptr %f322, align 4, !tbaa !8
ret i32 %3
}
define i32 @_Z2g6P7StructAP7StructBy(ptr %A, ptr %B, i64 %count) #0 {
entry:
; Access to &(A->f32) and &(B->a.f32_2).
; CHECK: Function
; CHECK: NoAlias: store i32 4, ptr %f32_2, align 4, !tbaa !10 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i32 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%A.addr = alloca ptr, align 8
%B.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %A, ptr %A.addr, align 8, !tbaa !0
store ptr %B, ptr %B.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructA, ptr %0, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !8
%1 = load ptr, ptr %B.addr, align 8, !tbaa !0
%a = getelementptr inbounds %struct.StructB, ptr %1, i32 0, i32 1
%f32_2 = getelementptr inbounds %struct.StructA, ptr %a, i32 0, i32 3
store i32 4, ptr %f32_2, align 4, !tbaa !16
%2 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f321 = getelementptr inbounds %struct.StructA, ptr %2, i32 0, i32 1
%3 = load i32, ptr %f321, align 4, !tbaa !8
ret i32 %3
}
define i32 @_Z2g7P7StructAP7StructSy(ptr %A, ptr %S, i64 %count) #0 {
entry:
; Access to &(A->f32) and &(S->f32).
; CHECK: Function
; CHECK: NoAlias: store i32 4, ptr %f321, align 4, !tbaa !10 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i32 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%A.addr = alloca ptr, align 8
%S.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %A, ptr %A.addr, align 8, !tbaa !0
store ptr %S, ptr %S.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructA, ptr %0, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !8
%1 = load ptr, ptr %S.addr, align 8, !tbaa !0
%f321 = getelementptr inbounds %struct.StructS, ptr %1, i32 0, i32 1
store i32 4, ptr %f321, align 4, !tbaa !17
%2 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f322 = getelementptr inbounds %struct.StructA, ptr %2, i32 0, i32 1
%3 = load i32, ptr %f322, align 4, !tbaa !8
ret i32 %3
}
define i32 @_Z2g8P7StructAP7StructSy(ptr %A, ptr %S, i64 %count) #0 {
entry:
; Access to &(A->f32) and &(S->f16).
; CHECK: Function
; CHECK: NoAlias: store i16 4, ptr %1, align 2, !tbaa !10 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i16 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%A.addr = alloca ptr, align 8
%S.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %A, ptr %A.addr, align 8, !tbaa !0
store ptr %S, ptr %S.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructA, ptr %0, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !8
%1 = load ptr, ptr %S.addr, align 8, !tbaa !0
store i16 4, ptr %1, align 2, !tbaa !19
%2 = load ptr, ptr %A.addr, align 8, !tbaa !0
%f321 = getelementptr inbounds %struct.StructA, ptr %2, i32 0, i32 1
%3 = load i32, ptr %f321, align 4, !tbaa !8
ret i32 %3
}
define i32 @_Z2g9P7StructSP8StructS2y(ptr %S, ptr %S2, i64 %count) #0 {
entry:
; Access to &(S->f32) and &(S2->f32).
; CHECK: Function
; CHECK: NoAlias: store i32 4, ptr %f321, align 4, !tbaa !10 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i32 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%S.addr = alloca ptr, align 8
%S2.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %S, ptr %S.addr, align 8, !tbaa !0
store ptr %S2, ptr %S2.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %S.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructS, ptr %0, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !17
%1 = load ptr, ptr %S2.addr, align 8, !tbaa !0
%f321 = getelementptr inbounds %struct.StructS2, ptr %1, i32 0, i32 1
store i32 4, ptr %f321, align 4, !tbaa !20
%2 = load ptr, ptr %S.addr, align 8, !tbaa !0
%f322 = getelementptr inbounds %struct.StructS, ptr %2, i32 0, i32 1
%3 = load i32, ptr %f322, align 4, !tbaa !17
ret i32 %3
}
define i32 @_Z3g10P7StructSP8StructS2y(ptr %S, ptr %S2, i64 %count) #0 {
entry:
; Access to &(S->f32) and &(S2->f16).
; CHECK: Function
; CHECK: NoAlias: store i16 4, ptr %1, align 2, !tbaa !10 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i16 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%S.addr = alloca ptr, align 8
%S2.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %S, ptr %S.addr, align 8, !tbaa !0
store ptr %S2, ptr %S2.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %S.addr, align 8, !tbaa !0
%f32 = getelementptr inbounds %struct.StructS, ptr %0, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !17
%1 = load ptr, ptr %S2.addr, align 8, !tbaa !0
store i16 4, ptr %1, align 2, !tbaa !22
%2 = load ptr, ptr %S.addr, align 8, !tbaa !0
%f321 = getelementptr inbounds %struct.StructS, ptr %2, i32 0, i32 1
%3 = load i32, ptr %f321, align 4, !tbaa !17
ret i32 %3
}
define i32 @_Z3g11P7StructCP7StructDy(ptr %C, ptr %D, i64 %count) #0 {
entry:
; Access to &(C->b.a.f32) and &(D->b.a.f32).
; CHECK: Function
; CHECK: NoAlias: store i32 4, ptr %f323, align 4, !tbaa !12 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i32 4
; Remove a load and propagate the value from store.
; OPT: ret i32 1
%C.addr = alloca ptr, align 8
%D.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
store ptr %C, ptr %C.addr, align 8, !tbaa !0
store ptr %D, ptr %D.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %C.addr, align 8, !tbaa !0
%b = getelementptr inbounds %struct.StructC, ptr %0, i32 0, i32 1
%a = getelementptr inbounds %struct.StructB, ptr %b, i32 0, i32 1
%f32 = getelementptr inbounds %struct.StructA, ptr %a, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !23
%1 = load ptr, ptr %D.addr, align 8, !tbaa !0
%b1 = getelementptr inbounds %struct.StructD, ptr %1, i32 0, i32 1
%a2 = getelementptr inbounds %struct.StructB, ptr %b1, i32 0, i32 1
%f323 = getelementptr inbounds %struct.StructA, ptr %a2, i32 0, i32 1
store i32 4, ptr %f323, align 4, !tbaa !25
%2 = load ptr, ptr %C.addr, align 8, !tbaa !0
%b4 = getelementptr inbounds %struct.StructC, ptr %2, i32 0, i32 1
%a5 = getelementptr inbounds %struct.StructB, ptr %b4, i32 0, i32 1
%f326 = getelementptr inbounds %struct.StructA, ptr %a5, i32 0, i32 1
%3 = load i32, ptr %f326, align 4, !tbaa !23
ret i32 %3
}
define i32 @_Z3g12P7StructCP7StructDy(ptr %C, ptr %D, i64 %count) #0 {
entry:
; Access to &(b1->a.f32) and &(b2->a.f32).
; CHECK: Function
; CHECK: MayAlias: store i32 4, ptr %f325, align 4, !tbaa !6 <-> store i32 1, ptr %f32, align 4, !tbaa !6
; OPT: define
; OPT: store i32 1
; OPT: store i32 4
; OPT: %[[RET:.*]] = load i32, ptr
; OPT: ret i32 %[[RET]]
%C.addr = alloca ptr, align 8
%D.addr = alloca ptr, align 8
%count.addr = alloca i64, align 8
%b1 = alloca ptr, align 8
%b2 = alloca ptr, align 8
store ptr %C, ptr %C.addr, align 8, !tbaa !0
store ptr %D, ptr %D.addr, align 8, !tbaa !0
store i64 %count, ptr %count.addr, align 8, !tbaa !4
%0 = load ptr, ptr %C.addr, align 8, !tbaa !0
%b = getelementptr inbounds %struct.StructC, ptr %0, i32 0, i32 1
store ptr %b, ptr %b1, align 8, !tbaa !0
%1 = load ptr, ptr %D.addr, align 8, !tbaa !0
%b3 = getelementptr inbounds %struct.StructD, ptr %1, i32 0, i32 1
store ptr %b3, ptr %b2, align 8, !tbaa !0
%2 = load ptr, ptr %b1, align 8, !tbaa !0
%a = getelementptr inbounds %struct.StructB, ptr %2, i32 0, i32 1
%f32 = getelementptr inbounds %struct.StructA, ptr %a, i32 0, i32 1
store i32 1, ptr %f32, align 4, !tbaa !12
%3 = load ptr, ptr %b2, align 8, !tbaa !0
%a4 = getelementptr inbounds %struct.StructB, ptr %3, i32 0, i32 1
%f325 = getelementptr inbounds %struct.StructA, ptr %a4, i32 0, i32 1
store i32 4, ptr %f325, align 4, !tbaa !12
%4 = load ptr, ptr %b1, align 8, !tbaa !0
%a6 = getelementptr inbounds %struct.StructB, ptr %4, i32 0, i32 1
%f327 = getelementptr inbounds %struct.StructA, ptr %a6, i32 0, i32 1
%5 = load i32, ptr %f327, align 4, !tbaa !12
ret i32 %5
}
attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
!0 = !{!1, !1, i64 0}
!1 = !{!"any pointer", !2}
!2 = !{!"omnipotent char", !3}
!3 = !{!"Simple C/C++ TBAA"}
!4 = !{!5, !5, i64 0}
!5 = !{!"long long", !2}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !2}
!8 = !{!9, !7, i64 4}
!9 = !{!"_ZTS7StructA", !10, i64 0, !7, i64 4, !10, i64 8, !7, i64 12}
!10 = !{!"short", !2}
!11 = !{!9, !10, i64 0}
!12 = !{!13, !7, i64 8}
!13 = !{!"_ZTS7StructB", !10, i64 0, !9, i64 4, !7, i64 20}
!14 = !{!13, !10, i64 4}
!15 = !{!13, !7, i64 20}
!16 = !{!13, !7, i64 16}
!17 = !{!18, !7, i64 4}
!18 = !{!"_ZTS7StructS", !10, i64 0, !7, i64 4}
!19 = !{!18, !10, i64 0}
!20 = !{!21, !7, i64 4}
!21 = !{!"_ZTS8StructS2", !10, i64 0, !7, i64 4}
!22 = !{!21, !10, i64 0}
!23 = !{!24, !7, i64 12}
!24 = !{!"_ZTS7StructC", !10, i64 0, !13, i64 4, !7, i64 28}
!25 = !{!26, !7, i64 12}
!26 = !{!"_ZTS7StructD", !10, i64 0, !13, i64 4, !7, i64 28, !2, i64 32}
|