mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
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
This commit is contained in:
parent
4777a517f2
commit
3b8a617319
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user