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