summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-05-30 06:42:29 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-05-30 06:42:29 +0000
commitc8ed40400ce5aa9942582c9f57866b8066c55fae (patch)
tree9fc2e3df919bdcc9d6c9b5653f24122f8dd9186f /llvm/lib/Transforms
parentf59d921622ac47bda1d46b071f21467dabd84ea2 (diff)
downloadbcm5719-llvm-c8ed40400ce5aa9942582c9f57866b8066c55fae.tar.gz
bcm5719-llvm-c8ed40400ce5aa9942582c9f57866b8066c55fae.zip
NewGVN: Fix PR33194, memory corruption by putting temporary instructions in tables sometimes.
llvm-svn: 304194
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/NewGVN.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 67abc311698..39ed209bda2 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -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);
OpenPOWER on IntegriCloud