1 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck %s
3 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"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; Check instrumentation mul when one of the operands is a constant.
8 define i64 @MulConst(i64 %x) sanitize_memory {
10 %y = mul i64 %x, 42949672960000
14 ; 42949672960000 = 2**32 * 10000
15 ; 36 trailing zero bits
18 ; CHECK-LABEL: @MulConst(
19 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
20 ; CHECK: [[B:%.*]] = mul i64 [[A]], 68719476736
21 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
24 define i64 @MulZero(i64 %x) sanitize_memory {
30 ; CHECK-LABEL: @MulZero(
31 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
32 ; CHECK: [[B:%.*]] = mul i64 [[A]], 0{{$}}
33 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
36 define i64 @MulNeg(i64 %x) sanitize_memory {
42 ; CHECK-LABEL: @MulNeg(
43 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
44 ; CHECK: [[B:%.*]] = mul i64 [[A]], 16
45 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
48 define i64 @MulNeg2(i64 %x) sanitize_memory {
54 ; CHECK-LABEL: @MulNeg2(
55 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
56 ; CHECK: [[B:%.*]] = mul i64 [[A]], 16
57 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
60 define i64 @MulOdd(i64 %x) sanitize_memory {
62 %y = mul i64 %x, 12345
66 ; CHECK-LABEL: @MulOdd(
67 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
68 ; CHECK: [[B:%.*]] = mul i64 [[A]], 1
69 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
72 define i64 @MulLarge(i64 %x) sanitize_memory {
74 %y = mul i64 %x, -9223372036854775808
78 ; -9223372036854775808 = 0x7000000000000000
80 ; CHECK-LABEL: @MulLarge(
81 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
82 ; CHECK: [[B:%.*]] = mul i64 [[A]], -9223372036854775808
83 ; CHECK: store i64 [[B]], ptr @__msan_retval_tls
85 define <4 x i32> @MulVectorConst(<4 x i32> %x) sanitize_memory {
87 %y = mul <4 x i32> %x, <i32 3072, i32 0, i32 -16, i32 -48>
91 ; CHECK-LABEL: @MulVectorConst(
92 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
93 ; CHECK: [[B:%.*]] = mul <4 x i32> [[A]], <i32 1024, i32 0, i32 16, i32 16>
94 ; CHECK: store <4 x i32> [[B]], ptr @__msan_retval_tls
97 ; The constant in multiplication does not have to be a literal integer constant.
98 @X = linkonce_odr global ptr null
99 define i64 @MulNonIntegerConst(i64 %a) sanitize_memory {
100 %mul = mul i64 %a, ptrtoint (ptr @X to i64)
104 ; CHECK-LABEL: @MulNonIntegerConst(
105 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
106 ; CHECK: [[B:%.*]] = mul i64 [[A]], 1
107 ; CHECK: store i64 [[B]], {{.*}}@__msan_retval_tls
109 define <2 x i64> @MulNonIntegerVectorConst(<2 x i64> %a) sanitize_memory {
110 %mul = mul <2 x i64> %a, <i64 3072, i64 ptrtoint (ptr @X to i64)>
114 ; CHECK-LABEL: @MulNonIntegerVectorConst(
115 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
116 ; CHECK: [[B:%.*]] = mul <2 x i64> [[A]], <i64 1024, i64 1>
117 ; CHECK: store <2 x i64> [[B]], {{.*}}@__msan_retval_tls