diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-15 00:12:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-15 00:12:35 +0000 |
commit | b68ec5c339903ea05caaac13c37be9a21318239e (patch) | |
tree | cfbd6f504f37affa3463b0b2f2bfbe44ff7e50aa /llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | |
parent | f62308c9b0071c688eff4d4d8c1bbb03a77d2dcb (diff) | |
download | bcm5719-llvm-b68ec5c339903ea05caaac13c37be9a21318239e.tar.gz bcm5719-llvm-b68ec5c339903ea05caaac13c37be9a21318239e.zip |
Generalize LoadAndStorePromoter a bit and switch LICM
to use it.
llvm-svn: 123501
Diffstat (limited to 'llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 07d9787e663..13902552ebd 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -844,20 +844,13 @@ namespace { class AllocaPromoter : public LoadAndStorePromoter { AllocaInst *AI; public: - AllocaPromoter() : AI(0) {} + AllocaPromoter(const SmallVectorImpl<Instruction*> &Insts, SSAUpdater &S) + : LoadAndStorePromoter(Insts, S), AI(0) {} - void run(AllocaInst *AI, SSAUpdater &SSA) { + void run(AllocaInst *AI, const SmallVectorImpl<Instruction*> &Insts) { // Remember which alloca we're promoting (for isInstInList). this->AI = AI; - - // Build the list of instructions to promote. - SmallVector<Instruction*, 64> Insts; - for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end(); - UI != E; ++UI) - Insts.push_back(cast<Instruction>(*UI)); - - LoadAndStorePromoter::run(AI->getName(), Insts, &SSA); - + LoadAndStorePromoter::run(Insts); AI->eraseFromParent(); } @@ -882,7 +875,7 @@ bool SROA::performPromotion(Function &F) { BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function bool Changed = false; - + SmallVector<Instruction*, 64> Insts; while (1) { Allocas.clear(); @@ -899,9 +892,17 @@ bool SROA::performPromotion(Function &F) { PromoteMemToReg(Allocas, *DT, *DF); else { SSAUpdater SSA; - AllocaPromoter Promoter; - for (unsigned i = 0, e = Allocas.size(); i != e; ++i) - Promoter.run(Allocas[i], SSA); + for (unsigned i = 0, e = Allocas.size(); i != e; ++i) { + AllocaInst *AI = Allocas[i]; + + // Build list of instructions to promote. + for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end(); + UI != E; ++UI) + Insts.push_back(cast<Instruction>(*UI)); + + AllocaPromoter(Insts, SSA).run(AI, Insts); + Insts.clear(); + } } NumPromoted += Allocas.size(); Changed = true; |