xref: /llvm-project/llvm/test/Instrumentation/MemorySanitizer/msan-disable-checks.ll (revision e7bac3b9fa739f8d167a390a547068aad1d424a7)
1; Test for -msan-disable-checks, which should treat every function in the file
2; as if it didn't have the sanitize_memory attribute.
3; RUN: opt < %s -msan-check-access-address=0 -S -passes='module(msan)' 2>&1 | FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,INSTR %s
4; RUN: opt < %s -msan-check-access-address=0 -S -passes='module(msan)' -msan-disable-checks=1 2>&1 | FileCheck -allow-deprecated-dag-overlap -check-prefixes=CHECK,NOSANITIZE %s
5
6target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7target triple = "x86_64-unknown-linux-gnu"
8
9declare void @bar()
10
11define i32 @SanitizeFn(i32 %x) uwtable sanitize_memory {
12entry:
13  %tobool = icmp eq i32 %x, 0
14  br i1 %tobool, label %if.end, label %if.then
15
16if.then:                                          ; preds = %entry
17  tail call void @bar()
18  br label %if.end
19
20if.end:                                           ; preds = %entry, %if.then
21  ret i32 %x
22}
23
24; CHECK-LABEL: @SanitizeFn
25; INSTR: @__msan_warning
26; NOSANITIZE-NOT: @__msan_warning
27; NOSANITIZE: store i32 0, {{.*}} @__msan_retval_tls
28; CHECK: ret i32
29
30
31define i32 @NoSanitizeFn(i32 %x) uwtable {
32entry:
33  %tobool = icmp eq i32 %x, 0
34  br i1 %tobool, label %if.end, label %if.then
35
36if.then:                                          ; preds = %entry
37  tail call void @bar()
38  br label %if.end
39
40if.end:                                           ; preds = %entry, %if.then
41  ret i32 %x
42}
43
44
45; CHECK-LABEL: @NoSanitizeFn
46; CHECK-NOT: @__msan_warning
47; CHECK: store i32 0, {{.*}} @__msan_retval_tls
48; CHECK: ret i32
49
50