[llvm] r359842 - [MemorySSA] Refactor removing multiple trivial phis [NFC].
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Thu May 2 16:12:49 PDT 2019
Author: asbirlea
Date: Thu May 2 16:12:49 2019
New Revision: 359842
URL: http://llvm.org/viewvc/llvm-project?rev=359842&view=rev
Log:
[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
Modified:
llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h
llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
Modified: llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h?rev=359842&r1=359841&r2=359842&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h Thu May 2 16:12:49 2019
@@ -261,6 +261,7 @@ private:
MemoryAccess *recursePhi(MemoryAccess *Phi);
template <class RangeType>
MemoryAccess *tryRemoveTrivialPhi(MemoryPhi *Phi, RangeType &Operands);
+ void tryRemoveTrivialPhis(ArrayRef<WeakVH> UpdatedPHIs);
void fixupDefs(const SmallVectorImpl<WeakVH> &);
// Clone all uses and defs from BB to NewBB given a 1:1 map of all
// instructions and blocks cloned, and a map of MemoryPhi : Definition
Modified: llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp?rev=359842&r1=359841&r2=359842&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp (original)
+++ llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp Thu May 2 16:12:49 2019
@@ -355,12 +355,9 @@ void MemorySSAUpdater::insertDef(MemoryD
}
// 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) {
More information about the llvm-commits
mailing list