[clang] 262d6d4 - [test][CodeGen] Check noundef for return value

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 4 19:11:05 PST 2022


Author: Vitaly Buka
Date: 2022-12-04T19:10:17-08:00
New Revision: 262d6d495c692678c100fc4565a519b4ed070f28

URL: https://github.com/llvm/llvm-project/commit/262d6d495c692678c100fc4565a519b4ed070f28
DIFF: https://github.com/llvm/llvm-project/commit/262d6d495c692678c100fc4565a519b4ed070f28.diff

LOG: [test][CodeGen] Check noundef for return value

Added: 
    clang/test/CodeGen/msan-param-retval.cpp

Modified: 
    clang/test/CodeGen/msan-param-retval.c

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeGen/msan-param-retval.c b/clang/test/CodeGen/msan-param-retval.c
index fffb6cb01409..e0aae2d90fdc 100644
--- a/clang/test/CodeGen/msan-param-retval.c
+++ b/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) {
 }
@@ -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
\ No newline at end of file
+// EAGER-NOT:    @__msan_param_tls
+// CHECK: }
+
+int foo() {
+  return 1;
+}
+
+// CHECK:   define dso_local i32 @foo() #0 {
+// CHECK:        @__msan_retval_tls
+// CHECK: }
\ No newline at end of file

diff  --git a/clang/test/CodeGen/msan-param-retval.cpp b/clang/test/CodeGen/msan-param-retval.cpp
new file mode 100644
index 000000000000..6926cce1080e
--- /dev/null
+++ b/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: }
\ No newline at end of file


        


More information about the cfe-commits mailing list