1*d21b3d34SFangrui Song // Test that on the second entry to a function the origins are still right. 2*d21b3d34SFangrui Song 3*d21b3d34SFangrui Song // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1 4*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out 5*d21b3d34SFangrui Song // RUN: %clangxx_msan -O1 %s -o %t && not %run %t >%t.out 2>&1 6*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out 7*d21b3d34SFangrui Song // RUN: %clangxx_msan -O2 %s -o %t && not %run %t >%t.out 2>&1 8*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out 9*d21b3d34SFangrui Song // RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&1 10*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out 11*d21b3d34SFangrui Song 12*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&1 13*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out 14*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t >%t.out 2>&1 15*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out 16*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&1 17*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out 18*d21b3d34SFangrui Song // RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&1 19*d21b3d34SFangrui Song // RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out 20*d21b3d34SFangrui Song 21*d21b3d34SFangrui Song #include <stdlib.h> 22*d21b3d34SFangrui Song 23*d21b3d34SFangrui Song extern "C" f(int depth)24*d21b3d34SFangrui Songint f(int depth) { 25*d21b3d34SFangrui Song if (depth) return f(depth - 1); 26*d21b3d34SFangrui Song 27*d21b3d34SFangrui Song int x; 28*d21b3d34SFangrui Song int *volatile p = &x; 29*d21b3d34SFangrui Song return *p; 30*d21b3d34SFangrui Song } 31*d21b3d34SFangrui Song main(int argc,char ** argv)32*d21b3d34SFangrui Songint main(int argc, char **argv) { 33*d21b3d34SFangrui Song return f(1); 34*d21b3d34SFangrui Song // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value 35*d21b3d34SFangrui Song // CHECK: {{#0 0x.* in main .*stack-origin2.cpp:}}[[@LINE-2]] 36*d21b3d34SFangrui Song 37*d21b3d34SFangrui Song // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'f' 38*d21b3d34SFangrui Song // CHECK-ORIGINS: {{#0 0x.* in f .*stack-origin2.cpp:}}[[@LINE-14]] 39*d21b3d34SFangrui Song 40*d21b3d34SFangrui Song // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin2.cpp:.* main}} 41*d21b3d34SFangrui Song } 42