llvm.org GIT mirror llvm / dcfa1b5
[msan] Fix __msan_maybe_ for non-standard type sizes. Fix incorrect calculation of the type size for __msan_maybe_warning_N call that resulted in an invalid (narrowing) zext instruction and "Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed." Only happens in very large functions (with more than 3500 MSan checks) operating on integer types that are not power-of-two. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274395 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 4 years ago
2 changed file(s) with 86 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
609609
610610 unsigned TypeSizeToSizeIndex(unsigned TypeSize) {
611611 if (TypeSize <= 8) return 0;
612 return Log2_32_Ceil(TypeSize / 8);
612 return Log2_32_Ceil((TypeSize + 7) / 8);
613613 }
614614
615615 /// This class does all the work for a given function. Store and Load
0 ; RUN: opt < %s -msan -msan-instrumentation-with-call-threshold=0 -S | FileCheck %s
1
2 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"
3 target triple = "x86_64-unknown-linux-gnu"
4
5 define <4 x i32> @test1(<4 x i32> %vec, i1 %idx, i32 %x) sanitize_memory {
6 %vec1 = insertelement <4 x i32> %vec, i32 %x, i1 %idx
7 ret <4 x i32> %vec1
8 }
9 ; CHECK-LABEL: @test1(
10 ; CHECK: %[[A:.*]] = zext i1 {{.*}} to i8
11 ; CHECK: call void @__msan_maybe_warning_1(i8 %[[A]], i32 0)
12 ; CHECK: ret <4 x i32>
13
14 define <4 x i32> @test2(<4 x i32> %vec, i2 %idx, i32 %x) sanitize_memory {
15 %vec1 = insertelement <4 x i32> %vec, i32 %x, i2 %idx
16 ret <4 x i32> %vec1
17 }
18 ; CHECK-LABEL: @test2(
19 ; CHECK: %[[A:.*]] = zext i2 {{.*}} to i8
20 ; CHECK: call void @__msan_maybe_warning_1(i8 %[[A]], i32 0)
21 ; CHECK: ret <4 x i32>
22
23 define <4 x i32> @test8(<4 x i32> %vec, i8 %idx, i32 %x) sanitize_memory {
24 %vec1 = insertelement <4 x i32> %vec, i32 %x, i8 %idx
25 ret <4 x i32> %vec1
26 }
27 ; CHECK-LABEL: @test8(
28 ; zext i8 -> i8 unnecessary.
29 ; CHECK: call void @__msan_maybe_warning_1(i8 %{{.*}}, i32 0)
30 ; CHECK: ret <4 x i32>
31
32 define <4 x i32> @test9(<4 x i32> %vec, i9 %idx, i32 %x) sanitize_memory {
33 %vec1 = insertelement <4 x i32> %vec, i32 %x, i9 %idx
34 ret <4 x i32> %vec1
35 }
36 ; CHECK-LABEL: @test9(
37 ; CHECK: %[[A:.*]] = zext i9 {{.*}} to i16
38 ; CHECK: call void @__msan_maybe_warning_2(i16 %[[A]], i32 0)
39 ; CHECK: ret <4 x i32>
40
41 define <4 x i32> @test16(<4 x i32> %vec, i16 %idx, i32 %x) sanitize_memory {
42 %vec1 = insertelement <4 x i32> %vec, i32 %x, i16 %idx
43 ret <4 x i32> %vec1
44 }
45 ; CHECK-LABEL: @test16(
46 ; CHECK: call void @__msan_maybe_warning_2(i16 %{{.*}}, i32 0)
47 ; CHECK: ret <4 x i32>
48
49 define <4 x i32> @test17(<4 x i32> %vec, i17 %idx, i32 %x) sanitize_memory {
50 %vec1 = insertelement <4 x i32> %vec, i32 %x, i17 %idx
51 ret <4 x i32> %vec1
52 }
53 ; CHECK-LABEL: @test17(
54 ; CHECK: %[[A:.*]] = zext i17 {{.*}} to i32
55 ; CHECK: call void @__msan_maybe_warning_4(i32 %[[A]], i32 0)
56 ; CHECK: ret <4 x i32>
57
58 define <4 x i32> @test42(<4 x i32> %vec, i42 %idx, i32 %x) sanitize_memory {
59 %vec1 = insertelement <4 x i32> %vec, i32 %x, i42 %idx
60 ret <4 x i32> %vec1
61 }
62 ; CHECK-LABEL: @test42(
63 ; CHECK: %[[A:.*]] = zext i42 {{.*}} to i64
64 ; CHECK: call void @__msan_maybe_warning_8(i64 %[[A]], i32 0)
65 ; CHECK: ret <4 x i32>
66
67 define <4 x i32> @test64(<4 x i32> %vec, i64 %idx, i32 %x) sanitize_memory {
68 %vec1 = insertelement <4 x i32> %vec, i32 %x, i64 %idx
69 ret <4 x i32> %vec1
70 }
71 ; CHECK-LABEL: @test64(
72 ; CHECK: call void @__msan_maybe_warning_8(i64 %{{.*}}, i32 0)
73 ; CHECK: ret <4 x i32>
74
75 ; Type size too large => inline check.
76 define <4 x i32> @test65(<4 x i32> %vec, i65 %idx, i32 %x) sanitize_memory {
77 %vec1 = insertelement <4 x i32> %vec, i32 %x, i65 %idx
78 ret <4 x i32> %vec1
79 }
80 ; CHECK-LABEL: @test65(
81 ; CHECK-NOT: call void @__msan_maybe_warning_
82 ; CHECK: icmp ne i65 %{{.*}}, 0
83 ; CHECK-NOT: call void @__msan_maybe_warning_
84 ; CHECK: ret <4 x i32>