diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-27 06:56:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-27 06:56:12 +0000 |
commit | f57b845547302d24ecb6a9e79d7bc386f761a6c9 (patch) | |
tree | 369bc5be013a3a6d0373dbf26820d701e01c5297 /lib/Transforms/Scalar/ADCE.cpp | |
parent | f2361c5e5c2917e6f19a55927b221d8671753a40 (diff) | |
download | external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.gz external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.bz2 external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.zip |
* Rename MethodPass class to FunctionPass
- Rename runOnMethod to runOnFunction
* Transform getAnalysisUsageInfo into getAnalysisUsage
- Method is now const
- It now takes one AnalysisUsage object to fill in instead of 3 vectors
to fill in
- Pass's now specify which other passes they _preserve_ not which ones
they modify (be conservative!)
- A pass can specify that it preserves all analyses (because it never
modifies the underlying program)
* s/Method/Function/g in other random places as well
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2333 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/ADCE.cpp')
-rw-r--r-- | lib/Transforms/Scalar/ADCE.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index c129b5c5a8..71069c617c 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -29,7 +29,7 @@ using std::cerr; // It's public interface consists of a constructor and a doADCE() method. // class ADCE { - Function *M; // The method that we are working on... + Function *M; // The function that we are working on std::vector<Instruction*> WorkList; // Instructions that just became live std::set<Instruction*> LiveSet; // The set of live instructions bool MadeChanges; @@ -38,11 +38,11 @@ class ADCE { // The public interface for this class // public: - // ADCE Ctor - Save the method to operate on... - inline ADCE(Function *m) : M(m), MadeChanges(false) {} + // ADCE Ctor - Save the function to operate on... + inline ADCE(Function *f) : M(f), MadeChanges(false) {} // doADCE() - Run the Agressive Dead Code Elimination algorithm, returning - // true if the method was modified. + // true if the function was modified. bool doADCE(cfg::DominanceFrontier &CDG); //===--------------------------------------------------------------------===// @@ -75,14 +75,14 @@ private: // doADCE() - Run the Agressive Dead Code Elimination algorithm, returning -// true if the method was modified. +// true if the function was modified. // bool ADCE::doADCE(cfg::DominanceFrontier &CDG) { #ifdef DEBUG_ADCE cerr << "Function: " << M; #endif - // Iterate over all of the instructions in the method, eliminating trivially + // Iterate over all of the instructions in the function, eliminating trivially // dead instructions, and marking instructions live that are known to be // needed. Perform the walk in depth first order so that we avoid marking any // instructions live in basic blocks that are unreachable. These blocks will @@ -173,7 +173,7 @@ bool ADCE::doADCE(cfg::DominanceFrontier &CDG) { if (EntryBlock && EntryBlock != M->front()) { if (isa<PHINode>(EntryBlock->front())) { // Cannot make the first block be a block with a PHI node in it! Instead, - // strip the first basic block of the method to contain no instructions, + // strip the first basic block of the function to contain no instructions, // then add a simple branch to the "real" entry node... // BasicBlock *E = M->front(); @@ -191,9 +191,9 @@ bool ADCE::doADCE(cfg::DominanceFrontier &CDG) { } else { - // We need to move the new entry block to be the first bb of the method. + // We need to move the new entry block to be the first bb of the function Function::iterator EBI = find(M->begin(), M->end(), EntryBlock); - std::swap(*EBI, *M->begin());// Exchange old location with start of method + std::swap(*EBI, *M->begin()); // Exchange old location with start of fn MadeChanges = true; } } @@ -289,19 +289,17 @@ BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set<BasicBlock*> &VisitedBlocks, } namespace { - struct AgressiveDCE : public MethodPass { + struct AgressiveDCE : public FunctionPass { // doADCE - Execute the Agressive Dead Code Elimination Algorithm // - virtual bool runOnMethod(Function *M) { - return ADCE(M).doADCE( + virtual bool runOnFunction(Function *F) { + return ADCE(F).doADCE( getAnalysis<cfg::DominanceFrontier>(cfg::DominanceFrontier::PostDomID)); } - // getAnalysisUsageInfo - We require post dominance frontiers (aka Control + // getAnalysisUsage - We require post dominance frontiers (aka Control // Dependence Graph) - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Requires.push_back(cfg::DominanceFrontier::PostDomID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(cfg::DominanceFrontier::PostDomID); } }; } |