// 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
// 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];
// 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];
#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]]