diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-04-28 22:18:19 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-04-28 22:18:19 +0000 |
commit | c20ccd2c0209fdaae7f7efe066c4b59b4ca46842 (patch) | |
tree | f8069addd5016e531b6f59a15cb618f5a5189fca /llvm | |
parent | a1e734050cf2495f551ce3b97c0790a8232ea164 (diff) | |
download | bcm5719-llvm-c20ccd2c0209fdaae7f7efe066c4b59b4ca46842.tar.gz bcm5719-llvm-c20ccd2c0209fdaae7f7efe066c4b59b4ca46842.zip |
InferAddressSpaces: Avoid looking up deleted values
While looking at pure addressing expressions, it's possible
for the value to appear later in Postorder.
I haven't been able to come up with a testcase where this
exhibits an actual issue, but if you insert a dump before
the value map lookup, a few testcases crash.
llvm-svn: 301705
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp index a9505a45eef..a2ce9b4907d 100644 --- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp +++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp @@ -815,6 +815,8 @@ bool InferAddressSpaces::rewriteWithNewAddressSpaces( NewV->setOperand(OperandNo, ValueWithNewAddrSpace.lookup(UndefUse->get())); } + SmallVector<Instruction *, 16> DeadInstructions; + // Replaces the uses of the old address expressions with the new ones. for (Value *V : Postorder) { Value *NewV = ValueWithNewAddrSpace.lookup(V); @@ -888,7 +890,7 @@ bool InferAddressSpaces::rewriteWithNewAddressSpaces( unsigned NewAS = NewV->getType()->getPointerAddressSpace(); if (ASC->getDestAddressSpace() == NewAS) { ASC->replaceAllUsesWith(NewV); - ASC->eraseFromParent(); + DeadInstructions.push_back(ASC); continue; } } @@ -906,10 +908,15 @@ bool InferAddressSpaces::rewriteWithNewAddressSpaces( } } - if (V->use_empty()) - RecursivelyDeleteTriviallyDeadInstructions(V); + if (V->use_empty()) { + if (Instruction *I = dyn_cast<Instruction>(V)) + DeadInstructions.push_back(I); + } } + for (Instruction *I : DeadInstructions) + RecursivelyDeleteTriviallyDeadInstructions(I); + return true; } |