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/IPO | |
parent | f2361c5e5c2917e6f19a55927b221d8671753a40 (diff) | |
download | external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.zip external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.gz external_llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.bz2 |
* 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/IPO')
-rw-r--r-- | lib/Transforms/IPO/ConstantMerge.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/IPO/DeadTypeElimination.cpp | 17 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalDCE.cpp | 11 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 20 | ||||
-rw-r--r-- | lib/Transforms/IPO/MutateStructTypes.cpp | 26 | ||||
-rw-r--r-- | lib/Transforms/IPO/OldPoolAllocate.cpp | 7 | ||||
-rw-r--r-- | lib/Transforms/IPO/SimpleStructMutation.cpp | 14 |
7 files changed, 40 insertions, 65 deletions
diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index ef51105..ee28b13 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -58,8 +58,8 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo, } namespace { - // FIXME: ConstantMerge should not be a methodPass!!! - class ConstantMerge : public MethodPass { + // FIXME: ConstantMerge should not be a FunctionPass!!! + class ConstantMerge : public FunctionPass { protected: std::map<Constant*, GlobalVariable*> Constants; unsigned LastConstantSeen; @@ -73,7 +73,7 @@ namespace { return ::mergeDuplicateConstants(M, LastConstantSeen, Constants); } - bool runOnMethod(Function *) { return false; } + bool runOnFunction(Function *) { return false; } // doFinalization - Clean up internal state for this module // @@ -85,10 +85,10 @@ namespace { }; struct DynamicConstantMerge : public ConstantMerge { - // runOnMethod - Check to see if any globals have been added to the + // runOnFunction - Check to see if any globals have been added to the // global list for the module. If so, eliminate them. // - bool runOnMethod(Function *F) { + bool runOnFunction(Function *F) { return ::mergeDuplicateConstants(F->getParent(), LastConstantSeen, Constants); } diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index 4f2e24d..3ba6057 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -35,7 +35,7 @@ using std::cerr; static const Type *PtrSByte = 0; // 'sbyte*' type namespace { - struct CleanupGCCOutput : public MethodPass { + struct CleanupGCCOutput : public FunctionPass { // doPassInitialization - For this pass, it removes global symbol table // entries for primitive types. These are never used for linking in GCC and // they make the output uglier to look at, so we nuke them. @@ -46,18 +46,15 @@ namespace { // runOnFunction - This method simplifies the specified function hopefully. // - bool runOnMethod(Function *F); + bool runOnFunction(Function *F); // doPassFinalization - Strip out type names that are unused by the program bool doFinalization(Module *M); - // getAnalysisUsageInfo - This function needs FindUsedTypes to do its job... + // getAnalysisUsage - This function needs FindUsedTypes to do its job... // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - // FIXME: Invalidates the CFG - Required.push_back(FindUsedTypes::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(FindUsedTypes::ID); } }; } @@ -246,7 +243,7 @@ static inline void RefactorPredecessor(BasicBlock *BB, BasicBlock *Pred) { } -// runOnMethod - Loop through the function and fix problems with the PHI nodes +// runOnFunction - Loop through the function and fix problems with the PHI nodes // in the current function. The problem is that PHI nodes might exist with // multiple entries for the same predecessor. GCC sometimes generates code that // looks like this: @@ -262,7 +259,7 @@ static inline void RefactorPredecessor(BasicBlock *BB, BasicBlock *Pred) { // bb8: %reg119 = phi uint [ 0, %bbX ], [ 1, %bb7 ] // // -bool CleanupGCCOutput::runOnMethod(Function *M) { +bool CleanupGCCOutput::runOnFunction(Function *M) { bool Changed = false; // Don't use iterators because invalidation gets messy... for (unsigned MI = 0; MI < M->size(); ++MI) { diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index ae9bd39..cd9c35f 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -1,6 +1,7 @@ //===-- GlobalDCE.cpp - DCE unreachable internal functions ----------------===// // // This transform is designed to eliminate unreachable internal globals +// FIXME: GlobalDCE should update the callgraph, not destroy it! // //===----------------------------------------------------------------------===// @@ -55,16 +56,12 @@ namespace { return RemoveUnreachableFunctions(M, getAnalysis<CallGraph>()); } - // getAnalysisUsageInfo - This function works on the call graph of a module. + // getAnalysisUsage - This function works on the call graph of a module. // It is capable of updating the call graph to reflect the new state of the // module. // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Required.push_back(CallGraph::ID); - // FIXME: This should update the callgraph, not destroy it! - Destroyed.push_back(CallGraph::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(CallGraph::ID); } }; } diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 7f96278..fcb1e4f 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -53,7 +53,7 @@ static inline void RemapInstruction(Instruction *I, } } -// InlineMethod - This function forcibly inlines the called function into the +// InlineFunction - This function forcibly inlines the called function into the // basic block of the caller. This returns false if it is not possible to // inline this call. The program is still in a well defined state if this // occurs though. @@ -63,8 +63,8 @@ static inline void RemapInstruction(Instruction *I, // exists in the instruction stream. Similiarly this will inline a recursive // function by one level. // -bool InlineMethod(BasicBlock::iterator CIIt) { - assert(isa<CallInst>(*CIIt) && "InlineMethod only works on CallInst nodes!"); +bool InlineFunction(BasicBlock::iterator CIIt) { + assert(isa<CallInst>(*CIIt) && "InlineFunction only works on CallInst nodes"); assert((*CIIt)->getParent() && "Instruction not embedded in basic block!"); assert((*CIIt)->getParent()->getParent() && "Instruction not in function!"); @@ -209,7 +209,7 @@ bool InlineMethod(BasicBlock::iterator CIIt) { return true; } -bool InlineMethod(CallInst *CI) { +bool InlineFunction(CallInst *CI) { assert(CI->getParent() && "CallInst not embeded in BasicBlock!"); BasicBlock *PBB = CI->getParent(); @@ -217,12 +217,12 @@ bool InlineMethod(CallInst *CI) { assert(CallIt != PBB->end() && "CallInst has parent that doesn't contain CallInst?!?"); - return InlineMethod(CallIt); + return InlineFunction(CallIt); } static inline bool ShouldInlineFunction(const CallInst *CI, const Function *F) { assert(CI->getParent() && CI->getParent()->getParent() && - "Call not embedded into a method!"); + "Call not embedded into a function!"); // Don't inline a recursive call. if (CI->getParent()->getParent() == F) return false; @@ -244,7 +244,7 @@ static inline bool DoFunctionInlining(BasicBlock *BB) { // Check to see if we should inline this function Function *F = CI->getCalledFunction(); if (F && ShouldInlineFunction(CI, F)) - return InlineMethod(I); + return InlineFunction(I); } } return false; @@ -270,11 +270,11 @@ static bool doFunctionInlining(Function *F) { } namespace { - struct FunctionInlining : public MethodPass { - virtual bool runOnMethod(Function *F) { + struct FunctionInlining : public FunctionPass { + virtual bool runOnFunction(Function *F) { return doFunctionInlining(F); } }; } -Pass *createMethodInliningPass() { return new FunctionInlining(); } +Pass *createFunctionInliningPass() { return new FunctionInlining(); } diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index b5dd937..2a6d184 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -28,12 +28,6 @@ using std::map; using std::vector; -//FIXME: These headers are only included because the analyses are killed!!! -#include "llvm/Analysis/CallGraph.h" -#include "llvm/Analysis/FindUsedTypes.h" -#include "llvm/Analysis/FindUnsafePointerTypes.h" -//FIXME end - // To enable debugging, uncomment this... //#define DEBUG_MST(x) x @@ -273,7 +267,7 @@ void MutateStructTypes::processGlobals(Module *M) { if (Meth->hasName()) Meth->setName("OLD."+Meth->getName()); - // Insert the new function into the method list... to be filled in later.. + // Insert the new function into the function list... to be filled in later M->getFunctionList().push_back(NewMeth); // Keep track of the association... @@ -325,10 +319,10 @@ void MutateStructTypes::removeDeadGlobals(Module *M) { -// transformMethod - This transforms the instructions of the function to use the -// new types. +// transformFunction - This transforms the instructions of the function to use +// the new types. // -void MutateStructTypes::transformMethod(Function *m) { +void MutateStructTypes::transformFunction(Function *m) { const Function *M = m; map<const GlobalValue*, GlobalValue*>::iterator GMI = GlobalMap.find(M); if (GMI == GlobalMap.end()) @@ -518,19 +512,9 @@ bool MutateStructTypes::run(Module *M) { processGlobals(M); for_each(M->begin(), M->end(), - bind_obj(this, &MutateStructTypes::transformMethod)); + bind_obj(this, &MutateStructTypes::transformFunction)); removeDeadGlobals(M); return true; } -// getAnalysisUsageInfo - This function needs the results of the -// FindUsedTypes and FindUnsafePointerTypes analysis passes... -// -void MutateStructTypes::getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Destroyed.push_back(FindUsedTypes::ID); - Destroyed.push_back(FindUnsafePointerTypes::ID); - Destroyed.push_back(CallGraph::ID); -} diff --git a/lib/Transforms/IPO/OldPoolAllocate.cpp b/lib/Transforms/IPO/OldPoolAllocate.cpp index 43683e4..bd67fe1 100644 --- a/lib/Transforms/IPO/OldPoolAllocate.cpp +++ b/lib/Transforms/IPO/OldPoolAllocate.cpp @@ -234,12 +234,11 @@ namespace { bool run(Module *M); - // getAnalysisUsageInfo - This function requires data structure information + // getAnalysisUsage - This function requires data structure information // to be able to see what is pool allocatable. // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &,Pass::AnalysisSet &) { - Required.push_back(DataStructure::ID); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(DataStructure::ID); } public: diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index 5c64aa3..33e0289 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -1,4 +1,4 @@ -//===- SimpleStructMutation.cpp - Swap structure elements around ---*- C++ -*--=// +//===- SimpleStructMutation.cpp - Swap structure elements around -*- C++ -*--=// // // This pass does a simple transformation that swaps all of the elements of the // struct types in the program around. @@ -31,15 +31,13 @@ namespace { return Changed; } - // getAnalysisUsageInfo - This function needs the results of the + // getAnalysisUsage - This function needs the results of the // FindUsedTypes and FindUnsafePointerTypes analysis passes... // - virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required, - Pass::AnalysisSet &Destroyed, - Pass::AnalysisSet &Provided) { - Required.push_back(FindUsedTypes::ID); - Required.push_back(FindUnsafePointerTypes::ID); - MutateStructTypes::getAnalysisUsageInfo(Required, Destroyed, Provided); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(FindUsedTypes::ID); + AU.addRequired(FindUnsafePointerTypes::ID); + MutateStructTypes::getAnalysisUsage(AU); } private: |