[msan] A no-op implementation of VarArg handling.
[oota-llvm.git] / test / Instrumentation / MemorySanitizer / msan_basic.ll
1 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK-ORIGINS %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
5
6 ; Check the presence of __msan_init
7 ; CHECK: @llvm.global_ctors {{.*}} @__msan_init
8
9 ; Check the presence and the linkage type of __msan_track_origins and
10 ; other interface symbols.
11 ; CHECK: @__msan_track_origins = weak_odr constant i32 0
12 ; CHECK: @__msan_keep_going = weak_odr constant i32 0
13 ; CHECK: @__msan_retval_tls = external thread_local(initialexec) global [{{.*}}]
14 ; CHECK: @__msan_retval_origin_tls = external thread_local(initialexec) global i32
15 ; CHECK: @__msan_param_tls = external thread_local(initialexec) global [{{.*}}]
16 ; CHECK: @__msan_param_origin_tls = external thread_local(initialexec) global [{{.*}}]
17 ; CHECK: @__msan_va_arg_tls = external thread_local(initialexec) global [{{.*}}]
18 ; CHECK: @__msan_va_arg_overflow_size_tls = external thread_local(initialexec) global i64
19 ; CHECK: @__msan_origin_tls = external thread_local(initialexec) global i32
20
21
22 ; Check instrumentation of stores
23
24 define void @Store(i32* nocapture %p, i32 %x) nounwind uwtable sanitize_memory {
25 entry:
26   store i32 %x, i32* %p, align 4
27   ret void
28 }
29
30 ; CHECK: @Store
31 ; CHECK: load {{.*}} @__msan_param_tls
32 ; CHECK: store
33 ; CHECK: store
34 ; CHECK: ret void
35 ; CHECK-ORIGINS: @Store
36 ; CHECK-ORIGINS: load {{.*}} @__msan_param_tls
37 ; CHECK-ORIGINS: store
38 ; CHECK-ORIGINS: icmp
39 ; CHECK-ORIGINS: br i1
40 ; CHECK-ORIGINS: <label>
41 ; CHECK-ORIGINS: store
42 ; CHECK-ORIGINS: br label
43 ; CHECK-ORIGINS: <label>
44 ; CHECK-ORIGINS: store
45 ; CHECK-ORIGINS: ret void
46
47
48 ; Check instrumentation of aligned stores
49 ; Shadow store has the same alignment as the original store; origin store
50 ; does not specify explicit alignment.
51
52 define void @AlignedStore(i32* nocapture %p, i32 %x) nounwind uwtable sanitize_memory {
53 entry:
54   store i32 %x, i32* %p, align 32
55   ret void
56 }
57
58 ; CHECK: @AlignedStore
59 ; CHECK: load {{.*}} @__msan_param_tls
60 ; CHECK: store {{.*}} align 32
61 ; CHECK: store {{.*}} align 32
62 ; CHECK: ret void
63 ; CHECK-ORIGINS: @AlignedStore
64 ; CHECK-ORIGINS: load {{.*}} @__msan_param_tls
65 ; CHECK-ORIGINS: store {{.*}} align 32
66 ; CHECK-ORIGINS: icmp
67 ; CHECK-ORIGINS: br i1
68 ; CHECK-ORIGINS: <label>
69 ; CHECK-ORIGINS: store {{.*}} align 32
70 ; CHECK-ORIGINS: br label
71 ; CHECK-ORIGINS: <label>
72 ; CHECK-ORIGINS: store {{.*}} align 32
73 ; CHECK-ORIGINS: ret void
74
75
76 ; load followed by cmp: check that we load the shadow and call __msan_warning.
77 define void @LoadAndCmp(i32* nocapture %a) nounwind uwtable sanitize_memory {
78 entry:
79   %0 = load i32* %a, align 4
80   %tobool = icmp eq i32 %0, 0
81   br i1 %tobool, label %if.end, label %if.then
82
83 if.then:                                          ; preds = %entry
84   tail call void (...)* @foo() nounwind
85   br label %if.end
86
87 if.end:                                           ; preds = %entry, %if.then
88   ret void
89 }
90
91 declare void @foo(...)
92
93 ; CHECK: @LoadAndCmp
94 ; CHECK: = load
95 ; CHECK: = load
96 ; CHECK: call void @__msan_warning_noreturn()
97 ; CHECK-NEXT: call void asm sideeffect
98 ; CHECK-NEXT: unreachable
99 ; CHECK: ret void
100
101 ; Check that we store the shadow for the retval.
102 define i32 @ReturnInt() nounwind uwtable readnone sanitize_memory {
103 entry:
104   ret i32 123
105 }
106
107 ; CHECK: @ReturnInt
108 ; CHECK: store i32 0,{{.*}}__msan_retval_tls
109 ; CHECK: ret i32
110
111 ; Check that we get the shadow for the retval.
112 define void @CopyRetVal(i32* nocapture %a) nounwind uwtable sanitize_memory {
113 entry:
114   %call = tail call i32 @ReturnInt() nounwind
115   store i32 %call, i32* %a, align 4
116   ret void
117 }
118
119 ; CHECK: @CopyRetVal
120 ; CHECK: load{{.*}}__msan_retval_tls
121 ; CHECK: store
122 ; CHECK: store
123 ; CHECK: ret void
124
125
126 ; Check that we generate PHIs for shadow.
127 define void @FuncWithPhi(i32* nocapture %a, i32* %b, i32* nocapture %c) nounwind uwtable sanitize_memory {
128 entry:
129   %tobool = icmp eq i32* %b, null
130   br i1 %tobool, label %if.else, label %if.then
131
132   if.then:                                          ; preds = %entry
133   %0 = load i32* %b, align 4
134   br label %if.end
135
136   if.else:                                          ; preds = %entry
137   %1 = load i32* %c, align 4
138   br label %if.end
139
140   if.end:                                           ; preds = %if.else, %if.then
141   %t.0 = phi i32 [ %0, %if.then ], [ %1, %if.else ]
142   store i32 %t.0, i32* %a, align 4
143   ret void
144 }
145
146 ; CHECK: @FuncWithPhi
147 ; CHECK: = phi
148 ; CHECK-NEXT: = phi
149 ; CHECK: store
150 ; CHECK: store
151 ; CHECK: ret void
152
153 ; Compute shadow for "x << 10"
154 define void @ShlConst(i32* nocapture %x) nounwind uwtable sanitize_memory {
155 entry:
156   %0 = load i32* %x, align 4
157   %1 = shl i32 %0, 10
158   store i32 %1, i32* %x, align 4
159   ret void
160 }
161
162 ; CHECK: @ShlConst
163 ; CHECK: = load
164 ; CHECK: = load
165 ; CHECK: shl
166 ; CHECK: shl
167 ; CHECK: store
168 ; CHECK: store
169 ; CHECK: ret void
170
171 ; Compute shadow for "10 << x": it should have 'sext i1'.
172 define void @ShlNonConst(i32* nocapture %x) nounwind uwtable sanitize_memory {
173 entry:
174   %0 = load i32* %x, align 4
175   %1 = shl i32 10, %0
176   store i32 %1, i32* %x, align 4
177   ret void
178 }
179
180 ; CHECK: @ShlNonConst
181 ; CHECK: = load
182 ; CHECK: = load
183 ; CHECK: = sext i1
184 ; CHECK: store
185 ; CHECK: store
186 ; CHECK: ret void
187
188 ; SExt
189 define void @SExt(i32* nocapture %a, i16* nocapture %b) nounwind uwtable sanitize_memory {
190 entry:
191   %0 = load i16* %b, align 2
192   %1 = sext i16 %0 to i32
193   store i32 %1, i32* %a, align 4
194   ret void
195 }
196
197 ; CHECK: @SExt
198 ; CHECK: = load
199 ; CHECK: = load
200 ; CHECK: = sext
201 ; CHECK: = sext
202 ; CHECK: store
203 ; CHECK: store
204 ; CHECK: ret void
205
206
207 ; memset
208 define void @MemSet(i8* nocapture %x) nounwind uwtable sanitize_memory {
209 entry:
210   call void @llvm.memset.p0i8.i64(i8* %x, i8 42, i64 10, i32 1, i1 false)
211   ret void
212 }
213
214 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind
215
216 ; CHECK: @MemSet
217 ; CHECK: call i8* @__msan_memset
218 ; CHECK: ret void
219
220
221 ; memcpy
222 define void @MemCpy(i8* nocapture %x, i8* nocapture %y) nounwind uwtable sanitize_memory {
223 entry:
224   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %x, i8* %y, i64 10, i32 1, i1 false)
225   ret void
226 }
227
228 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
229
230 ; CHECK: @MemCpy
231 ; CHECK: call i8* @__msan_memcpy
232 ; CHECK: ret void
233
234
235 ; memmove is lowered to a call
236 define void @MemMove(i8* nocapture %x, i8* nocapture %y) nounwind uwtable sanitize_memory {
237 entry:
238   call void @llvm.memmove.p0i8.p0i8.i64(i8* %x, i8* %y, i64 10, i32 1, i1 false)
239   ret void
240 }
241
242 declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
243
244 ; CHECK: @MemMove
245 ; CHECK: call i8* @__msan_memmove
246 ; CHECK: ret void
247
248
249 ; Check that we propagate shadow for "select"
250
251 define i32 @Select(i32 %a, i32 %b, i32 %c) nounwind uwtable readnone sanitize_memory {
252 entry:
253   %tobool = icmp ne i32 %c, 0
254   %cond = select i1 %tobool, i32 %a, i32 %b
255   ret i32 %cond
256 }
257
258 ; CHECK: @Select
259 ; CHECK: select
260 ; CHECK-NEXT: select
261 ; CHECK: ret i32
262
263
264 ; Check that we propagate origin for "select" with vector condition.
265 ; Select condition is flattened to i1, which is then used to select one of the
266 ; argument origins.
267
268 define <8 x i16> @SelectVector(<8 x i16> %a, <8 x i16> %b, <8 x i1> %c) nounwind uwtable readnone sanitize_memory {
269 entry:
270   %cond = select <8 x i1> %c, <8 x i16> %a, <8 x i16> %b
271   ret <8 x i16> %cond
272 }
273
274 ; CHECK-ORIGINS: @SelectVector
275 ; CHECK-ORIGINS: bitcast <8 x i1> {{.*}} to i8
276 ; CHECK-ORIGINS: icmp ne i8
277 ; CHECK-ORIGINS: select i1
278 ; CHECK-ORIGINS: ret <8 x i16>
279
280
281 define i8* @IntToPtr(i64 %x) nounwind uwtable readnone sanitize_memory {
282 entry:
283   %0 = inttoptr i64 %x to i8*
284   ret i8* %0
285 }
286
287 ; CHECK: @IntToPtr
288 ; CHECK: load i64*{{.*}}__msan_param_tls
289 ; CHECK-NEXT: inttoptr
290 ; CHECK-NEXT: store i64{{.*}}__msan_retval_tls
291 ; CHECK: ret i8
292
293
294 define i8* @IntToPtr_ZExt(i16 %x) nounwind uwtable readnone sanitize_memory {
295 entry:
296   %0 = inttoptr i16 %x to i8*
297   ret i8* %0
298 }
299
300 ; CHECK: @IntToPtr_ZExt
301 ; CHECK: zext
302 ; CHECK-NEXT: inttoptr
303 ; CHECK: ret i8
304
305
306 ; Check that we insert exactly one check on udiv
307 ; (2nd arg shadow is checked, 1st arg shadow is propagated)
308
309 define i32 @Div(i32 %a, i32 %b) nounwind uwtable readnone sanitize_memory {
310 entry:
311   %div = udiv i32 %a, %b
312   ret i32 %div
313 }
314
315 ; CHECK: @Div
316 ; CHECK: icmp
317 ; CHECK: call void @__msan_warning
318 ; CHECK-NOT: icmp
319 ; CHECK: udiv
320 ; CHECK-NOT: icmp
321 ; CHECK: ret i32
322
323
324 ; Check that we propagate shadow for x<0, x>=0, etc (i.e. sign bit tests)
325
326 define zeroext i1 @ICmpSLT(i32 %x) nounwind uwtable readnone sanitize_memory {
327   %1 = icmp slt i32 %x, 0
328   ret i1 %1
329 }
330
331 ; CHECK: @ICmpSLT
332 ; CHECK: icmp slt
333 ; CHECK-NOT: call void @__msan_warning
334 ; CHECK: icmp slt
335 ; CHECK-NOT: call void @__msan_warning
336 ; CHECK: ret i1
337
338 define zeroext i1 @ICmpSGE(i32 %x) nounwind uwtable readnone sanitize_memory {
339   %1 = icmp sge i32 %x, 0
340   ret i1 %1
341 }
342
343 ; CHECK: @ICmpSGE
344 ; CHECK: icmp slt
345 ; CHECK-NOT: call void @__msan_warning
346 ; CHECK: icmp sge
347 ; CHECK-NOT: call void @__msan_warning
348 ; CHECK: ret i1
349
350 define zeroext i1 @ICmpSGT(i32 %x) nounwind uwtable readnone sanitize_memory {
351   %1 = icmp sgt i32 0, %x
352   ret i1 %1
353 }
354
355 ; CHECK: @ICmpSGT
356 ; CHECK: icmp slt
357 ; CHECK-NOT: call void @__msan_warning
358 ; CHECK: icmp sgt
359 ; CHECK-NOT: call void @__msan_warning
360 ; CHECK: ret i1
361
362 define zeroext i1 @ICmpSLE(i32 %x) nounwind uwtable readnone sanitize_memory {
363   %1 = icmp sle i32 0, %x
364   ret i1 %1
365 }
366
367 ; CHECK: @ICmpSLE
368 ; CHECK: icmp slt
369 ; CHECK-NOT: call void @__msan_warning
370 ; CHECK: icmp sle
371 ; CHECK-NOT: call void @__msan_warning
372 ; CHECK: ret i1
373
374
375 ; Check that we propagate shadow for x<0, x>=0, etc (i.e. sign bit tests)
376 ; of the vector arguments.
377
378 define <2 x i1> @ICmpSLT_vector(<2 x i32*> %x) nounwind uwtable readnone sanitize_memory {
379   %1 = icmp slt <2 x i32*> %x, zeroinitializer
380   ret <2 x i1> %1
381 }
382
383 ; CHECK: @ICmpSLT_vector
384 ; CHECK: icmp slt <2 x i64>
385 ; CHECK-NOT: call void @__msan_warning
386 ; CHECK: icmp slt <2 x i32*>
387 ; CHECK-NOT: call void @__msan_warning
388 ; CHECK: ret <2 x i1>
389
390
391 ; Check that we propagate shadow for unsigned relational comparisons with
392 ; constants
393
394 define zeroext i1 @ICmpUGTConst(i32 %x) nounwind uwtable readnone sanitize_memory {
395 entry:
396   %cmp = icmp ugt i32 %x, 7
397   ret i1 %cmp
398 }
399
400 ; CHECK: @ICmpUGTConst
401 ; CHECK: icmp ugt i32
402 ; CHECK-NOT: call void @__msan_warning
403 ; CHECK: icmp ugt i32
404 ; CHECK-NOT: call void @__msan_warning
405 ; CHECK: icmp ugt i32
406 ; CHECK-NOT: call void @__msan_warning
407 ; CHECK: ret i1
408
409
410 ; Check that loads of shadow have the same aligment as the original loads.
411 ; Check that loads of origin have the aligment of max(4, original alignment).
412
413 define i32 @ShadowLoadAlignmentLarge() nounwind uwtable sanitize_memory {
414   %y = alloca i32, align 64
415   %1 = load volatile i32* %y, align 64
416   ret i32 %1
417 }
418
419 ; CHECK: @ShadowLoadAlignmentLarge
420 ; CHECK: load i32* {{.*}} align 64
421 ; CHECK: load volatile i32* {{.*}} align 64
422 ; CHECK: ret i32
423
424 define i32 @ShadowLoadAlignmentSmall() nounwind uwtable sanitize_memory {
425   %y = alloca i32, align 2
426   %1 = load volatile i32* %y, align 2
427   ret i32 %1
428 }
429
430 ; CHECK: @ShadowLoadAlignmentSmall
431 ; CHECK: load i32* {{.*}} align 2
432 ; CHECK: load volatile i32* {{.*}} align 2
433 ; CHECK: ret i32
434
435 ; CHECK-ORIGINS: @ShadowLoadAlignmentSmall
436 ; CHECK-ORIGINS: load i32* {{.*}} align 2
437 ; CHECK-ORIGINS: load i32* {{.*}} align 4
438 ; CHECK-ORIGINS: load volatile i32* {{.*}} align 2
439 ; CHECK-ORIGINS: ret i32
440
441
442 ; Test vector manipulation instructions.
443 ; Check that the same bit manipulation is applied to the shadow values.
444 ; Check that there is a zero test of the shadow of %idx argument, where present.
445
446 define i32 @ExtractElement(<4 x i32> %vec, i32 %idx) sanitize_memory {
447   %x = extractelement <4 x i32> %vec, i32 %idx
448   ret i32 %x
449 }
450
451 ; CHECK: @ExtractElement
452 ; CHECK: extractelement
453 ; CHECK: call void @__msan_warning
454 ; CHECK: extractelement
455 ; CHECK: ret i32
456
457 define <4 x i32> @InsertElement(<4 x i32> %vec, i32 %idx, i32 %x) sanitize_memory {
458   %vec1 = insertelement <4 x i32> %vec, i32 %x, i32 %idx
459   ret <4 x i32> %vec1
460 }
461
462 ; CHECK: @InsertElement
463 ; CHECK: insertelement
464 ; CHECK: call void @__msan_warning
465 ; CHECK: insertelement
466 ; CHECK: ret <4 x i32>
467
468 define <4 x i32> @ShuffleVector(<4 x i32> %vec, <4 x i32> %vec1) sanitize_memory {
469   %vec2 = shufflevector <4 x i32> %vec, <4 x i32> %vec1,
470                         <4 x i32> <i32 0, i32 4, i32 1, i32 5>
471   ret <4 x i32> %vec2
472 }
473
474 ; CHECK: @ShuffleVector
475 ; CHECK: shufflevector
476 ; CHECK-NOT: call void @__msan_warning
477 ; CHECK: shufflevector
478 ; CHECK: ret <4 x i32>
479
480
481 ; Test bswap intrinsic instrumentation
482 define i32 @BSwap(i32 %x) nounwind uwtable readnone sanitize_memory {
483   %y = tail call i32 @llvm.bswap.i32(i32 %x)
484   ret i32 %y
485 }
486
487 declare i32 @llvm.bswap.i32(i32) nounwind readnone
488
489 ; CHECK: @BSwap
490 ; CHECK-NOT: call void @__msan_warning
491 ; CHECK: @llvm.bswap.i32
492 ; CHECK-NOT: call void @__msan_warning
493 ; CHECK: @llvm.bswap.i32
494 ; CHECK-NOT: call void @__msan_warning
495 ; CHECK: ret i32
496
497
498 ; Store intrinsic.
499
500 define void @StoreIntrinsic(i8* %p, <4 x float> %x) nounwind uwtable sanitize_memory {
501   call void @llvm.x86.sse.storeu.ps(i8* %p, <4 x float> %x)
502   ret void
503 }
504
505 declare void @llvm.x86.sse.storeu.ps(i8*, <4 x float>) nounwind
506
507 ; CHECK: @StoreIntrinsic
508 ; CHECK-NOT: br
509 ; CHECK-NOT: = or
510 ; CHECK: store <4 x i32> {{.*}} align 1
511 ; CHECK: call void @llvm.x86.sse.storeu.ps
512 ; CHECK: ret void
513
514
515 ; Load intrinsic.
516
517 define <16 x i8> @LoadIntrinsic(i8* %p) nounwind uwtable sanitize_memory {
518   %call = call <16 x i8> @llvm.x86.sse3.ldu.dq(i8* %p)
519   ret <16 x i8> %call
520 }
521
522 declare <16 x i8> @llvm.x86.sse3.ldu.dq(i8* %p) nounwind
523
524 ; CHECK: @LoadIntrinsic
525 ; CHECK: load <16 x i8>* {{.*}} align 1
526 ; CHECK-NOT: br
527 ; CHECK-NOT: = or
528 ; CHECK: call <16 x i8> @llvm.x86.sse3.ldu.dq
529 ; CHECK: store <16 x i8> {{.*}} @__msan_retval_tls
530 ; CHECK: ret <16 x i8>
531
532 ; CHECK-ORIGINS: @LoadIntrinsic
533 ; CHECK-ORIGINS: [[ORIGIN:%[01-9a-z]+]] = load i32* {{.*}}
534 ; CHECK-ORIGINS: call <16 x i8> @llvm.x86.sse3.ldu.dq
535 ; CHECK-ORIGINS: store i32 {{.*}}[[ORIGIN]], i32* @__msan_retval_origin_tls
536 ; CHECK-ORIGINS: ret <16 x i8>
537
538
539 ; Simple NoMem intrinsic
540 ; Check that shadow is OR'ed, and origin is Select'ed
541 ; And no shadow checks!
542
543 define <8 x i16> @Paddsw128(<8 x i16> %a, <8 x i16> %b) nounwind uwtable sanitize_memory {
544   %call = call <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16> %a, <8 x i16> %b)
545   ret <8 x i16> %call
546 }
547
548 declare <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16> %a, <8 x i16> %b) nounwind
549
550 ; CHECK: @Paddsw128
551 ; CHECK-NEXT: load <8 x i16>* {{.*}} @__msan_param_tls
552 ; CHECK-NEXT: load <8 x i16>* {{.*}} @__msan_param_tls
553 ; CHECK-NEXT: = or <8 x i16>
554 ; CHECK-NEXT: call <8 x i16> @llvm.x86.sse2.padds.w
555 ; CHECK-NEXT: store <8 x i16> {{.*}} @__msan_retval_tls
556 ; CHECK-NEXT: ret <8 x i16>
557
558 ; CHECK-ORIGINS: @Paddsw128
559 ; CHECK-ORIGINS: load i32* {{.*}} @__msan_param_origin_tls
560 ; CHECK-ORIGINS: load i32* {{.*}} @__msan_param_origin_tls
561 ; CHECK-ORIGINS: = bitcast <8 x i16> {{.*}} to i128
562 ; CHECK-ORIGINS-NEXT: = icmp ne i128 {{.*}}, 0
563 ; CHECK-ORIGINS-NEXT: = select i1 {{.*}}, i32 {{.*}}, i32
564 ; CHECK-ORIGINS: call <8 x i16> @llvm.x86.sse2.padds.w
565 ; CHECK-ORIGINS: store i32 {{.*}} @__msan_retval_origin_tls
566 ; CHECK-ORIGINS: ret <8 x i16>
567
568
569 ; Test handling of vectors of pointers.
570 ; Check that shadow of such vector is a vector of integers.
571
572 define <8 x i8*> @VectorOfPointers(<8 x i8*>* %p) nounwind uwtable sanitize_memory {
573   %x = load <8 x i8*>* %p
574   ret <8 x i8*> %x
575 }
576
577 ; CHECK: @VectorOfPointers
578 ; CHECK: load <8 x i64>*
579 ; CHECK: load <8 x i8*>*
580 ; CHECK: store <8 x i64> {{.*}} @__msan_retval_tls
581 ; CHECK: ret <8 x i8*>
582
583 ; Test handling of va_copy.
584
585 declare void @llvm.va_copy(i8*, i8*) nounwind
586
587 define void @VACopy(i8* %p1, i8* %p2) nounwind uwtable sanitize_memory {
588   call void @llvm.va_copy(i8* %p1, i8* %p2) nounwind
589   ret void
590 }
591
592 ; CHECK: @VACopy
593 ; CHECK: call void @llvm.memset.p0i8.i64({{.*}}, i8 0, i64 24, i32 8, i1 false)
594 ; CHECK: ret void
595
596
597 ; Test handling of volatile stores.
598 ; Check that MemorySanitizer does not add a check of the value being stored.
599
600 define void @VolatileStore(i32* nocapture %p, i32 %x) nounwind uwtable sanitize_memory {
601 entry:
602   store volatile i32 %x, i32* %p, align 4
603   ret void
604 }
605
606 ; CHECK: @VolatileStore
607 ; CHECK-NOT: @__msan_warning
608 ; CHECK: ret void
609
610
611 ; Test that checks are omitted but shadow propagation is kept if
612 ; sanitize_memory attribute is missing.
613
614 define i32 @NoSanitizeMemory(i32 %x) uwtable {
615 entry:
616   %tobool = icmp eq i32 %x, 0
617   br i1 %tobool, label %if.end, label %if.then
618
619 if.then:                                          ; preds = %entry
620   tail call void @bar()
621   br label %if.end
622
623 if.end:                                           ; preds = %entry, %if.then
624   ret i32 %x
625 }
626
627 declare void @bar()
628
629 ; CHECK: @NoSanitizeMemory
630 ; CHECK-NOT: @__msan_warning
631 ; CHECK: load i32* {{.*}} @__msan_param_tls
632 ; CHECK-NOT: @__msan_warning
633 ; CHECK: store {{.*}} @__msan_retval_tls
634 ; CHECK-NOT: @__msan_warning
635 ; CHECK: ret i32