[PATCH] D46722: [InstCombine] fix crash due to ignored addrspacecast
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 14 15:08:48 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332302: [InstCombine] fix crash due to ignored addrspacecast (authored by kfischer, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D46722
Files:
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/gep-addrspace.ll
Index: llvm/trunk/test/Transforms/InstCombine/gep-addrspace.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/gep-addrspace.ll
+++ llvm/trunk/test/Transforms/InstCombine/gep-addrspace.ll
@@ -32,3 +32,22 @@
ret void
}
+declare void @escape_alloca(i16*)
+
+; check that addrspacecast is not ignored (leading to an assertion failure)
+; when trying to mark a GEP as inbounds
+define { i8, i8 } @inbounds_after_addrspacecast() {
+top:
+; CHECK-LABEL: @inbounds_after_addrspacecast
+ %0 = alloca i16, align 2
+ call void @escape_alloca(i16* %0)
+ %tmpcast = bitcast i16* %0 to [2 x i8]*
+; CHECK: addrspacecast [2 x i8]* %tmpcast to [2 x i8] addrspace(11)*
+ %1 = addrspacecast [2 x i8]* %tmpcast to [2 x i8] addrspace(11)*
+; CHECK: getelementptr [2 x i8], [2 x i8] addrspace(11)* %1, i64 0, i64 1
+ %2 = getelementptr [2 x i8], [2 x i8] addrspace(11)* %1, i64 0, i64 1
+; CHECK: addrspace(11)
+ %3 = load i8, i8 addrspace(11)* %2, align 1
+ %.fca.1.insert = insertvalue { i8, i8 } zeroinitializer, i8 %3, 1
+ ret { i8, i8 } %.fca.1.insert
+}
Index: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1937,16 +1937,17 @@
// addrspacecast between types is canonicalized as a bitcast, then an
// addrspacecast. To take advantage of the below bitcast + struct GEP, look
// through the addrspacecast.
+ Value *ASCStrippedPtrOp = PtrOp;
if (auto *ASC = dyn_cast<AddrSpaceCastInst>(PtrOp)) {
// X = bitcast A addrspace(1)* to B addrspace(1)*
// Y = addrspacecast A addrspace(1)* to B addrspace(2)*
// Z = gep Y, <...constant indices...>
// Into an addrspacecasted GEP of the struct.
if (auto *BC = dyn_cast<BitCastInst>(ASC->getOperand(0)))
- PtrOp = BC;
+ ASCStrippedPtrOp = BC;
}
- if (auto *BCI = dyn_cast<BitCastInst>(PtrOp)) {
+ if (auto *BCI = dyn_cast<BitCastInst>(ASCStrippedPtrOp)) {
Value *SrcOp = BCI->getOperand(0);
PointerType *SrcType = cast<PointerType>(BCI->getSrcTy());
Type *SrcEltType = SrcType->getElementType();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46722.146700.patch
Type: text/x-patch
Size: 2295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180514/b95250ca/attachment.bin>
More information about the llvm-commits
mailing list