summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
diff options
context:
space:
mode:
authorKeno Fischer <keno@alumni.harvard.edu>2018-05-14 22:05:01 +0000
committerKeno Fischer <keno@alumni.harvard.edu>2018-05-14 22:05:01 +0000
commitde577af8c0617df6bb707ac0a7ebccbf77d7cb6e (patch)
tree192fb100ed592774de5c7cd4a5f4ed97607ae51d /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
parent165587b4247702cba4ea40e7d03a269369010136 (diff)
downloadbcm5719-llvm-de577af8c0617df6bb707ac0a7ebccbf77d7cb6e.tar.gz
bcm5719-llvm-de577af8c0617df6bb707ac0a7ebccbf77d7cb6e.zip
[InstCombine] fix crash due to ignored addrspacecast
Summary: Part of the InstCombine code for simplifying GEPs looks through addrspacecasts. However, this was done by updating a variable also used by the next transformation, for marking GEPs as inbounds. This led to replacing a GEP with a similar instruction in a different addrspace, which caused an assertion failure in RAUW. This caused julia issue https://github.com/JuliaLang/julia/issues/27055 Patch by Jeff Bezanson <jeff@juliacomputing.com> Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D46722 llvm-svn: 332302
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 2549257bc97..e0a9ec21621 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1937,16 +1937,17 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// 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();
OpenPOWER on IntegriCloud