diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2015-01-18 01:45:07 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2015-01-18 01:45:07 +0000 |
commit | 5eee895ccf9bea773e3c01f8915a9fba106e4f3f (patch) | |
tree | b20de8eec7951800f5cbee9c17a11bd1600ae664 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | |
parent | 691addc25f9ad25da4c679e447b325efce613308 (diff) | |
download | llvm-5eee895ccf9bea773e3c01f8915a9fba106e4f3f.zip llvm-5eee895ccf9bea773e3c01f8915a9fba106e4f3f.tar.gz llvm-5eee895ccf9bea773e3c01f8915a9fba106e4f3f.tar.bz2 |
[PM] Lift the actual analyses used into the inferface rather than
accepting a Pass and querying it for analyses.
This is necessary to allow the utilities to work both with the old and
new pass managers, and I also think this makes the interface much more
clear and helps the reader know what analyses the utility can actually
handle. I plan to repeat this process iteratively to clean up all the
pass utilities.
llvm-svn: 226386
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index 867e433..29b5d2b 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -65,16 +65,10 @@ void llvm::DeleteDeadBlock(BasicBlock *BB) { /// any single-entry PHI nodes in it, fold them away. This handles the case /// when all entries to the PHI nodes in a block are guaranteed equal, such as /// when the block has exactly one predecessor. -void llvm::FoldSingleEntryPHINodes(BasicBlock *BB, Pass *P) { +void llvm::FoldSingleEntryPHINodes(BasicBlock *BB, AliasAnalysis *AA, + MemoryDependenceAnalysis *MemDep) { if (!isa<PHINode>(BB->begin())) return; - AliasAnalysis *AA = nullptr; - MemoryDependenceAnalysis *MemDep = nullptr; - if (P) { - AA = P->getAnalysisIfAvailable<AliasAnalysis>(); - MemDep = P->getAnalysisIfAvailable<MemoryDependenceAnalysis>(); - } - while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) { if (PN->getIncomingValue(0) != PN) PN->replaceAllUsesWith(PN->getIncomingValue(0)); @@ -148,8 +142,11 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, Pass *P) { } // Begin by getting rid of unneeded PHIs. - if (isa<PHINode>(BB->front())) - FoldSingleEntryPHINodes(BB, P); + if (isa<PHINode>(BB->front())) { + auto *AA = P ? P->getAnalysisIfAvailable<AliasAnalysis>() : nullptr; + auto *MemDep = P ? P->getAnalysisIfAvailable<MemoryDependenceAnalysis>() : nullptr; + FoldSingleEntryPHINodes(BB, AA, MemDep); + } // Delete the unconditional branch from the predecessor... PredBB->getInstList().pop_back(); |