aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/MemorySSAUpdater.cpp
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-05-02 23:12:49 +0000
committerAlina Sbirlea <asbirlea@google.com>2019-05-02 23:12:49 +0000
commit151ab4844af55846c8ae609cc7e39bb19c9a3d73 (patch)
tree6ea9eeeadbf5e5837df0ca4752f1804f18606603 /llvm/lib/Analysis/MemorySSAUpdater.cpp
parent1db0f0ca988f95916dc553afa48387b698811ec8 (diff)
downloadllvm-151ab4844af55846c8ae609cc7e39bb19c9a3d73.zip
llvm-151ab4844af55846c8ae609cc7e39bb19c9a3d73.tar.gz
llvm-151ab4844af55846c8ae609cc7e39bb19c9a3d73.tar.bz2
[MemorySSA] Refactor removing multiple trivial phis [NFC].
Summary: Create a method to clean up multiple potentially trivial phis, since we will need this often. Reviewers: george.burgess.iv Subscribers: jlebar, Prazek, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61471 llvm-svn: 359842
Diffstat (limited to 'llvm/lib/Analysis/MemorySSAUpdater.cpp')
-rw-r--r--llvm/lib/Analysis/MemorySSAUpdater.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index 3f3fd99..7c675b7 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -355,12 +355,9 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) {
}
// Optimize potentially non-minimal phis added in this method.
- for (unsigned Idx = NewPhiIndex; Idx < NewPhiIndexEnd; ++Idx) {
- if (auto *MPhi = cast_or_null<MemoryPhi>(InsertedPHIs[Idx])) {
- auto OperRange = MPhi->operands();
- tryRemoveTrivialPhi(MPhi, OperRange);
- }
- }
+ unsigned NewPhiSize = NewPhiIndexEnd - NewPhiIndex;
+ if (NewPhiSize)
+ tryRemoveTrivialPhis(ArrayRef<WeakVH>(&InsertedPHIs[NewPhiIndex], NewPhiSize));
// Now that all fixups are done, rename all uses if we are asked.
if (RenameUses) {
@@ -1215,6 +1212,14 @@ void MemorySSAUpdater::removeBlocks(
}
}
+void MemorySSAUpdater::tryRemoveTrivialPhis(ArrayRef<WeakVH> UpdatedPHIs) {
+ for (auto &VH : UpdatedPHIs)
+ if (auto *MPhi = cast_or_null<MemoryPhi>(VH)) {
+ auto OperRange = MPhi->operands();
+ tryRemoveTrivialPhi(MPhi, OperRange);
+ }
+}
+
MemoryAccess *MemorySSAUpdater::createMemoryAccessInBB(
Instruction *I, MemoryAccess *Definition, const BasicBlock *BB,
MemorySSA::InsertionPlace Point) {