Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / chained_origin.cpp
blobb98bc3dd00482307be9c30a816783171c780c926
1 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
2 // RUN: not %run %t >%t.out 2>&1
3 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%short-stack --check-prefix=CHECK-STACK < %t.out
5 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DHEAP=1 -O3 %s -o %t && \
6 // RUN: not %run %t >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%short-stack --check-prefix=CHECK-HEAP < %t.out
10 // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
11 // RUN: not %run %t >%t.out 2>&1
12 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%short-stack --check-prefix=CHECK-STACK < %t.out
14 // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DHEAP=1 -O3 %s -o %t && \
15 // RUN: not %run %t >%t.out 2>&1
16 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-HEAP < %t.out
18 #include <stdio.h>
20 volatile int x, y;
22 __attribute__((noinline)) void fn_g(int &a) { x = a; }
24 __attribute__((noinline)) void fn_f(int &a) { fn_g(a); }
26 __attribute__((noinline)) void fn_h() { y = x; }
28 int main(int argc, char *argv[]) {
29 #ifdef HEAP
30 int * volatile zz = new int;
31 int z = *zz;
32 #else
33 int volatile z;
34 #endif
35 fn_f((int &)z);
36 fn_h();
37 return y;
40 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
41 // CHECK: {{#0 .* in main.*chained_origin.cpp:}}[[@LINE-4]]
43 // CHECK: Uninitialized value was stored to memory at
44 // CHECK-FULL-STACK: {{#0 .* in fn_h.*chained_origin.cpp:}}[[@LINE-18]]
45 // CHECK-FULL-STACK: {{#1 .* in main.*chained_origin.cpp:}}[[@LINE-9]]
46 // CHECK-SHORT-STACK: {{#0 .* in fn_h.*chained_origin.cpp:}}[[@LINE-21]]
48 // CHECK: Uninitialized value was stored to memory at
49 // CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-27]]
50 // CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin.cpp:}}[[@LINE-26]]
51 // CHECK-FULL-STACK: {{#2 .* in main.*chained_origin.cpp:}}[[@LINE-16]]
52 // CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-37]]
54 // CHECK-STACK: Uninitialized value was created by an allocation of 'z' in the stack frame
55 // CHECK-STACK: {{#0 .* in main.*chained_origin.cpp:}}[[@LINE-22]]
57 // CHECK-HEAP: Uninitialized value was created by a heap allocation
58 // CHECK-HEAP: {{#1 .* in main.*chained_origin.cpp:}}[[@LINE-28]]