mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-09 13:41:47 +00:00
NewGVN: Fix PR33194, memory corruption by putting temporary instructions in tables sometimes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304194 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
38012725da
commit
328a635eb4
@ -956,8 +956,12 @@ const Expression *NewGVN::checkSimplificationResults(Expression *E,
|
||||
if (CC && CC->getDefiningExpr()) {
|
||||
// If we simplified to something else, we need to communicate
|
||||
// that we're users of the value we simplified to.
|
||||
if (I != V)
|
||||
addAdditionalUsers(V, I);
|
||||
if (I != V) {
|
||||
// Don't add temporary instructions to the user lists.
|
||||
if (!AllTempInstructions.count(I))
|
||||
addAdditionalUsers(V, I);
|
||||
}
|
||||
|
||||
if (I)
|
||||
DEBUG(dbgs() << "Simplified " << *I << " to "
|
||||
<< " expression " << *CC->getDefiningExpr() << "\n");
|
||||
@ -2502,9 +2506,8 @@ NewGVN::makePossiblePhiOfOps(Instruction *I, bool HasBackedge,
|
||||
// Clone the instruction, create an expression from it, and see if we
|
||||
// have a leader.
|
||||
Instruction *ValueOp = I->clone();
|
||||
auto Iter = TempToMemory.end();
|
||||
if (MemAccess)
|
||||
Iter = TempToMemory.insert({ValueOp, MemAccess}).first;
|
||||
TempToMemory.insert({ValueOp, MemAccess});
|
||||
|
||||
for (auto &Op : ValueOp->operands()) {
|
||||
Op = Op->DoPHITranslation(PHIBlock, PredBB);
|
||||
@ -2523,7 +2526,7 @@ NewGVN::makePossiblePhiOfOps(Instruction *I, bool HasBackedge,
|
||||
AllTempInstructions.erase(ValueOp);
|
||||
ValueOp->deleteValue();
|
||||
if (MemAccess)
|
||||
TempToMemory.erase(Iter);
|
||||
TempToMemory.erase(ValueOp);
|
||||
if (!E)
|
||||
return nullptr;
|
||||
FoundVal = findPhiOfOpsLeader(E, PredBB);
|
||||
|
Loading…
Reference in New Issue
Block a user