diff options
author | Naveen Saini <naveen.kumar.saini@intel.com> | 2020-11-03 13:36:13 +0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2020-11-04 11:42:04 -0800 |
commit | e63d6f9abba5348e2183089d6ef5ea384d7ae8d8 (patch) | |
tree | 330f459a6fe286261e5ae10a098f5d6a58222427 /recipes-devtools/clang | |
parent | eba7c48f131d8fd5a1d840949d8ead2ecfe65edc (diff) | |
download | meta-clang-e63d6f9abba5348e2183089d6ef5ea384d7ae8d8.tar.gz |
llvm: Do not crash on weird `bitcast <1 x i8*> to i8*`
This patch is already merged in llvm-11.
Ref:
https://github.com/llvm/llvm-project/commit/381054a989ebd0b585fee46f2a01a7c5de10acf7
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
Diffstat (limited to 'recipes-devtools/clang')
-rw-r--r-- | recipes-devtools/clang/clang/0027-InstCombine-visitBitCast-do-not-crash-on-weird-bitca.patch | 51 | ||||
-rw-r--r-- | recipes-devtools/clang/common.inc | 1 |
2 files changed, 52 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0027-InstCombine-visitBitCast-do-not-crash-on-weird-bitca.patch b/recipes-devtools/clang/clang/0027-InstCombine-visitBitCast-do-not-crash-on-weird-bitca.patch new file mode 100644 index 0000000..77ca35b --- /dev/null +++ b/recipes-devtools/clang/clang/0027-InstCombine-visitBitCast-do-not-crash-on-weird-bitca.patch | |||
@@ -0,0 +1,51 @@ | |||
1 | From 381054a989ebd0b585fee46f2a01a7c5de10acf7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Roman Lebedev <lebedev.ri@gmail.com> | ||
3 | Date: Wed, 24 Jun 2020 21:12:09 +0300 | ||
4 | Subject: [PATCH] [InstCombine] visitBitCast(): do not crash on weird `bitcast | ||
5 | <1 x i8*> to i8*` | ||
6 | |||
7 | Even if we know that RHS of a bitcast is a pointer, | ||
8 | we can't assume LHS is, because it might be | ||
9 | a single-element vector of pointer. | ||
10 | |||
11 | Upstream-Status: Backport [https://github.com/llvm/llvm-project/commit/381054a989ebd0b585fee46f2a01a7c5de10acf7] | ||
12 | |||
13 | Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com> | ||
14 | |||
15 | --- | ||
16 | lib/Transforms/InstCombine/InstCombineCasts.cpp | 3 ++- | ||
17 | test/Transforms/InstCombine/bitcast.ll | 6 ++++++ | ||
18 | 2 files changed, 8 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp | ||
21 | index 3750f31e3cf..a8c87ea3558 100644 | ||
22 | --- a/lib/Transforms/InstCombine/InstCombineCasts.cpp | ||
23 | +++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp | ||
24 | @@ -2471,8 +2471,9 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) { | ||
25 | if (DestTy == Src->getType()) | ||
26 | return replaceInstUsesWith(CI, Src); | ||
27 | |||
28 | - if (PointerType *DstPTy = dyn_cast<PointerType>(DestTy)) { | ||
29 | + if (isa<PointerType>(SrcTy) && isa<PointerType>(DestTy)) { | ||
30 | PointerType *SrcPTy = cast<PointerType>(SrcTy); | ||
31 | + PointerType *DstPTy = cast<PointerType>(DestTy); | ||
32 | Type *DstElTy = DstPTy->getElementType(); | ||
33 | Type *SrcElTy = SrcPTy->getElementType(); | ||
34 | |||
35 | diff --git a/test/Transforms/InstCombine/bitcast.ll b/test/Transforms/InstCombine/bitcast.ll | ||
36 | index 0f0cbdb364a..c4ee52f27a8 100644 | ||
37 | --- a/test/Transforms/InstCombine/bitcast.ll | ||
38 | +++ b/test/Transforms/InstCombine/bitcast.ll | ||
39 | @@ -561,3 +561,9 @@ define void @constant_fold_vector_to_half() { | ||
40 | store volatile half bitcast (<4 x i4> <i4 0, i4 0, i4 0, i4 4> to half), half* undef | ||
41 | ret void | ||
42 | } | ||
43 | + | ||
44 | +; Ensure that we do not crash when looking at such a weird bitcast. | ||
45 | +define i8* @bitcast_from_single_element_pointer_vector_to_pointer(<1 x i8*> %ptrvec) { | ||
46 | + %ptr = bitcast <1 x i8*> %ptrvec to i8* | ||
47 | + ret i8* %ptr | ||
48 | +} | ||
49 | -- | ||
50 | 2.17.1 | ||
51 | |||
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index 3ecbe78..d257f4b 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc | |||
@@ -34,6 +34,7 @@ SRC_URI = "\ | |||
34 | file://0024-fix-path-to-libffi.patch \ | 34 | file://0024-fix-path-to-libffi.patch \ |
35 | file://0025-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch \ | 35 | file://0025-clang-driver-Add-dyld-prefix-when-checking-sysroot-f.patch \ |
36 | file://0026-OpenCL-Fix-support-for-cl_khr_mipmap_image_writes.patch \ | 36 | file://0026-OpenCL-Fix-support-for-cl_khr_mipmap_image_writes.patch \ |
37 | file://0027-InstCombine-visitBitCast-do-not-crash-on-weird-bitca.patch;patchdir=llvm \ | ||
37 | " | 38 | " |
38 | 39 | ||
39 | # Fallback to no-PIE if not set | 40 | # Fallback to no-PIE if not set |