summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MemorySSA.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2018-08-22 22:34:38 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2018-08-22 22:34:38 +0000
commit5676a5d48cb8764341d7b6da0251b7988078be24 (patch)
treed705b0bbc363e908f17f70d8493c24897b10b8d0 /llvm/lib/Analysis/MemorySSA.cpp
parenta8accca4f598576cab06bd1917bbba59ec1513b9 (diff)
downloadbcm5719-llvm-5676a5d48cb8764341d7b6da0251b7988078be24.tar.gz
bcm5719-llvm-5676a5d48cb8764341d7b6da0251b7988078be24.zip
[MemorySSA] Invalidate optimized Defs upon moving them; NFC
We're currently getting this behavior implicitly, since we determine if a Def's optimization is valid based on the ID of its defining access. This is incorrect, though I wouldn't be surprised if this was masked in part by that we're using a WeakVH to track what Defs are optimized to. (Not to mention that we don't move Defs super often, AFAICT). I'll submit a patch to fix this shortly. This also includes a minor refactor to reduce duplication a bit. No test is included, since like said, this already happens to be our behavior. I'll add a test for this with my fix to the other bug mentioned above. llvm-svn: 340461
Diffstat (limited to 'llvm/lib/Analysis/MemorySSA.cpp')
-rw-r--r--llvm/lib/Analysis/MemorySSA.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index e9063f679b3..3eab719fa3b 100644
--- a/llvm/lib/Analysis/MemorySSA.cpp
+++ b/llvm/lib/Analysis/MemorySSA.cpp
@@ -1472,15 +1472,25 @@ void MemorySSA::insertIntoListsBefore(MemoryAccess *What, const BasicBlock *BB,
BlockNumberingValid.erase(BB);
}
+void MemorySSA::prepareForMoveTo(MemoryAccess *What, BasicBlock *BB) {
+ // Keep it in the lookup tables, remove from the lists
+ removeFromLists(What, false);
+
+ // Note that moving should implicitly invalidate the optimized state of a
+ // MemoryUse (and Phis can't be optimized). However, it doesn't do so for a
+ // MemoryDef.
+ if (auto *MD = dyn_cast<MemoryDef>(What))
+ MD->resetOptimized();
+ What->setBlock(BB);
+}
+
// Move What before Where in the IR. The end result is that What will belong to
// the right lists and have the right Block set, but will not otherwise be
// correct. It will not have the right defining access, and if it is a def,
// things below it will not properly be updated.
void MemorySSA::moveTo(MemoryUseOrDef *What, BasicBlock *BB,
AccessList::iterator Where) {
- // Keep it in the lookup tables, remove from the lists
- removeFromLists(What, false);
- What->setBlock(BB);
+ prepareForMoveTo(What, BB);
insertIntoListsBefore(What, BB, Where);
}
@@ -1496,8 +1506,7 @@ void MemorySSA::moveTo(MemoryAccess *What, BasicBlock *BB,
assert(Inserted && "Cannot move a Phi to a block that already has one");
}
- removeFromLists(What, false);
- What->setBlock(BB);
+ prepareForMoveTo(What, BB);
insertIntoListsForBlock(What, BB, Point);
}
OpenPOWER on IntegriCloud