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