[tests][msan] Use -fno-sanitize-memory-param-retval in tests
authorVitaly Buka <vitalybuka@google.com>
Sat, 27 Aug 2022 01:04:17 +0000 (18:04 -0700)
committerVitaly Buka <vitalybuka@google.com>
Tue, 27 Sep 2022 00:24:22 +0000 (17:24 -0700)
Supports either default of -f[no-]sanitize-memory-param-retval.

Reviewed By: aeubanks, MaskRay

Differential Revision: https://reviews.llvm.org/D134683

15 files changed:
compiler-rt/test/msan/Linux/swapcontext_annotation_reset.cpp
compiler-rt/test/msan/bsearch.cpp
compiler-rt/test/msan/chained_origin.cpp
compiler-rt/test/msan/chained_origin_empty_stack.cpp
compiler-rt/test/msan/chained_origin_memcpy.cpp
compiler-rt/test/msan/chained_origin_memmove.cpp
compiler-rt/test/msan/cxa_atexit.cpp
compiler-rt/test/msan/insertvalue_origin.cpp
compiler-rt/test/msan/no_sanitize_memory_prop.cpp
compiler-rt/test/msan/noundef_analysis.cpp
compiler-rt/test/msan/param_tls_limit.cpp
compiler-rt/test/msan/qsort.cpp
compiler-rt/test/msan/signal_stress_test.cpp
compiler-rt/test/msan/unpoison_param.cpp
compiler-rt/test/msan/vector_cvt.cpp

index 342ef73..6820252 100644 (file)
@@ -1,5 +1,5 @@
-// RUN: %clangxx_msan -fno-sanitize=memory -c %s -o %t-main.o
-// RUN: %clangxx_msan %t-main.o %s -o %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fno-sanitize=memory -c %s -o %t-main.o
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval %t-main.o %s -o %t
 // RUN: %run %t
 
 #include <assert.h>
index bf2526c..965184a 100644 (file)
@@ -1,12 +1,12 @@
 // __NO_INLINE__ is defined so bsearch needs interceptor.
-// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
-// RUN: %clangxx_msan -DPOISON_DATA -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -DPOISON_KEY -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 -g %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON_DATA -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON_KEY -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 // __NO_INLINE__ is undefined so bsearch should be inlined and instrumented and still work as expected.
-// RUN: %clangxx_msan -O2 -g %s -o %t && %run %t
-// RUN: %clangxx_msan -DPOISON_DATA -O2 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -DPOISON_KEY -O2 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O2 -g %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON_DATA -O2 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON_KEY -O2 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 #include <assert.h>
 #include <stdlib.h>
index 9fe73ed..b98bc3d 100644 (file)
 
 volatile int x, y;
 
-__attribute__((noinline))
-void fn_g(int a) {
-  x = a;
-}
+__attribute__((noinline)) void fn_g(int &a) { x = a; }
 
-__attribute__((noinline))
-void fn_f(int a) {
-  fn_g(a);
-}
+__attribute__((noinline)) void fn_f(int &a) { fn_g(a); }
 
