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