• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck  \
2; RUN: %s
3; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
4
5target 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"
6target triple = "x86_64-unknown-linux-gnu"
7
8; Check instrumentation mul when one of the operands is a constant.
9
10define i64 @MulConst(i64 %x) sanitize_memory {
11entry:
12  %y = mul i64 %x, 42949672960000
13  ret i64 %y
14}
15
16; 42949672960000 = 2**32 * 10000
17; 36 trailing zero bits
18; 68719476736 = 2**36
19
20; CHECK-LABEL: @MulConst(
21; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
22; CHECK: [[B:%.*]] = mul i64 [[A]], 68719476736
23; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
24
25
26define i64 @MulZero(i64 %x) sanitize_memory {
27entry:
28  %y = mul i64 %x, 0
29  ret i64 %y
30}
31
32; CHECK-LABEL: @MulZero(
33; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
34; CHECK: [[B:%.*]] = mul i64 [[A]], 0{{$}}
35; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
36
37
38define i64 @MulNeg(i64 %x) sanitize_memory {
39entry:
40  %y = mul i64 %x, -16
41  ret i64 %y
42}
43
44; CHECK-LABEL: @MulNeg(
45; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
46; CHECK: [[B:%.*]] = mul i64 [[A]], 16
47; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
48
49
50define i64 @MulNeg2(i64 %x) sanitize_memory {
51entry:
52  %y = mul i64 %x, -48
53  ret i64 %y
54}
55
56; CHECK-LABEL: @MulNeg2(
57; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
58; CHECK: [[B:%.*]] = mul i64 [[A]], 16
59; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
60
61
62define i64 @MulOdd(i64 %x) sanitize_memory {
63entry:
64  %y = mul i64 %x, 12345
65  ret i64 %y
66}
67
68; CHECK-LABEL: @MulOdd(
69; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
70; CHECK: [[B:%.*]] = mul i64 [[A]], 1
71; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
72
73
74define i64 @MulLarge(i64 %x) sanitize_memory {
75entry:
76  %y = mul i64 %x, -9223372036854775808
77  ret i64 %y
78}
79
80; -9223372036854775808 = 0x7000000000000000
81
82; CHECK-LABEL: @MulLarge(
83; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
84; CHECK: [[B:%.*]] = mul i64 [[A]], -9223372036854775808
85; CHECK: store i64 [[B]], i64* {{.*}} @__msan_retval_tls
86
87define <4 x i32> @MulVectorConst(<4 x i32> %x) sanitize_memory {
88entry:
89  %y = mul <4 x i32> %x, <i32 3072, i32 0, i32 -16, i32 -48>
90  ret <4 x i32> %y
91}
92
93; CHECK-LABEL: @MulVectorConst(
94; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
95; CHECK: [[B:%.*]] = mul <4 x i32> [[A]], <i32 1024, i32 0, i32 16, i32 16>
96; CHECK: store <4 x i32> [[B]], <4 x i32>* {{.*}} @__msan_retval_tls
97
98
99; The constant in multiplication does not have to be a literal integer constant.
100@X = linkonce_odr global i8* null
101define i64 @MulNonIntegerConst(i64 %a) sanitize_memory {
102  %mul = mul i64 %a, ptrtoint (i8** @X to i64)
103  ret i64 %mul
104}
105
106; CHECK-LABEL: @MulNonIntegerConst(
107; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
108; CHECK: [[B:%.*]] = mul i64 [[A]], 1
109; CHECK: store i64 [[B]], {{.*}}@__msan_retval_tls
110
111define <2 x i64> @MulNonIntegerVectorConst(<2 x i64> %a) sanitize_memory {
112  %mul = mul <2 x i64> %a, <i64 3072, i64 ptrtoint (i8** @X to i64)>
113  ret <2 x i64> %mul
114}
115
116; CHECK-LABEL: @MulNonIntegerVectorConst(
117; CHECK: [[A:%.*]] = load {{.*}} @__msan_param_tls
118; CHECK: [[B:%.*]] = mul <2 x i64> [[A]], <i64 1024, i64 1>
119; CHECK: store <2 x i64> [[B]], {{.*}}@__msan_retval_tls
120