xref: /llvm-project/clang/test/CodeGen/msan-param-retval.cpp (revision 12f78e740c5419f7d1fbcf8f2106e7a40cd1d6f7)
1 // RUN: %clang_cc1 -Wno-error=return-type -triple x86_64-linux-gnu -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -o - %s | \
2 // RUN:     FileCheck %s --check-prefixes=CLEAN,CHECK
3 // RUN: %clang_cc1 -Wno-error=return-type -triple x86_64-linux-gnu -emit-llvm -fsanitize=memory -fno-sanitize-memory-param-retval -o - %s | \
4 // RUN:     FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY,CHECK
5 // RUN: %clang_cc1 -Wno-error=return-type -triple x86_64-linux-gnu -emit-llvm -fsanitize=memory -mllvm -msan-eager-checks -o - %s | \
6 // RUN:     FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK
7 // RUN: %clang_cc1 -Wno-error=return-type -triple x86_64-linux-gnu -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -fsanitize-memory-param-retval -o - %s | \
8 // RUN:     FileCheck %s --check-prefixes=CLEAN,CHECK
9 // RUN: %clang_cc1 -Wno-error=return-type -triple x86_64-linux-gnu -emit-llvm -fsanitize=memory -o - %s | \
10 // RUN:     FileCheck %s --check-prefixes=NOUNDEF,EAGER,CHECK
11 
12 void bar(int x) {
13 }
14 
15 // CLEAN:   define dso_local void @_Z3bari(i32 %x) #0 {
16 // NOUNDEF: define dso_local void @_Z3bari(i32 noundef %x) #0 {
17 // CLEAN:        @__msan_param_tls
18 // NOUNDEF_ONLY: @__msan_param_tls
19 // EAGER-NOT:    @__msan_param_tls
20 // CHECK: }
21 
22 int foo() {
23   return 1;
24 }
25 
26 // CLEAN:   define dso_local i32 @_Z3foov() #0 {
27 // NOUNDEF: define dso_local noundef i32 @_Z3foov() #0 {
28 // CLEAN:        @__msan_retval_tls
29 // NOUNDEF_ONLY: @__msan_retval_tls
30 // EAGER-NOT:    @__msan_retval_tls
31 // CHECK: }
32 
33 int noret() {
34 }
35 
36 // CLEAN: define dso_local i32 @_Z5noretv() #0 {
37 // NOUNDEF: define dso_local noundef i32 @_Z5noretv() #0 {
38 // CHECK:  unreachable
39 // CHECK: }