[test][msan] Update for noundef on retval
authorVitaly Buka <vitalybuka@google.com>
Mon, 5 Dec 2022 06:29:15 +0000 (22:29 -0800)
committerVitaly Buka <vitalybuka@google.com>
Mon, 5 Dec 2022 06:47:56 +0000 (22:47 -0800)
clang/test/CodeGen/sanitize-memory-disable.c
compiler-rt/test/msan/stack-origin2.cpp

index da3593a..865b37c 100644 (file)
@@ -1,6 +1,7 @@
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,WITHOUT %s
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=memory -fno-sanitize-memory-param-retval | FileCheck -check-prefixes CHECK,MSAN,RETTLS %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the return value in
@@ -15,7 +16,7 @@
 // MSAN: @llvm.memset{{.*}}({{.*}}, i8 -1
 // KMSAN: __msan_poison_alloca
 // WITHOUT-NOT: __msan_retval_tls
-// MSAN: __msan_retval_tls
+// RETTLS: __msan_retval_tls
 // CHECK: ret i32
 int instrumented1(int *a) {
   volatile char buf[8];
@@ -34,7 +35,7 @@ int instrumented1(int *a) {
 // MSAN: @llvm.memset{{.*}}({{.*}}, i8 0
 // KMSAN: __msan_unpoison_alloca
 // WITHOUT-NOT: __msan_retval_tls
-// MSAN: __msan_retval_tls
+// RETTLS: __msan_retval_tls
 // CHECK: ret i32
 __attribute__((no_sanitize("memory"))) __attribute__((no_sanitize("kernel-memory"))) int no_false_positives1(int *a) {
   volatile char buf[8];
index f47a393..1c9d66a 100644 (file)
 
 #include <stdlib.h>
 
-extern "C"
-int f(int depth) {
-  if (depth) return f(depth - 1);
+int t;
 
-  int x;
-  int *volatile p = &x;
-  return *p;
+extern "C" void f(int depth) {
+  if (depth)
+    return f(depth - 1);
+
+  volatile int x;
+  t = x;
 }
 
 int main(int argc, char **argv) {
-  return f(1);
+  f(1);
+  return t;
   // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
   // CHECK: {{#0 0x.* in main .*stack-origin2.cpp:}}[[@LINE-2]]