-__attribute__((noinline))
-void fn_h() {
-  y = x;
-}
+__attribute__((noinline)) void fn_h() { y = x; }
 
 int main(int argc, char *argv[]) {
 #ifdef HEAP
@@ -41,7 +32,7 @@ int main(int argc, char *argv[]) {
 #else
   int volatile z;
 #endif
-  fn_f(z);
+  fn_f((int &)z);
   fn_h();
   return y;
 }
@@ -50,13 +41,13 @@ int main(int argc, char *argv[]) {
 // CHECK: {{#0 .* in main.*chained_origin.cpp:}}[[@LINE-4]]
 
 // CHECK: Uninitialized value was stored to memory at
-// CHECK-FULL-STACK: {{#0 .* in fn_h.*chained_origin.cpp:}}[[@LINE-19]]
+// CHECK-FULL-STACK: {{#0 .* in fn_h.*chained_origin.cpp:}}[[@LINE-18]]
 // CHECK-FULL-STACK: {{#1 .* in main.*chained_origin.cpp:}}[[@LINE-9]]
 // CHECK-SHORT-STACK: {{#0 .* in fn_h.*chained_origin.cpp:}}[[@LINE-21]]
 
 // CHECK: Uninitialized value was stored to memory at
-// CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-34]]
-// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin.cpp:}}[[@LINE-30]]
+// CHECK-FULL-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-27]]
+// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin.cpp:}}[[@LINE-26]]
 // CHECK-FULL-STACK: {{#2 .* in main.*chained_origin.cpp:}}[[@LINE-16]]
 // CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-37]]
 
index 23d4633..101016f 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
 // RUN:     MSAN_OPTIONS=store_context_size=1 not %run %t 2>&1 | FileCheck %s
 
 // Test that stack trace for the intermediate store is not empty.
index 4d4ae7f..8961b4c 100644 (file)
@@ -1,17 +1,16 @@
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
 // RUN:     not %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
 
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
 // RUN:     not %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
 
-
-// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
+// 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 && \
 // RUN:     not %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
 
-// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
+// 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 && \
 // RUN:     not %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
 
index 1862ec8..fcaf373 100644 (file)
@@ -1,16 +1,16 @@
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
 // RUN:     not %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
 
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
 // RUN:     not %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
 
-// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=0 -O3 %s -o %t && \
+// 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 && \
 // RUN:     not %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z1 --check-prefix=CHECK-%short-stack < %t.out
 
-// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -DOFFSET=10 -O3 %s -o %t && \
+// 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 && \
 // RUN:     not %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-Z2 --check-prefix=CHECK-%short-stack < %t.out
 
index 70384b9..1c63bb9 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clangxx_msan -O0 %s -o %t && %run %t %p
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 %s -o %t && %run %t %p
 
 // PR17377: C++ module destructors get stale argument shadow.
 
index 68e7d9a..68b9ed1 100644 (file)
@@ -13,7 +13,7 @@ struct mypair {
  int y;
 };
 
-mypair my_make_pair(int64_t x, int y)  {
+mypair my_make_pair(int64_t &x, int y) {
  mypair p;
  p.x = x;
  p.y = y;
index cf21c94..47560b6 100644 (file)
@@ -1,7 +1,7 @@
-// RUN: %clangxx_msan -O0 %s -o %t && %run %t >%t.out 2>&1
-// RUN: %clangxx_msan -O1 %s -o %t && %run %t >%t.out 2>&1
-// RUN: %clangxx_msan -O2 %s -o %t && %run %t >%t.out 2>&1
-// RUN: %clangxx_msan -O3 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O1 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O2 %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O3 %s -o %t && %run %t >%t.out 2>&1
 
 // Test that (no_sanitize_memory) functions DO NOT propagate shadow.
 
index 3de4d99..47695ab 100644 (file)
@@ -1,8 +1,6 @@
-// RUN: %clangxx_msan %s -o %t && %run %t >%t.out 2>&1
+// RUN: %clangxx_msan %s -fno-sanitize-memory-param-retval -o %t && %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=MISSED --allow-empty < %t.out
-// RUN: %clangxx_msan %s -mllvm -msan-eager-checks=1 -o %t && not %run %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan %s -disable-noundef-analysis -fsanitize-memory-param-retval -o %t && not %run %t >%t.out 2>&1
+// RUN: %clangxx_msan %s -mllvm -msan-eager-checks=1 -fno-sanitize-memory-param-retval -o %t && not %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 
 struct SimpleStruct {
index d6ff48c..0f52127 100644 (file)
@@ -1,9 +1,9 @@
 // ParamTLS has limited size. Everything that does not fit is considered fully
 // initialized.
 
-// RUN: %clangxx_msan -O0 %s -o %t && %run %t
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && %run %t
-// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O0 %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins -O0 %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O0 %s -o %t && %run %t
 //
 // AArch64 fails with:
 // void f801(S<801>): Assertion `__msan_test_shadow(&s, sizeof(s)) == -1' failed
index f052ed1..af287ed 100644 (file)
@@ -1,5 +1,5 @@
-// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
-// RUN: %clangxx_msan -DPOISON -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 -g %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -DPOISON -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 #include <assert.h>
 #include <errno.h>
index dfbc580..fd434ad 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %run %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval -std=c++11 -O0 %s -o %t && %run %t
 //
 // Test that va_arg shadow from a signal handler does not leak outside.
 
index f59d2cb..7687cd8 100644 (file)
@@ -3,7 +3,7 @@
 // compile main() without MSan.
 
 // RUN: %clangxx_msan -fno-sanitize=memory -c %s -o %t-main.o
-// RUN: %clangxx_msan %t-main.o %s -o %t
+// RUN: %clangxx_msan -fno-sanitize-memory-param-retval %t-main.o %s -o %t
 // RUN: %run %t
 
 #include <assert.h>
index aa5327e..f318f66 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <emmintrin.h>
 
-int to_int(double v) {
+int to_int(double &v) {
   __m128d t = _mm_set_sd(v);
   int x = _mm_cvtsd_si32(t);
   return x;