From e92fe7af3f9d7a660e026912852c8ce401331c03 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Sun, 4 Dec 2022 22:29:15 -0800 Subject: [PATCH] [test][msan] Update for noundef on retval --- clang/test/CodeGen/sanitize-memory-disable.c | 5 +++-- compiler-rt/test/msan/stack-origin2.cpp | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/clang/test/CodeGen/sanitize-memory-disable.c b/clang/test/CodeGen/sanitize-memory-disable.c index da3593a..865b37c 100644 --- a/clang/test/CodeGen/sanitize-memory-disable.c +++ b/clang/test/CodeGen/sanitize-memory-disable.c @@ -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]; diff --git a/compiler-rt/test/msan/stack-origin2.cpp b/compiler-rt/test/msan/stack-origin2.cpp index f47a393..1c9d66a 100644 --- a/compiler-rt/test/msan/stack-origin2.cpp +++ b/compiler-rt/test/msan/stack-origin2.cpp @@ -20,17 +20,19 @@ #include -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]] -- 2.7.4