1; Test -msan-instrumentation-with-call-threshold
2; Test that in with-calls mode there are no calls to __msan_chain_origin - they
3; are done from __msan_maybe_store_origin_*.
4
5; RUN: opt < %s -msan-check-access-address=0                                   \
6; RUN: -msan-instrumentation-with-call-threshold=0 -S -passes=msan 2>&1 |      \
7; RUN: FileCheck %s
8; RUN: opt < %s -msan -msan-check-access-address=0 -msan-instrumentation-with-call-threshold=0 -S | FileCheck %s
9; RUN: opt < %s -msan-check-access-address=0                                   \
10; RUN: -msan-instrumentation-with-call-threshold=0 -msan-track-origins=1 -S    \
11; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK                       \
12; RUN: -check-prefix=CHECK-ORIGINS %s
13; RUN: opt < %s -msan -msan-check-access-address=0 -msan-instrumentation-with-call-threshold=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
14; RUN: opt < %s -msan-check-access-address=0                                   \
15; RUN: -msan-instrumentation-with-call-threshold=0 -msan-track-origins=2 -S    \
16; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK                       \
17; RUN: -check-prefix=CHECK-ORIGINS %s
18; RUN: opt < %s -msan -msan-check-access-address=0 -msan-instrumentation-with-call-threshold=0 -msan-track-origins=2 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
19
20target 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"
21target triple = "x86_64-unknown-linux-gnu"
22
23define void @LoadAndCmp(i32* nocapture %a) nounwind uwtable sanitize_memory {
24entry:
25  %0 = load i32, i32* %a, align 4
26  %tobool = icmp eq i32 %0, 0
27  br i1 %tobool, label %if.end, label %if.then
28
29if.then:                                          ; preds = %entry
30  tail call void (...) @foo() nounwind
31  br label %if.end
32
33if.end:                                           ; preds = %entry, %if.then
34  ret void
35}
36
37declare void @foo(...)
38
39; CHECK-LABEL: @LoadAndCmp
40; CHECK: = load
41; CHECK: = load
42; CHECK: = zext i1 {{.*}} to i8
43; CHECK: call void @__msan_maybe_warning_1(
44; CHECK-NOT: unreachable
45; CHECK: ret void
46
47
48define void @Store(i64* nocapture %p, i64 %x) nounwind uwtable sanitize_memory {
49entry:
50  store i64 %x, i64* %p, align 4
51  ret void
52}
53
54; CHECK-LABEL: @Store
55; CHECK: load {{.*}} @__msan_param_tls
56; CHECK-ORIGINS: load {{.*}} @__msan_param_origin_tls
57; CHECK: store
58; CHECK-ORIGINS-NOT: __msan_chain_origin
59; CHECK-ORIGINS: bitcast i64* {{.*}} to i8*
60; CHECK-ORIGINS-NOT: __msan_chain_origin
61; CHECK-ORIGINS: call void @__msan_maybe_store_origin_8(
62; CHECK-ORIGINS-NOT: __msan_chain_origin
63; CHECK: store i64
64; CHECK: ret void
65