[SelectOpt] Support ADD and SUB with zext operands. (#115489)
[llvm-project.git] / compiler-rt / test / msan / chained_origin_memcpy.cpp
blob8961b4cd64da6ad72ec6978db77ab80d7896388e
1 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
2 // RUN: not %run %t >%t.out 2>&1
3 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
5 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
6 // RUN: not %run %t >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
9 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
10 // RUN: not %run %t >%t.out 2>&1
11 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
13 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
14 // RUN: not %run %t >%t.out 2>&1
15 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
17 #include <stdio.h>
18 #include <string.h>
20 int xx[10000];
21 int yy[10000];
22 volatile int idx = 30;
24 __attribute__((noinline))
25 void fn_g(int a, int b) {
26 xx[idx] = a; xx[idx + 10] = b;
29 __attribute__((noinline))
30 void fn_f(int a, int b) {
31 fn_g(a, b);
34 __attribute__((noinline))
35 void fn_h() {
36 memcpy(&yy, &xx, sizeof(xx));
39 int main(int argc, char *argv[]) {
40 int volatile z1;
41 int volatile z2;
42 fn_f(z1, z2);
43 fn_h();
44 return yy[idx + OFFSET];
47 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
48 // CHECK: {{#0 .* in main .*chained_origin_memcpy.cpp:}}[[@LINE-4]]
50 // CHECK: Uninitialized value was stored to memory at
51 // CHECK-FULL-STACK: {{#1 .* in fn_h.*chained_origin_memcpy.cpp:}}[[@LINE-15]]
52 // CHECK-SHORT-STACK: {{#0 .* in __msan_memcpy.*msan_interceptors.cpp:}}
54 // CHECK: Uninitialized value was stored to memory at
55 // CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cpp:}}[[@LINE-29]]
56 // CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin_memcpy.cpp:}}[[@LINE-25]]
57 // CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cpp:}}[[@LINE-31]]
59 // CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame
60 // CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame
61 // CHECK-Z1: {{#0 .* in main.*chained_origin_memcpy.cpp:}}[[@LINE-21]]
62 // CHECK-Z2: {{#0 .* in main.*chained_origin_memcpy.cpp:}}[[@LINE-21]]