[AArch64][NFC] NFC for const vector as Instruction operand (#116790)
[llvm-project.git] / llvm / test / Transforms / Util / trivial-auto-var-init-call.ll
blobc12648a6b3d81e9d38f9effb2732c01771dce584
1 ; RUN: opt -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s
2 ; RUN: opt --try-experimental-debuginfo-iterators -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s
3 ; RUN: cat %t.opt.yaml | FileCheck -check-prefix=YAML %s
5 ; Emit remarks for memcpy, memmove, memset, bzero.
6 define void @known_call(ptr %src, ptr %dst, i64 %size) {
7 ; CHECK: Call to memset inserted by -ftrivial-auto-var-init.
8 ; YAML-LABEL: --- !Missed
9 ; YAML-NEXT: Pass:            annotation-remarks
10 ; YAML-NEXT: Name:            AutoInitIntrinsic
11 ; YAML-NEXT: DebugLoc:
12 ; YAML-NEXT: Function:        known_call
13 ; YAML-NEXT: Args:
14 ; YAML-NEXT:   - String:          'Call to '
15 ; YAML-NEXT:   - Callee:          memset
16 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
17 ; YAML-NEXT:   - String:          ' Inlined: '
18 ; YAML-NEXT:   - StoreInlined:     'false'
19 ; YAML-NEXT:   - String:          .
20 ; YAML-NEXT:   - String:          ' Volatile: '
21 ; YAML-NEXT:   - StoreVolatile:   'false'
22 ; YAML-NEXT:   - String:          .
23 ; YAML-NEXT:   - String:          ' Atomic: '
24 ; YAML-NEXT:   - StoreAtomic:     'false'
25 ; YAML-NEXT:   - String:          .
26 ; YAML-NEXT: ...
27   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 %size, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
28 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init.
29 ; YAML-LABEL: --- !Missed
30 ; YAML-NEXT: Pass:            annotation-remarks
31 ; YAML-NEXT: Name:            AutoInitIntrinsic
32 ; YAML-NEXT: DebugLoc:
33 ; YAML-NEXT: Function:        known_call
34 ; YAML-NEXT: Args:
35 ; YAML-NEXT:   - String:          'Call to '
36 ; YAML-NEXT:   - Callee:          memcpy
37 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
38 ; YAML-NEXT:   - String:          ' Inlined: '
39 ; YAML-NEXT:   - StoreInlined:     'false'
40 ; YAML-NEXT:   - String:          .
41 ; YAML-NEXT:   - String:          ' Volatile: '
42 ; YAML-NEXT:   - StoreVolatile:   'false'
43 ; YAML-NEXT:   - String:          .
44 ; YAML-NEXT:   - String:          ' Atomic: '
45 ; YAML-NEXT:   - StoreAtomic:     'false'
46 ; YAML-NEXT:   - String:          .
47 ; YAML-NEXT: ...
48   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %size, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
49 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init.
50 ; YAML-LABEL: --- !Missed
51 ; YAML-NEXT: Pass:            annotation-remarks
52 ; YAML-NEXT: Name:            AutoInitIntrinsic
53 ; YAML-NEXT: DebugLoc:
54 ; YAML-NEXT: Function:        known_call
55 ; YAML-NEXT: Args:
56 ; YAML-NEXT:   - String:          'Call to '
57 ; YAML-NEXT:   - Callee:          memmove
58 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
59 ; YAML-NEXT:   - String:          ' Inlined: '
60 ; YAML-NEXT:   - StoreInlined:     'false'
61 ; YAML-NEXT:   - String:          .
62 ; YAML-NEXT:   - String:          ' Volatile: '
63 ; YAML-NEXT:   - StoreVolatile:   'false'
64 ; YAML-NEXT:   - String:          .
65 ; YAML-NEXT:   - String:          ' Atomic: '
66 ; YAML-NEXT:   - StoreAtomic:     'false'
67 ; YAML-NEXT:   - String:          .
68 ; YAML-NEXT: ...
69   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %size, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
70 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init.
71 ; YAML-LABEL: --- !Missed
72 ; YAML-NEXT: Pass:            annotation-remarks
73 ; YAML-NEXT: Name:            AutoInitCall
74 ; YAML-NEXT: DebugLoc:
75 ; YAML-NEXT: Function:        known_call
76 ; YAML-NEXT: Args:
77 ; YAML-NEXT:   - String:          'Call to '
78 ; YAML-NEXT:   - Callee:          bzero
79 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
80 ; YAML-NEXT: ...
81   call void @bzero(ptr %dst, i64 %size), !annotation !0, !dbg !DILocation(scope: !4)
82 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init.
83 ; YAML-LABEL: --- !Missed
84 ; YAML-NEXT: Pass:            annotation-remarks
85 ; YAML-NEXT: Name:            AutoInitCall
86 ; YAML-NEXT: DebugLoc:
87 ; YAML-NEXT: Function:        known_call
88 ; YAML-NEXT: Args:
89 ; YAML-NEXT:   - String:          'Call to '
90 ; YAML-NEXT:   - Callee:          memset
91 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
92 ; YAML-NEXT:   - String:          ' Memory operation size: '
93 ; YAML-NEXT:   - StoreSize:       '32'
94 ; YAML-NEXT:   - String:          ' bytes.'
95 ; YAML-NEXT: ...
96   call ptr @memset(ptr %dst, i32 0, i64 32), !annotation !0, !dbg !DILocation(scope: !4)
97   ret void
100 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes.
101 define void @known_call_with_size(ptr %src, ptr %dst) {
102 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 32 bytes.
103 ; YAML-LABEL: --- !Missed
104 ; YAML-NEXT: Pass:            annotation-remarks
105 ; YAML-NEXT: Name:            AutoInitIntrinsic
106 ; YAML-NEXT: DebugLoc:
107 ; YAML-NEXT: Function:        known_call_with_size
108 ; YAML-NEXT: Args:
109 ; YAML-NEXT:   - String:          'Call to '
110 ; YAML-NEXT:   - Callee:          memset
111 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
112 ; YAML-NEXT:   - String:          ' Memory operation size: '
113 ; YAML-NEXT:   - StoreSize:       '32'
114 ; YAML-NEXT:   - String:          ' bytes.'
115 ; YAML-NEXT:   - String:          ' Inlined: '
116 ; YAML-NEXT:   - StoreInlined:     'false'
117 ; YAML-NEXT:   - String:          .
118 ; YAML-NEXT:   - String:          ' Volatile: '
119 ; YAML-NEXT:   - StoreVolatile:   'false'
120 ; YAML-NEXT:   - String:          .
121 ; YAML-NEXT:   - String:          ' Atomic: '
122 ; YAML-NEXT:   - StoreAtomic:     'false'
123 ; YAML-NEXT:   - String:          .
124 ; YAML-NEXT: ...
125   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 32, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
126 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 32 bytes.
127 ; YAML-LABEL: --- !Missed
128 ; YAML-NEXT: Pass:            annotation-remarks
129 ; YAML-NEXT: Name:            AutoInitIntrinsic
130 ; YAML-NEXT: DebugLoc:
131 ; YAML-NEXT: Function:        known_call_with_size
132 ; YAML-NEXT: Args:
133 ; YAML-NEXT:   - String:          'Call to '
134 ; YAML-NEXT:   - Callee:          memcpy
135 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
136 ; YAML-NEXT:   - String:          ' Memory operation size: '
137 ; YAML-NEXT:   - StoreSize:       '32'
138 ; YAML-NEXT:   - String:          ' bytes.'
139 ; YAML-NEXT:   - String:          ' Inlined: '
140 ; YAML-NEXT:   - StoreInlined:     'false'
141 ; YAML-NEXT:   - String:          .
142 ; YAML-NEXT:   - String:          ' Volatile: '
143 ; YAML-NEXT:   - StoreVolatile:   'false'
144 ; YAML-NEXT:   - String:          .
145 ; YAML-NEXT:   - String:          ' Atomic: '
146 ; YAML-NEXT:   - StoreAtomic:     'false'
147 ; YAML-NEXT:   - String:          .
148 ; YAML-NEXT: ...
149   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 32, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
150 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 32 bytes.
151 ; YAML-LABEL: --- !Missed
152 ; YAML-NEXT: Pass:            annotation-remarks
153 ; YAML-NEXT: Name:            AutoInitIntrinsic
154 ; YAML-NEXT: DebugLoc:
155 ; YAML-NEXT: Function:        known_call_with_size
156 ; YAML-NEXT: Args:
157 ; YAML-NEXT:   - String:          'Call to '
158 ; YAML-NEXT:   - Callee:          memmove
159 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
160 ; YAML-NEXT:   - String:          ' Memory operation size: '
161 ; YAML-NEXT:   - StoreSize:       '32'
162 ; YAML-NEXT:   - String:          ' bytes.'
163 ; YAML-NEXT:   - String:          ' Inlined: '
164 ; YAML-NEXT:   - StoreInlined:     'false'
165 ; YAML-NEXT:   - String:          .
166 ; YAML-NEXT:   - String:          ' Volatile: '
167 ; YAML-NEXT:   - StoreVolatile:   'false'
168 ; YAML-NEXT:   - String:          .
169 ; YAML-NEXT:   - String:          ' Atomic: '
170 ; YAML-NEXT:   - StoreAtomic:     'false'
171 ; YAML-NEXT:   - String:          .
172 ; YAML-NEXT: ...
173   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 32, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
174 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 32 bytes.
175 ; YAML-LABEL: --- !Missed
176 ; YAML-NEXT: Pass:            annotation-remarks
177 ; YAML-NEXT: Name:            AutoInitCall
178 ; YAML-NEXT: DebugLoc:
179 ; YAML-NEXT: Function:        known_call_with_size
180 ; YAML-NEXT: Args:
181 ; YAML-NEXT:   - String:          'Call to '
182 ; YAML-NEXT:   - Callee:          bzero
183 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
184 ; YAML-NEXT:   - String:          ' Memory operation size: '
185 ; YAML-NEXT:   - StoreSize:       '32'
186 ; YAML-NEXT:   - String:          ' bytes.'
187 ; YAML-NEXT: ...
188   call void @bzero(ptr %dst, i64 32), !annotation !0, !dbg !DILocation(scope: !4)
190   ret void
193 ; Emit remarks for memcpy, memmove, memset marked volatile.
194 define void @known_call_volatile(ptr %src, ptr %dst, i64 %size) {
195 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Volatile: true.
196 ; YAML-LABEL: --- !Missed
197 ; YAML-NEXT: Pass:            annotation-remarks
198 ; YAML-NEXT: Name:            AutoInitIntrinsic
199 ; YAML-NEXT: DebugLoc:
200 ; YAML-NEXT: Function:        known_call_volatile
201 ; YAML-NEXT: Args:
202 ; YAML-NEXT:   - String:          'Call to '
203 ; YAML-NEXT:   - Callee:          memset
204 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
205 ; YAML-NEXT:   - String:          ' Volatile: '
206 ; YAML-NEXT:   - StoreVolatile:   'true'
207 ; YAML-NEXT:   - String:          .
208 ; YAML-NEXT:   - String:          ' Inlined: '
209 ; YAML-NEXT:   - StoreInlined:     'false'
210 ; YAML-NEXT:   - String:          .
211 ; YAML-NEXT:   - String:          ' Atomic: '
212 ; YAML-NEXT:   - StoreAtomic:     'false'
213 ; YAML-NEXT:   - String:          .
214 ; YAML-NEXT: ...
215   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 %size, i1 true), !annotation !0, !dbg !DILocation(scope: !4)
216 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Volatile: true.
217 ; YAML-LABEL: --- !Missed
218 ; YAML-NEXT: Pass:            annotation-remarks
219 ; YAML-NEXT: Name:            AutoInitIntrinsic
220 ; YAML-NEXT: DebugLoc:
221 ; YAML-NEXT: Function:        known_call_volatile
222 ; YAML-NEXT: Args:
223 ; YAML-NEXT:   - String:          'Call to '
224 ; YAML-NEXT:   - Callee:          memcpy
225 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
226 ; YAML-NEXT:   - String:          ' Volatile: '
227 ; YAML-NEXT:   - StoreVolatile:   'true'
228 ; YAML-NEXT:   - String:          .
229 ; YAML-NEXT:   - String:          ' Inlined: '
230 ; YAML-NEXT:   - StoreInlined:     'false'
231 ; YAML-NEXT:   - String:          .
232 ; YAML-NEXT:   - String:          ' Atomic: '
233 ; YAML-NEXT:   - StoreAtomic:     'false'
234 ; YAML-NEXT:   - String:          .
235 ; YAML-NEXT: ...
236   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %size, i1 true), !annotation !0, !dbg !DILocation(scope: !4)
237 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Volatile: true.
238 ; YAML-LABEL: --- !Missed
239 ; YAML-NEXT: Pass:            annotation-remarks
240 ; YAML-NEXT: Name:            AutoInitIntrinsic
241 ; YAML-NEXT: DebugLoc:
242 ; YAML-NEXT: Function:        known_call_volatile
243 ; YAML-NEXT: Args:
244 ; YAML-NEXT:   - String:          'Call to '
245 ; YAML-NEXT:   - Callee:          memmove
246 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
247 ; YAML-NEXT:   - String:          ' Volatile: '
248 ; YAML-NEXT:   - StoreVolatile:   'true'
249 ; YAML-NEXT:   - String:          .
250 ; YAML-NEXT:   - String:          ' Inlined: '
251 ; YAML-NEXT:   - StoreInlined:     'false'
252 ; YAML-NEXT:   - String:          .
253 ; YAML-NEXT:   - String:          ' Atomic: '
254 ; YAML-NEXT:   - StoreAtomic:     'false'
255 ; YAML-NEXT:   - String:          .
256 ; YAML-NEXT: ...
257   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %size, i1 true), !annotation !0, !dbg !DILocation(scope: !4)
258   ret void
261 ; Emit remarks for memcpy, memmove, memset marked atomic.
262 define void @known_call_atomic(ptr %src, ptr %dst, i64 %size) {
263 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Atomic: true.
264 ; YAML-LABEL: --- !Missed
265 ; YAML-NEXT: Pass:            annotation-remarks
266 ; YAML-NEXT: Name:            AutoInitIntrinsic
267 ; YAML-NEXT: DebugLoc:
268 ; YAML-NEXT: Function:        known_call_atomic
269 ; YAML-NEXT: Args:
270 ; YAML-NEXT:   - String:          'Call to '
271 ; YAML-NEXT:   - Callee:          memset
272 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
273 ; YAML-NEXT:   - String:          ' Atomic: '
274 ; YAML-NEXT:   - StoreAtomic:     'true'
275 ; YAML-NEXT:   - String:          .
276 ; YAML-NEXT:   - String:          ' Inlined: '
277 ; YAML-NEXT:   - StoreInlined:     'false'
278 ; YAML-NEXT:   - String:          .
279 ; YAML-NEXT:   - String:          ' Volatile: '
280 ; YAML-NEXT:   - StoreVolatile:   'false'
281 ; YAML-NEXT:   - String:          .
282 ; YAML-NEXT: ...
283   call void @llvm.memset.element.unordered.atomic.p0.i64(ptr align 1 %dst, i8 0, i64 %size, i32 1), !annotation !0, !dbg !DILocation(scope: !4)
284 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Atomic: true.
285 ; YAML-LABEL: --- !Missed
286 ; YAML-NEXT: Pass:            annotation-remarks
287 ; YAML-NEXT: Name:            AutoInitIntrinsic
288 ; YAML-NEXT: DebugLoc:
289 ; YAML-NEXT: Function:        known_call_atomic
290 ; YAML-NEXT: Args:
291 ; YAML-NEXT:   - String:          'Call to '
292 ; YAML-NEXT:   - Callee:          memcpy
293 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
294 ; YAML-NEXT:   - String:          ' Atomic: '
295 ; YAML-NEXT:   - StoreAtomic:     'true'
296 ; YAML-NEXT:   - String:          .
297 ; YAML-NEXT:   - String:          ' Inlined: '
298 ; YAML-NEXT:   - StoreInlined:     'false'
299 ; YAML-NEXT:   - String:          .
300 ; YAML-NEXT:   - String:          ' Volatile: '
301 ; YAML-NEXT:   - StoreVolatile:   'false'
302 ; YAML-NEXT:   - String:          .
303 ; YAML-NEXT: ...
304   call void @llvm.memcpy.element.unordered.atomic.p0.p0.i64(ptr align 1 %dst, ptr align 1 %src, i64 %size, i32 1), !annotation !0, !dbg !DILocation(scope: !4)
305 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Atomic: true.
306 ; YAML-LABEL: --- !Missed
307 ; YAML-NEXT: Pass:            annotation-remarks
308 ; YAML-NEXT: Name:            AutoInitIntrinsic
309 ; YAML-NEXT: DebugLoc:
310 ; YAML-NEXT: Function:        known_call_atomic
311 ; YAML-NEXT: Args:
312 ; YAML-NEXT:   - String:          'Call to '
313 ; YAML-NEXT:   - Callee:          memmove
314 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
315 ; YAML-NEXT:   - String:          ' Atomic: '
316 ; YAML-NEXT:   - StoreAtomic:     'true'
317 ; YAML-NEXT:   - String:          .
318 ; YAML-NEXT:   - String:          ' Inlined: '
319 ; YAML-NEXT:   - StoreInlined:     'false'
320 ; YAML-NEXT:   - String:          .
321 ; YAML-NEXT:   - String:          ' Volatile: '
322 ; YAML-NEXT:   - StoreVolatile:   'false'
323 ; YAML-NEXT:   - String:          .
324 ; YAML-NEXT: ...
325   call void @llvm.memmove.element.unordered.atomic.p0.p0.i64(ptr align 1 %dst, ptr align 1 %src, i64 %size, i32 1), !annotation !0, !dbg !DILocation(scope: !4)
326   ret void
329 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes to
330 ; an alloca.
331 define void @known_call_with_size_alloca(ptr %src) {
332 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
333 ; CHECK-NEXT: Variables: dst (1 bytes).
334 ; YAML-LABEL: --- !Missed
335 ; YAML-NEXT: Pass:            annotation-remarks
336 ; YAML-NEXT: Name:            AutoInitIntrinsic
337 ; YAML-NEXT: DebugLoc:
338 ; YAML-NEXT: Function:        known_call_with_size_alloca
339 ; YAML-NEXT: Args:
340 ; YAML-NEXT:   - String:          'Call to '
341 ; YAML-NEXT:   - Callee:          memset
342 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
343 ; YAML-NEXT:   - String:          ' Memory operation size: '
344 ; YAML-NEXT:   - StoreSize:       '1'
345 ; YAML-NEXT:   - String:          ' bytes.'
346 ; YAML-NEXT:   - String:          "\n Written Variables: "
347 ; YAML-NEXT:   - WVarName:        dst
348 ; YAML-NEXT:   - String:          ' ('
349 ; YAML-NEXT:   - WVarSize:        '1'
350 ; YAML-NEXT:   - String:          ' bytes)'
351 ; YAML-NEXT:   - String:          .
352 ; YAML-NEXT:   - String:          ' Inlined: '
353 ; YAML-NEXT:   - StoreInlined:     'false'
354 ; YAML-NEXT:   - String:          .
355 ; YAML-NEXT:   - String:          ' Volatile: '
356 ; YAML-NEXT:   - StoreVolatile:   'false'
357 ; YAML-NEXT:   - String:          .
358 ; YAML-NEXT:   - String:          ' Atomic: '
359 ; YAML-NEXT:   - StoreAtomic:     'false'
360 ; YAML-NEXT:   - String:          .
361 ; YAML-NEXT: ...
362   %dst = alloca i8
363   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
364 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
365 ; CHECK-NEXT: Variables: dst (1 bytes).
366 ; YAML-LABEL: --- !Missed
367 ; YAML-NEXT: Pass:            annotation-remarks
368 ; YAML-NEXT: Name:            AutoInitIntrinsic
369 ; YAML-NEXT: DebugLoc:
370 ; YAML-NEXT: Function:        known_call_with_size_alloca
371 ; YAML-NEXT: Args:
372 ; YAML-NEXT:   - String:          'Call to '
373 ; YAML-NEXT:   - Callee:          memcpy
374 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
375 ; YAML-NEXT:   - String:          ' Memory operation size: '
376 ; YAML-NEXT:   - StoreSize:       '1'
377 ; YAML-NEXT:   - String:          ' bytes.'
378 ; YAML-NEXT:   - String:          "\n Written Variables: "
379 ; YAML-NEXT:   - WVarName:        dst
380 ; YAML-NEXT:   - String:          ' ('
381 ; YAML-NEXT:   - WVarSize:        '1'
382 ; YAML-NEXT:   - String:          ' bytes)'
383 ; YAML-NEXT:   - String:          .
384 ; YAML-NEXT:   - String:          ' Inlined: '
385 ; YAML-NEXT:   - StoreInlined:     'false'
386 ; YAML-NEXT:   - String:          .
387 ; YAML-NEXT:   - String:          ' Volatile: '
388 ; YAML-NEXT:   - StoreVolatile:   'false'
389 ; YAML-NEXT:   - String:          .
390 ; YAML-NEXT:   - String:          ' Atomic: '
391 ; YAML-NEXT:   - StoreAtomic:     'false'
392 ; YAML-NEXT:   - String:          .
393 ; YAML-NEXT: ...
394   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
395 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
396 ; CHECK-NEXT: Variables: dst (1 bytes).
397 ; YAML-LABEL: --- !Missed
398 ; YAML-NEXT: Pass:            annotation-remarks
399 ; YAML-NEXT: Name:            AutoInitIntrinsic
400 ; YAML-NEXT: DebugLoc:
401 ; YAML-NEXT: Function:        known_call_with_size_alloca
402 ; YAML-NEXT: Args:
403 ; YAML-NEXT:   - String:          'Call to '
404 ; YAML-NEXT:   - Callee:          memmove
405 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
406 ; YAML-NEXT:   - String:          ' Memory operation size: '
407 ; YAML-NEXT:   - StoreSize:       '1'
408 ; YAML-NEXT:   - String:          ' bytes.'
409 ; YAML-NEXT:   - String:          "\n Written Variables: "
410 ; YAML-NEXT:   - WVarName:        dst
411 ; YAML-NEXT:   - String:          ' ('
412 ; YAML-NEXT:   - WVarSize:        '1'
413 ; YAML-NEXT:   - String:          ' bytes)'
414 ; YAML-NEXT:   - String:          .
415 ; YAML-NEXT:   - String:          ' Inlined: '
416 ; YAML-NEXT:   - StoreInlined:     'false'
417 ; YAML-NEXT:   - String:          .
418 ; YAML-NEXT:   - String:          ' Volatile: '
419 ; YAML-NEXT:   - StoreVolatile:   'false'
420 ; YAML-NEXT:   - String:          .
421 ; YAML-NEXT:   - String:          ' Atomic: '
422 ; YAML-NEXT:   - StoreAtomic:     'false'
423 ; YAML-NEXT:   - String:          .
424 ; YAML-NEXT: ...
425   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
426 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
427 ; CHECK-NEXT: Variables: dst (1 bytes).
428 ; YAML-LABEL: --- !Missed
429 ; YAML-NEXT: Pass:            annotation-remarks
430 ; YAML-NEXT: Name:            AutoInitCall
431 ; YAML-NEXT: DebugLoc:
432 ; YAML-NEXT: Function:        known_call_with_size_alloca
433 ; YAML-NEXT: Args:
434 ; YAML-NEXT:   - String:          'Call to '
435 ; YAML-NEXT:   - Callee:          bzero
436 ; YAML-NEXT:   - String:          ' inserted by -ftrivial-auto-var-init.'
437 ; YAML-NEXT:   - String:          ' Memory operation size: '
438 ; YAML-NEXT:   - StoreSize:       '1'
439 ; YAML-NEXT:   - String:          ' bytes.'
440 ; YAML-NEXT:   - String:          "\n Written Variables: "
441 ; YAML-NEXT:   - WVarName:        dst
442 ; YAML-NEXT:   - String:          ' ('
443 ; YAML-NEXT:   - WVarSize:        '1'
444 ; YAML-NEXT:   - String:          ' bytes)'
445 ; YAML-NEXT:   - String:          .
446 ; YAML-NEXT: ...
447   call void @bzero(ptr %dst, i64 1), !annotation !0, !dbg !DILocation(scope: !4)
449   ret void
452 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes to
453 ; an alloca through a GEP.
454 define void @known_call_with_size_alloca_gep(ptr %src) {
455 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
456 ; CHECK-NEXT: Variables: dst (1 bytes).
457   %dst = alloca i8
458   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
459 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
460 ; CHECK-NEXT: Variables: dst (1 bytes).
461   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
462 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
463 ; CHECK-NEXT: Variables: dst (1 bytes).
464   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
465 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
466 ; CHECK-NEXT: Variables: dst (1 bytes).
467   call void @bzero(ptr %dst, i64 1), !annotation !0, !dbg !DILocation(scope: !4)
468   ret void
471 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes to
472 ; an alloca through a GEP in an array.
473 define void @known_call_with_size_alloca_gep_array(ptr %src) {
474 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
475 ; CHECK-NEXT: Variables: dst (2 bytes).
476   %dst = alloca [2 x i8]
477   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
478 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
479 ; CHECK-NEXT: Variables: dst (2 bytes).
480   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
481 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
482 ; CHECK-NEXT: Variables: dst (2 bytes).
483   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
484 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
485 ; CHECK-NEXT: Variables: dst (2 bytes).
486   call void @bzero(ptr %dst, i64 1), !annotation !0, !dbg !DILocation(scope: !4)
487   ret void
490 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes to
491 ; an alloca through a bitcast.
492 define void @known_call_with_size_alloca_bitcast(ptr %src) {
493 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
494 ; CHECK-NEXT: Variables: dst (2 bytes).
495   %dst = alloca [2 x i8]
496   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
497 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
498 ; CHECK-NEXT: Variables: dst (2 bytes).
499   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
500 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
501 ; CHECK-NEXT: Variables: dst (2 bytes).
502   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
503 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
504 ; CHECK-NEXT: Variables: dst (2 bytes).
505   call void @bzero(ptr %dst, i64 1), !annotation !0, !dbg !DILocation(scope: !4)
506   ret void
509 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes to an alloca that has a DILocalVariable attached.
510 define void @known_call_with_size_alloca_di(ptr %src) {
511 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
512 ; CHECK-NEXT: Variables: destination (1 bytes).
513   %dst = alloca i8
514   call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
515   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
516 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
517 ; CHECK-NEXT: Variables: destination (1 bytes).
518   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
519 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
520 ; CHECK-NEXT: Variables: destination (1 bytes).
521   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
522 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
523 ; CHECK-NEXT: Variables: destination (1 bytes).
524   call void @bzero(ptr %dst, i64 1), !annotation !0, !dbg !DILocation(scope: !4)
525   ret void
528 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes to
529 ; an alloca that has more than one DILocalVariable attached.
530 define void @known_call_with_size_alloca_di_multiple(ptr %src) {
531 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
532 ; CHECK-NEXT: Variables: destination (1 bytes).
533   %dst = alloca i8
534   call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
535   call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
536 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
537 ; CHECK-NEXT: Variables: destination (1 bytes).
538   call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
539 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
540 ; CHECK-NEXT: Variables: destination (1 bytes).
541   call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
542 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
543 ; CHECK-NEXT: Variables: destination (1 bytes).
544   call void @bzero(ptr %dst, i64 1), !annotation !0, !dbg !DILocation(scope: !4)
545   ret void
548 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes to
549 ; a PHI node that can be two different allocas.
550 define void @known_call_with_size_alloca_phi(ptr %src) {
551 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
552 ; CHECK-NEXT: Variables: dst2 (1 bytes), dst (1 bytes).
553 entry:
554   %dst = alloca i8
555   %dst2 = alloca i8
556   %cmp = icmp eq i32 undef, undef
557   br i1 %cmp, label %l0, label %l1
559   br label %l2
561   br label %l2
563   %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ]
564   call void @llvm.memset.p0.i64(ptr %phidst, i8 0, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
565 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
566 ; CHECK-NEXT: Variables: dst2 (1 bytes), dst (1 bytes).
567   call void @llvm.memcpy.p0.p0.i64(ptr %phidst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
568 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
569 ; CHECK-NEXT: Variables: dst2 (1 bytes), dst (1 bytes).
570   call void @llvm.memmove.p0.p0.i64(ptr %phidst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
571 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
572 ; CHECK-NEXT: Variables: dst2 (1 bytes), dst (1 bytes).
573   call void @bzero(ptr %phidst, i64 1), !annotation !0, !dbg !DILocation(scope: !4)
574   ret void
577 ; Emit remarks for memcpy, memmove, memset, bzero with known constant sizes to
578 ; a PHI node that can be two different allocas, where one of it has multiple
579 ; DILocalVariable.
580 define void @known_call_with_size_alloca_phi_di_multiple(ptr %src) {
581 ; CHECK-NEXT: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
582 ; CHECK-NEXT: Variables: dst2 (1 bytes), destination2 (1 bytes), destination (1 bytes).
583 entry:
584   %dst = alloca i8
585   %dst2 = alloca i8
586   call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
587   call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)
588   %cmp = icmp eq i32 undef, undef
589   br i1 %cmp, label %l0, label %l1
591   br label %l2
593   br label %l2
595   %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ]
596   call void @llvm.memset.p0.i64(ptr %phidst, i8 0, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
597 ; CHECK-NEXT: Call to memcpy inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
598 ; CHECK-NEXT: Variables: dst2 (1 bytes), destination2 (1 bytes), destination (1 bytes).
599   call void @llvm.memcpy.p0.p0.i64(ptr %phidst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
600 ; CHECK-NEXT: Call to memmove inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
601 ; CHECK-NEXT: Variables: dst2 (1 bytes), destination2 (1 bytes), destination (1 bytes).
602   call void @llvm.memmove.p0.p0.i64(ptr %phidst, ptr %src, i64 1, i1 false), !annotation !0, !dbg !DILocation(scope: !4)
603 ; CHECK-NEXT: Call to bzero inserted by -ftrivial-auto-var-init. Memory operation size: 1 bytes.
604 ; CHECK-NEXT: Variables: dst2 (1 bytes), destination2 (1 bytes), destination (1 bytes).
605   call void @bzero(ptr %phidst, i64 1), !annotation !0, !dbg !DILocation(scope: !4)
606   ret void
609 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone speculatable willreturn
610 declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) argmemonly nounwind willreturn writeonly
611 declare void @llvm.memmove.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1 immarg) argmemonly nounwind willreturn
612 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) argmemonly nounwind willreturn
614 declare void @llvm.memset.element.unordered.atomic.p0.i64(ptr nocapture writeonly, i8, i64, i32 immarg) argmemonly nounwind willreturn writeonly
615 declare void @llvm.memcpy.element.unordered.atomic.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i32 immarg) argmemonly nounwind willreturn
616 declare void @llvm.memmove.element.unordered.atomic.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i32 immarg) argmemonly nounwind willreturn
618 declare void @bzero(ptr nocapture, i64) nofree nounwind
619 declare ptr @memset(ptr, i32, i64)
621 !llvm.module.flags = !{!1}
622 !0 = !{ !"auto-init" }
623 !1 = !{i32 2, !"Debug Info Version", i32 3}
624 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
625 !3 = !DIFile(filename: "file", directory: "")
626 !4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2)
627 !5 = !DIBasicType(name: "byte", size: 8)
628 !6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5)
629 !7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5)