[test][msan] Update for noundef on retval

This commit is contained in:
Vitaly Buka 2022-12-04 22:29:15 -08:00
parent a996cc217c
commit e92fe7af3f
2 changed files with 12 additions and 9 deletions

View 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];

View File

@ -20,17 +20,19 @@
#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]]