diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-09-14 10:26:38 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-09-14 10:26:38 +0000 |
commit | 8615cd236ed9f9540b4a3ad05dd0a1d202a3f6b4 (patch) | |
tree | ca8a4e775e25c6a37fdce4134f476ad9f0f3e74f /lib/Transforms | |
parent | 50754f089265bd6a4208d8b89c653e7f7854796a (diff) |
Move an instance variable to a local variable based on review by Duncan.
Originally I had anticipated needing to thread this through more bits of
the SROA pass itself, but that ended up not happening. In the end, this
is a much simpler way to manange the variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163893 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/SROA.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index 3d9752704c..acfa87a32e 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -1150,12 +1150,6 @@ class SROA : public FunctionPass { /// uses as dead. Only used to guard insertion into DeadInsts. SmallPtrSet<Instruction *, 4> DeadSplitInsts; - /// \brief A set of deleted alloca instructions. - /// - /// These pointers are *no longer valid* as they have been deleted. They are - /// used to remove deleted allocas from the list of promotable allocas. - SmallPtrSet<AllocaInst *, 4> DeletedAllocas; - /// \brief A collection of alloca instructions we can directly promote. std::vector<AllocaInst *> PromotableAllocas; @@ -1178,7 +1172,7 @@ private: AllocaPartitioning::iterator PI); bool splitAlloca(AllocaInst &AI, AllocaPartitioning &P); bool runOnAlloca(AllocaInst &AI); - void deleteDeadInstructions(); + void deleteDeadInstructions(SmallPtrSet<AllocaInst *, 4> &DeletedAllocas); }; } @@ -2556,7 +2550,16 @@ bool SROA::runOnAlloca(AllocaInst &AI) { return splitAlloca(AI, P) || Changed; } -void SROA::deleteDeadInstructions() { +/// \brief Delete the dead instructions accumulated in this run. +/// +/// Recursively deletes the dead instructions we've accumulated. This is done +/// at the very end to maximize locality of the recursive delete and to +/// minimize the problems of invalidated instruction pointers as such pointers +/// are used heavily in the intermediate stages of the algorithm. +/// +/// We also record the alloca instructions deleted here so that they aren't +/// subsequently handed to mem2reg to promote. +void SROA::deleteDeadInstructions(SmallPtrSet<AllocaInst*, 4> &DeletedAllocas) { DeadSplitInsts.clear(); while (!DeadInsts.empty()) { Instruction *I = DeadInsts.pop_back_val(); @@ -2607,9 +2610,13 @@ bool SROA::runOnFunction(Function &F) { Worklist.insert(AI); bool Changed = false; + // A set of deleted alloca instruction pointers which should be removed from + // the list of promotable allocas. + SmallPtrSet<AllocaInst *, 4> DeletedAllocas; + while (!Worklist.empty()) { Changed |= runOnAlloca(*Worklist.pop_back_val()); - deleteDeadInstructions(); + deleteDeadInstructions(DeletedAllocas); if (!DeletedAllocas.empty()) { PromotableAllocas.erase(std::remove_if(PromotableAllocas.begin(), PromotableAllocas.end(), |