Skip to content

Commit

Permalink
[test][CodeGen] Check noundef for return value
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka committed Dec 5, 2022
1 parent a3b48e0 commit 262d6d4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
21 changes: 15 additions & 6 deletions clang/test/CodeGen/msan-param-retval.c
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -o - %s | \
// RUN: FileCheck %s --check-prefix=CLEAN
// RUN: FileCheck %s --check-prefixes=CLEAN,CHECK
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -fno-sanitize-memory-param-retval -o - %s | \
// RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY
// RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY,CHECK
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -mllvm -msan-eager-checks -o - %s | \
// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -fsanitize-memory-param-retval -o - %s | \
// RUN: FileCheck %s --check-prefixes=CLEAN
// RUN: FileCheck %s --check-prefixes=CLEAN,CHECK
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o - %s | \
// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK

void bar(int x) {
}
Expand All @@ -16,4 +16,13 @@ void bar(int x) {
// NOUNDEF: define dso_local void @bar(i32 noundef %x) #0 {
// CLEAN: @__msan_param_tls
// NOUNDEF_ONLY: @__msan_param_tls
// EAGER-NOT: @__msan_param_tls
// EAGER-NOT: @__msan_param_tls
// CHECK: }

int foo() {
return 1;
}

// CHECK: define dso_local i32 @foo() #0 {
// CHECK: @__msan_retval_tls
// CHECK: }
31 changes: 31 additions & 0 deletions clang/test/CodeGen/msan-param-retval.cpp
@@ -0,0 +1,31 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -o - %s | \
// RUN: FileCheck %s --check-prefixes=CLEAN,CHECK
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -fno-sanitize-memory-param-retval -o - %s | \
// RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY,CHECK
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -mllvm -msan-eager-checks -o - %s | \
// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -fsanitize-memory-param-retval -o - %s | \
// RUN: FileCheck %s --check-prefixes=CLEAN,CHECK
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o - %s | \
// RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK

void bar(int x) {
}

// CLEAN: define dso_local void @_Z3bari(i32 %x) #0 {
// NOUNDEF: define dso_local void @_Z3bari(i32 noundef %x) #0 {
// CLEAN: @__msan_param_tls
// NOUNDEF_ONLY: @__msan_param_tls
// EAGER-NOT: @__msan_param_tls
// CHECK: }

int foo() {
return 1;
}

// CLEAN: define dso_local i32 @_Z3foov() #0 {
// NOUNDEF: define dso_local noundef i32 @_Z3foov() #0 {
// CLEAN: @__msan_retval_tls
// NOUNDEF_ONLY: @__msan_retval_tls
// EAGER-NOT: @__msan_retval_tls
// CHECK: }

0 comments on commit 262d6d4

Please sign in to comment.