1 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
4 target 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"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; Check instrumentation mul when one of the operands is a constant.
9 define i64 @MulConst(i64 %x) sanitize_memory {
11 %y = mul i64 %x, 42949672960000
15 ; 42949672960000 = 2**32 * 10000
16 ; 36 trailing zero bits
19 ; CHECK-LABEL: @MulConst(
20 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
21 ; CHECK: [[B:%.*]] = mul i64 [[A]], 68719476736
22 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
25 define i64 @MulZero(i64 %x) sanitize_memory {
31 ; CHECK-LABEL: @MulZero(
32 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
33 ; CHECK: [[B:%.*]] = mul i64 [[A]], 0{{$}}
34 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
37 define i64 @MulNeg(i64 %x) sanitize_memory {
43 ; CHECK-LABEL: @MulNeg(
44 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
45 ; CHECK: [[B:%.*]] = mul i64 [[A]], 16
46 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
49 define i64 @MulNeg2(i64 %x) sanitize_memory {
55 ; CHECK-LABEL: @MulNeg2(
56 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
57 ; CHECK: [[B:%.*]] = mul i64 [[A]], 16
58 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
61 define i64 @MulOdd(i64 %x) sanitize_memory {
63 %y = mul i64 %x, 12345
67 ; CHECK-LABEL: @MulOdd(
68 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
69 ; CHECK: [[B:%.*]] = mul i64 [[A]], 1
70 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
73 define i64 @MulLarge(i64 %x) sanitize_memory {
75 %y = mul i64 %x, -9223372036854775808
79 ; -9223372036854775808 = 0x7000000000000000
81 ; CHECK-LABEL: @MulLarge(
82 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
83 ; CHECK: [[B:%.*]] = mul i64 [[A]], -9223372036854775808
84 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
86 define <4 x i32> @MulVectorConst(<4 x i32> %x) sanitize_memory {
88 %y = mul <4 x i32> %x, <i32 3072, i32 0, i32 -16, i32 -48>
92 ; CHECK-LABEL: @MulVectorConst(
93 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
94 ; CHECK: [[B:%.*]] = mul <4 x i32> [[A]], <i32 1024, i32 0, i32 16, i32 16>
95 ; CHECK: store <4 x i32> [[B]], ptr @__msan_retval_tls
98 ; The constant in multiplication does not have to be a literal integer constant.
99 @X = linkonce_odr global ptr null
100 define i64 @MulNonIntegerConst(i64 %a) sanitize_memory {
101 %mul = mul i64 %a, ptrtoint (ptr @X to i64)
105 ; CHECK-LABEL: @MulNonIntegerConst(
106 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
107 ; CHECK: [[B:%.*]] = mul i64 [[A]], 1
108 ; CHECK: store i64 [[B]], {{.*}}@__msan_retval_tls
110 define <2 x i64> @MulNonIntegerVectorConst(<2 x i64> %a) sanitize_memory {
111 %mul = mul <2 x i64> %a, <i64 3072, i64 ptrtoint (ptr @X to i64)>
115 ; CHECK-LABEL: @MulNonIntegerVectorConst(
116 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
117 ; CHECK: [[B:%.*]] = mul <2 x i64> [[A]], <i64 1024, i64 1>
118 ; CHECK: store <2 x i64> [[B]], {{.*}}@__msan_retval_tls