diff options
author | Chris Lattner <sabre@nondot.org> | 2002-02-12 18:27:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-02-12 18:27:41 +0000 |
commit | 71b9411b8c90cfb479ab7d641ba81fbe379f33df (patch) | |
tree | cee17ebd5a1fbac897095acd44e11a310bc51ea7 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp | |
parent | eeeaf52ab6918ce309ad5e14f1e226e5c1d2c9a9 (diff) |
I forgot to provide dominance frontier information. Now it's available.
Also add more comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index e53150d643..f8cdb08520 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -18,12 +18,15 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar/PromoteMemoryToRegister.h" +#include "llvm/Analysis/Dominators.h" #include "llvm/iMemory.h" #include "llvm/Pass.h" #include "llvm/Method.h" - #include "llvm/Assembly/Writer.h" // For debugging +using cfg::DominanceFrontier; +// PromotePass - This class is implements the PromoteMemoryToRegister pass +// class PromotePass : public MethodPass { public: // runOnMethod - To run this pass, first we calculate the alloca instructions @@ -33,14 +36,27 @@ public: std::vector<AllocaInst*> Allocas; findSafeAllocas(M, Allocas); // Calculate safe allocas + // Get dominance frontier information... + DominanceFrontier &DF = getAnalysis<DominanceFrontier>(); + // Transform each alloca in turn... for (std::vector<AllocaInst*>::iterator I = Allocas.begin(), E = Allocas.end(); I != E; ++I) - promoteAlloca(*I); + promoteAlloca(*I, DF); return !Allocas.empty(); } + + // getAnalysisUsageInfo - We need dominance frontiers + // + virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + Requires.push_back(DominanceFrontier::ID); + } + +private: // findSafeAllocas - Find allocas that are safe to promote // void findSafeAllocas(Method *M, std::vector<AllocaInst*> &Allocas) const; @@ -48,7 +64,7 @@ public: // promoteAlloca - Convert the use chain of an alloca instruction into // register references. // - void promoteAlloca(AllocaInst *AI); + void promoteAlloca(AllocaInst *AI, DominanceFrontier &DF); }; @@ -79,15 +95,18 @@ void PromotePass::findSafeAllocas(Method *M, } + + // promoteAlloca - Convert the use chain of an alloca instruction into // register references. // -void PromotePass::promoteAlloca(AllocaInst *AI) { +void PromotePass::promoteAlloca(AllocaInst *AI, DominanceFrontier &DFInfo) { cerr << "TODO: Should process: " << AI; } - +// newPromoteMemoryToRegister - Provide an entry point to create this pass. +// Pass *newPromoteMemoryToRegister() { return new PromotePass(); } |