diff options
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/ExprTypeConvert.cpp | 22 | ||||
-rw-r--r-- | lib/Transforms/HoistPHIConstants.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/IPO/ConstantMerge.cpp | 12 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalDCE.cpp | 34 | ||||
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 87 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp | 22 | ||||
-rw-r--r-- | lib/Transforms/LevelRaise.cpp | 16 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ConstantProp.cpp | 12 | ||||
-rw-r--r-- | lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SymbolStripping.cpp | 28 | ||||
-rw-r--r-- | lib/Transforms/TransformInternals.cpp | 1 | ||||
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 35 | ||||
-rw-r--r-- | lib/Transforms/Utils/UnifyFunctionExitNodes.cpp | 16 |
14 files changed, 152 insertions, 159 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index 790f68f7a3..b91a74e1e8 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "TransformInternals.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/iOther.h" #include "llvm/iPHINode.h" #include "llvm/iMemory.h" @@ -828,34 +828,34 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty, assert (OI != I->op_end() && "Not using value!"); unsigned OpNum = OI - I->op_begin(); - // Are we trying to change the method pointer value to a new type? + // Are we trying to change the function pointer value to a new type? if (OpNum == 0) { PointerType *PTy = dyn_cast<PointerType>(Ty); if (PTy == 0) return false; // Can't convert to a non-pointer type... FunctionType *MTy = dyn_cast<FunctionType>(PTy->getElementType()); - if (MTy == 0) return false; // Can't convert to a non ptr to method... + if (MTy == 0) return false; // Can't convert to a non ptr to function... - // Perform sanity checks to make sure that new method type has the + // Perform sanity checks to make sure that new function type has the // correct number of arguments... // - unsigned NumArgs = I->getNumOperands()-1; // Don't include method ptr + unsigned NumArgs = I->getNumOperands()-1; // Don't include function ptr // Cannot convert to a type that requires more fixed arguments than // the call provides... // if (NumArgs < MTy->getParamTypes().size()) return false; - // Unless this is a vararg method type, we cannot provide more arguments + // Unless this is a vararg function type, we cannot provide more arguments // than are desired... // if (!MTy->isVarArg() && NumArgs > MTy->getParamTypes().size()) return false; - // Okay, at this point, we know that the call and the method type match + // Okay, at this point, we know that the call and the function type match // number of arguments. Now we see if we can convert the arguments // themselves. Note that we do not require operands to be convertable, // we can insert casts if they are convertible but not compatible. The - // reason for this is that we prefer to have resolved methods but casted + // reason for this is that we prefer to have resolved functions but casted // arguments if possible. // const FunctionType::ParamTypes &PTs = MTy->getParamTypes(); @@ -878,7 +878,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty, return false; // It's not in the varargs section... // If we get this far, we know the value is in the varargs section of the - // method! We can convert if we don't reinterpret the value... + // function! We can convert if we don't reinterpret the value... // return Ty->isLosslesslyConvertableTo(V->getType()); } @@ -1098,7 +1098,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, Value *Meth = I->getOperand(0); std::vector<Value*> Params(I->op_begin()+1, I->op_end()); - if (Meth == OldVal) { // Changing the method pointer? + if (Meth == OldVal) { // Changing the function pointer? PointerType *NewPTy = cast<PointerType>(NewVal->getType()); FunctionType *NewTy = cast<FunctionType>(NewPTy->getElementType()); const FunctionType::ParamTypes &PTs = NewTy->getParamTypes(); @@ -1107,7 +1107,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, // operands if needbe. Note that we do not require operands to be // convertable, we can insert casts if they are convertible but not // compatible. The reason for this is that we prefer to have resolved - // methods but casted arguments if possible. + // functions but casted arguments if possible. // BasicBlock::iterator It = find(BIL.begin(), BIL.end(), I); diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp index f20de1cfc2..26cf5ca04f 100644 --- a/lib/Transforms/HoistPHIConstants.cpp +++ b/lib/Transforms/HoistPHIConstants.cpp @@ -10,7 +10,7 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include "llvm/BasicBlock.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/Pass.h" #include <map> #include <vector> @@ -42,11 +42,11 @@ static Value *NormalizePhiOperand(PHINode *PN, Value *CPV, // Entry point for normalizing constant args in PHIs //--------------------------------------------------------------------------- -static bool doHoistPHIConstants(Method *M) { +static bool doHoistPHIConstants(Function *M) { CachedCopyMap Cache; bool Changed = false; - for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) { + for (Function::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) { std::vector<PHINode*> phis; // normalizing invalidates BB iterator for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) { @@ -75,7 +75,7 @@ static bool doHoistPHIConstants(Method *M) { namespace { struct HoistPHIConstants : public MethodPass { - virtual bool runOnMethod(Method *M) { return doHoistPHIConstants(M); } + virtual bool runOnMethod(Function *F) { return doHoistPHIConstants(F); } }; } diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index d78d185e8a..ef51105a47 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -9,7 +9,7 @@ // and elminate duplicates when it is initialized. // // The DynamicConstantMerge method is a superset of the ConstantMerge algorithm -// that checks for each method to see if constants have been added to the +// that checks for each function to see if constants have been added to the // constant pool since it was last run... if so, it processes them. // //===----------------------------------------------------------------------===// @@ -17,7 +17,7 @@ #include "llvm/Transforms/ConstantMerge.h" #include "llvm/GlobalVariable.h" #include "llvm/Module.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/Pass.h" // mergeDuplicateConstants - Workhorse for the pass. This eliminates duplicate @@ -73,7 +73,7 @@ namespace { return ::mergeDuplicateConstants(M, LastConstantSeen, Constants); } - bool runOnMethod(Method*) { return false; } + bool runOnMethod(Function *) { return false; } // doFinalization - Clean up internal state for this module // @@ -85,11 +85,11 @@ namespace { }; struct DynamicConstantMerge : public ConstantMerge { - // doPerMethodWork - Check to see if any globals have been added to the + // runOnMethod - Check to see if any globals have been added to the // global list for the module. If so, eliminate them. // - bool runOnMethod(Method *M) { - return ::mergeDuplicateConstants(M->getParent(), LastConstantSeen, + bool runOnMethod(Function *F) { + return ::mergeDuplicateConstants(F->getParent(), LastConstantSeen, Constants); } }; diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index ea23dbedda..ae9bd39270 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -1,4 +1,4 @@ -//===-- GlobalDCE.cpp - DCE unreachable internal methods ---------*- C++ -*--=// +//===-- GlobalDCE.cpp - DCE unreachable internal functions ----------------===// // // This transform is designed to eliminate unreachable internal globals // @@ -7,40 +7,40 @@ #include "llvm/Transforms/IPO/GlobalDCE.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/Module.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/Pass.h" #include "Support/DepthFirstIterator.h" #include <set> -static bool RemoveUnreachableMethods(Module *M, CallGraph &CallGraph) { - // Calculate which methods are reachable from the external methods in the call - // graph. +static bool RemoveUnreachableFunctions(Module *M, CallGraph &CallGraph) { + // Calculate which functions are reachable from the external functions in the + // call graph. // std::set<CallGraphNode*> ReachableNodes(df_begin(&CallGraph), df_end(&CallGraph)); - // Loop over the methods in the module twice. The first time is used to drop - // references that methods have to each other before they are deleted. The - // second pass removes the methods that need to be removed. + // Loop over the functions in the module twice. The first time is used to + // drop references that functions have to each other before they are deleted. + // The second pass removes the functions that need to be removed. // - std::vector<CallGraphNode*> MethodsToDelete; // Track unused methods + std::vector<CallGraphNode*> FunctionsToDelete; // Track unused functions for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { CallGraphNode *N = CallGraph[*I]; if (!ReachableNodes.count(N)) { // Not reachable?? (*I)->dropAllReferences(); N->removeAllCalledMethods(); - MethodsToDelete.push_back(N); + FunctionsToDelete.push_back(N); } } - // Nothing to do if no unreachable methods have been found... - if (MethodsToDelete.empty()) return false; + // Nothing to do if no unreachable functions have been found... + if (FunctionsToDelete.empty()) return false; - // Unreachables methods have been found and should have no references to them, - // delete them now. + // Unreachables functions have been found and should have no references to + // them, delete them now. // - for (std::vector<CallGraphNode*>::iterator I = MethodsToDelete.begin(), - E = MethodsToDelete.end(); I != E; ++I) + for (std::vector<CallGraphNode*>::iterator I = FunctionsToDelete.begin(), + E = FunctionsToDelete.end(); I != E; ++I) delete CallGraph.removeMethodFromModule(*I); return true; @@ -52,7 +52,7 @@ namespace { // the specified callgraph to reflect the changes. // bool run(Module *M) { - return RemoveUnreachableMethods(M, getAnalysis<CallGraph>()); + return RemoveUnreachableFunctions(M, getAnalysis<CallGraph>()); } // getAnalysisUsageInfo - This function works on the call graph of a module. diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 51cde2e799..d720c3c2cc 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -1,26 +1,23 @@ -//===- MethodInlining.cpp - Code to perform method inlining ---------------===// +//===- FunctionInlining.cpp - Code to perform function inlining -----------===// // -// This file implements inlining of methods. +// This file implements inlining of functions. // // Specifically, this: -// * Exports functionality to inline any method call -// * Inlines methods that consist of a single basic block -// * Is able to inline ANY method call -// . Has a smart heuristic for when to inline a method +// * Exports functionality to inline any function call +// * Inlines functions that consist of a single basic block +// * Is able to inline ANY function call +// . Has a smart heuristic for when to inline a function // // Notice that: // * This pass opens up a lot of opportunities for constant propogation. It // is a good idea to to run a constant propogation pass, then a DCE pass // sometime after running this pass. // -// TODO: Currently this throws away all of the symbol names in the method being -// inlined. This shouldn't happen. -// //===----------------------------------------------------------------------===// #include "llvm/Transforms/MethodInlining.h" #include "llvm/Module.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/Pass.h" #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" @@ -53,7 +50,7 @@ static inline void RemapInstruction(Instruction *I, } } -// InlineMethod - This function forcibly inlines the called method into the +// InlineMethod - 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. @@ -61,16 +58,16 @@ static inline void RemapInstruction(Instruction *I, // Note that this only does one level of inlining. For example, if the // instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now // exists in the instruction stream. Similiarly this will inline a recursive -// method by one level. +// function by one level. // bool InlineMethod(BasicBlock::iterator CIIt) { assert(isa<CallInst>(*CIIt) && "InlineMethod only works on CallInst nodes!"); assert((*CIIt)->getParent() && "Instruction not embedded in basic block!"); - assert((*CIIt)->getParent()->getParent() && "Instruction not in method!"); + assert((*CIIt)->getParent()->getParent() && "Instruction not in function!"); CallInst *CI = cast<CallInst>(*CIIt); const Function *CalledMeth = CI->getCalledFunction(); - if (CalledMeth == 0 || // Can't inline external method or indirect call! + if (CalledMeth == 0 || // Can't inline external function or indirect call! CalledMeth->isExternal()) return false; //cerr << "Inlining " << CalledMeth->getName() << " into " @@ -90,7 +87,7 @@ bool InlineMethod(BasicBlock::iterator CIIt) { // If we have a return value generated by this call, convert it into a PHI // node that gets values from each of the old RET instructions in the original - // method. + // function. // PHINode *PHI = 0; if (CalledMeth->getReturnType() != Type::VoidTy) { @@ -107,26 +104,26 @@ bool InlineMethod(BasicBlock::iterator CIIt) { CI->replaceAllUsesWith(PHI); } - // Keep a mapping between the original method's values and the new duplicated - // code's values. This includes all of: Method arguments, instruction values, - // constant pool entries, and basic blocks. + // Keep a mapping between the original function's values and the new + // duplicated code's values. This includes all of: Function arguments, + // instruction values, constant pool entries, and basic blocks. // std::map<const Value *, Value*> ValueMap; - // Add the method arguments to the mapping: (start counting at 1 to skip the - // method reference itself) + // Add the function arguments to the mapping: (start counting at 1 to skip the + // function reference itself) // - Method::ArgumentListType::const_iterator PTI = + Function::ArgumentListType::const_iterator PTI = CalledMeth->getArgumentList().begin(); for (unsigned a = 1, E = CI->getNumOperands(); a != E; ++a, ++PTI) ValueMap[*PTI] = CI->getOperand(a); ValueMap[NewBB] = NewBB; // Returns get converted to reference NewBB - // Loop over all of the basic blocks in the method, inlining them as - // appropriate. Keep track of the first basic block of the method... + // Loop over all of the basic blocks in the function, inlining them as + // appropriate. Keep track of the first basic block of the function... // - for (Method::const_iterator BI = CalledMeth->begin(); + for (Function::const_iterator BI = CalledMeth->begin(); BI != CalledMeth->end(); ++BI) { const BasicBlock *BB = *BI; assert(BB->getTerminator() && "BasicBlock doesn't have terminator!?!?"); @@ -161,7 +158,7 @@ bool InlineMethod(BasicBlock::iterator CIIt) { if (PHI) { // The PHI node should include this value! assert(RI->getReturnValue() && "Ret should have value!"); assert(RI->getReturnValue()->getType() == PHI->getType() && - "Ret value not consistent in method!"); + "Ret value not consistent in function!"); PHI->addIncoming((Value*)RI->getReturnValue(), cast<BasicBlock>(BB)); } @@ -174,16 +171,16 @@ bool InlineMethod(BasicBlock::iterator CIIt) { break; default: - cerr << "MethodInlining: Don't know how to handle terminator: " << TI; + cerr << "FunctionInlining: Don't know how to handle terminator: " << TI; abort(); } } - // Loop over all of the instructions in the method, fixing up operand + // Loop over all of the instructions in the function, fixing up operand // references as we go. This uses ValueMap to do all the hard work. // - for (Method::const_iterator BI = CalledMeth->begin(); + for (Function::const_iterator BI = CalledMeth->begin(); BI != CalledMeth->end(); ++BI) { const BasicBlock *BB = *BI; BasicBlock *NBB = (BasicBlock*)ValueMap[BB]; @@ -197,7 +194,7 @@ bool InlineMethod(BasicBlock::iterator CIIt) { if (PHI) RemapInstruction(PHI, ValueMap); // Fix the PHI node also... // Change the branch that used to go to NewBB to branch to the first basic - // block of the inlined method. + // block of the inlined function. // TerminatorInst *Br = OrigBB->getTerminator(); assert(Br && Br->getOpcode() == Instruction::Br && @@ -220,15 +217,15 @@ bool InlineMethod(CallInst *CI) { return InlineMethod(CallIt); } -static inline bool ShouldInlineMethod(const CallInst *CI, const Method *M) { +static inline bool ShouldInlineFunction(const CallInst *CI, const Function *F) { assert(CI->getParent() && CI->getParent()->getParent() && "Call not embedded into a method!"); // Don't inline a recursive call. - if (CI->getParent()->getParent() == M) return false; + if (CI->getParent()->getParent() == F) return false; // Don't inline something too big. This is a really crappy heuristic - if (M->size() > 3) return false; + if (F->size() > 3) return false; // Don't inline into something too big. This is a **really** crappy heuristic if (CI->getParent()->getParent()->size() > 10) return false; @@ -238,30 +235,30 @@ static inline bool ShouldInlineMethod(const CallInst *CI, const Method *M) { } -static inline bool DoMethodInlining(BasicBlock *BB) { +static inline bool DoFunctionInlining(BasicBlock *BB) { for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) { if (CallInst *CI = dyn_cast<CallInst>(*I)) { - // Check to see if we should inline this method - Method *F = CI->getCalledFunction(); - if (F && ShouldInlineMethod(CI, F)) + // Check to see if we should inline this function + Function *F = CI->getCalledFunction(); + if (F && ShouldInlineFunction(CI, F)) return InlineMethod(I); } } return false; } -// doMethodInlining - Use a heuristic based approach to inline methods that +// doFunctionInlining - Use a heuristic based approach to inline functions that // seem to look good. // -static bool doMethodInlining(Method *M) { +static bool doFunctionInlining(Function *F) { bool Changed = false; // Loop through now and inline instructions a basic block at a time... - for (Method::iterator I = M->begin(); I != M->end(); ) - if (DoMethodInlining(*I)) { + for (Function::iterator I = F->begin(); I != F->end(); ) + if (DoFunctionInlining(*I)) { Changed = true; // Iterator is now invalidated by new basic blocks inserted - I = M->begin(); + I = F->begin(); } else { ++I; } @@ -270,11 +267,11 @@ static bool doMethodInlining(Method *M) { } namespace { - struct MethodInlining : public MethodPass { - virtual bool runOnMethod(Method *M) { - return doMethodInlining(M); + struct FunctionInlining : public MethodPass { + virtual bool runOnMethod(Function *F) { + return doFunctionInlining(F); } }; } -Pass *createMethodInliningPass() { return new MethodInlining(); } +Pass *createMethodInliningPass() { return new FunctionInlining(); } diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index 1be6458fea..aa2cfdd218 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -1,8 +1,8 @@ //===-- ProfilePaths.cpp - interface to insert instrumentation ---*- C++ -*--=// // // This inserts intrumentation for counting -// execution of paths though a given method -// Its implemented as a "Method" Pass, and called using opt +// execution of paths though a given function +// Its implemented as a "Function" Pass, and called using opt // // This pass is implemented by using algorithms similar to // 1."Efficient Path Profiling": Ball, T. and Larus, J. R., @@ -18,7 +18,7 @@ // (code inserted through EdgeCode.cpp). // // The algorithm inserts code such that every acyclic path in the CFG -// of a method is identified through a unique number. the code insertion +// of a function is identified through a unique number. the code insertion // is optimal in the sense that its inserted over a minimal set of edges. Also, // the algorithm makes sure than initialization, path increment and counter // update can be collapsed into minmimum number of edges. @@ -27,7 +27,7 @@ #include "llvm/Transforms/Instrumentation/ProfilePaths.h" #include "llvm/Transforms/UnifyMethodExitNodes.h" #include "llvm/Support/CFG.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "llvm/ConstantVals.h" #include "llvm/DerivedTypes.h" @@ -39,10 +39,10 @@ using std::vector; class ProfilePaths: public MethodPass { public: - bool runOnMethod(Method *M); + bool runOnMethod(Function *M); // Before this pass, make sure that there is only one - // entry and only one exit node for the method in the CFG of the method + // entry and only one exit node for the function in the CFG of the function // void ProfilePaths::getAnalysisUsageInfo(Pass::AnalysisSet &Requires, Pass::AnalysisSet &Destroyed, @@ -67,8 +67,8 @@ static Node *findBB(std::set<Node *> &st, BasicBlock *BB){ return NULL; } -//Per method pass for inserting counters and trigger code -bool ProfilePaths::runOnMethod(Method *M){ +//Per function pass for inserting counters and trigger code +bool ProfilePaths::runOnMethod(Function *M){ //Transform the cfg s.t. we have just one exit node BasicBlock *ExitNode = getAnalysis<UnifyMethodExitNodes>().getExitNode(); @@ -83,7 +83,7 @@ bool ProfilePaths::runOnMethod(Method *M){ //That is, no two nodes must hav same BB* //First enter just nodes: later enter edges - for (Method::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){ + for (Function::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){ Node *nd=new Node(*BB); nodes.insert(nd); if(*BB==ExitNode) @@ -93,7 +93,7 @@ bool ProfilePaths::runOnMethod(Method *M){ } //now do it againto insert edges - for (Method::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){ + for (Function::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){ Node *nd=findBB(nodes, *BB); assert(nd && "No node for this edge!"); for(BasicBlock::succ_iterator s=succ_begin(*BB), se=succ_end(*BB); @@ -165,5 +165,5 @@ bool ProfilePaths::runOnMethod(Method *M){ processGraph(g, rVar, countVar, be, stDummy, exDummy); } - return true; // Always modifies method + return true; // Always modifies function } diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index de64793566..aecf78dc64 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -8,7 +8,7 @@ #include "llvm/Transforms/LevelChange.h" #include "TransformInternals.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/iOther.h" #include "llvm/iMemory.h" #include "llvm/ConstantVals.h" @@ -417,9 +417,9 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { -static bool DoRaisePass(Method *M) { +static bool DoRaisePass(Function *F) { bool Changed = false; - for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) { + for (Method::iterator MI = F->begin(), ME = F->end(); MI != ME; ++MI) { BasicBlock *BB = *MI; BasicBlock::InstListType &BIL = BB->getInstList(); @@ -445,9 +445,9 @@ static bool DoRaisePass(Method *M) { // RaisePointerReferences::doit - Raise a method representation to a higher // level. // -static bool doRPR(Method *M) { +static bool doRPR(Function *F) { #ifdef DEBUG_PEEPHOLE_INSTS - cerr << "\n\n\nStarting to work on Method '" << M->getName() << "'\n"; + cerr << "\n\n\nStarting to work on Function '" << F->getName() << "'\n"; #endif // Insert casts for all incoming pointer pointer values that are treated as @@ -457,13 +457,13 @@ static bool doRPR(Method *M) { do { #ifdef DEBUG_PEEPHOLE_INSTS - cerr << "Looping: \n" << M; + cerr << "Looping: \n" << F; #endif // Iterate over the method, refining it, until it converges on a stable // state LocalChange = false; - while (DoRaisePass(M)) LocalChange = true; + while (DoRaisePass(F)) LocalChange = true; Changed |= LocalChange; } while (LocalChange); @@ -473,7 +473,7 @@ static bool doRPR(Method *M) { namespace { struct RaisePointerReferences : public MethodPass { - virtual bool runOnMethod(Method *M) { return doRPR(M); } + virtual bool runOnMethod(Function *F) { return doRPR(F); } }; } diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index 624e6da39d..8818b5d967 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -24,7 +24,7 @@ #include "llvm/Transforms/Scalar/ConstantProp.h" #include "llvm/Transforms/Scalar/ConstantHandling.h" #include "llvm/Module.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" @@ -116,7 +116,7 @@ bool ConstantFoldTerminator(BasicBlock *BB, BasicBlock::iterator &II, BasicBlock *Destination = Cond->getValue() ? Dest1 : Dest2; BasicBlock *OldDest = Cond->getValue() ? Dest2 : Dest1; - //cerr << "Method: " << T->getParent()->getParent() + //cerr << "Function: " << T->getParent()->getParent() // << "\nRemoving branch from " << T->getParent() // << "\n\nTo: " << OldDest << endl; @@ -196,10 +196,10 @@ bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &II) { // DoConstPropPass - Propogate constants and do constant folding on instructions // this returns true if something was changed, false if nothing was changed. // -static bool DoConstPropPass(Method *M) { +static bool DoConstPropPass(Function *F) { bool SomethingChanged = false; - for (Method::iterator BBI = M->begin(); BBI != M->end(); ++BBI) { + for (Method::iterator BBI = F->begin(); BBI != F->end(); ++BBI) { BasicBlock *BB = *BBI; for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ) if (doConstantPropogation(BB, I)) @@ -212,11 +212,11 @@ static bool DoConstPropPass(Method *M) { namespace { struct ConstantPropogation : public MethodPass { - inline bool runOnMethod(Method *M) { + inline bool runOnMethod(Function *F) { bool Modified = false; // Fold constants until we make no progress... - while (DoConstPropPass(M)) Modified = true; + while (DoConstPropPass(F)) Modified = true; return Modified; } diff --git a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp index 09bfd5cf34..3a76d6a957 100644 --- a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp +++ b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp @@ -14,7 +14,7 @@ #include "llvm/iMemory.h" #include "llvm/iOther.h" #include "llvm/BasicBlock.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/Pass.h" @@ -149,12 +149,12 @@ decomposeArrayRef(BasicBlock::iterator& BBI) //--------------------------------------------------------------------------- static bool -doDecomposeMultiDimRefs(Method *M) +doDecomposeMultiDimRefs(Function *F) { bool changed = false; - for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) - for (BasicBlock::iterator newI, II=(*BI)->begin(); + for (Method::iterator BI = F->begin(), BE = F->end(); BI != BE; ++BI) + for (BasicBlock::iterator newI, II = (*BI)->begin(); II != (*BI)->end(); II = ++newI) { newI = II; @@ -172,7 +172,7 @@ doDecomposeMultiDimRefs(Method *M) namespace { struct DecomposeMultiDimRefsPass : public MethodPass { - virtual bool runOnMethod(Method *M) { return doDecomposeMultiDimRefs(M); } + virtual bool runOnMethod(Function *F) { return doDecomposeMultiDimRefs(F); } }; } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 1b0196e3e8..9bd95df508 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -16,7 +16,7 @@ #include "llvm/Transforms/Scalar/InstructionCombining.h" #include "llvm/Transforms/Scalar/ConstantHandling.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/iMemory.h" #include "llvm/InstrTypes.h" #include "llvm/Pass.h" @@ -147,8 +147,8 @@ static bool CombineInstruction(Instruction *I) { return true; } -static bool doInstCombining(Method *M) { - // Start the worklist out with all of the instructions in the method in it. +static bool doInstCombining(Function *M) { + // Start the worklist out with all of the instructions in the function in it. std::vector<Instruction*> WorkList(inst_begin(M), inst_end(M)); while (!WorkList.empty()) { @@ -172,7 +172,7 @@ static bool doInstCombining(Method *M) { namespace { struct InstructionCombining : public MethodPass { - virtual bool runOnMethod(Method *M) { return doInstCombining(M); } + virtual bool runOnMethod(Function *F) { return doInstCombining(F); } }; } diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index 8502082a15..a026fd673a 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -1,11 +1,11 @@ -//===- SymbolStripping.cpp - Code to string symbols for methods and modules -=// +//===- SymbolStripping.cpp - Strip symbols for functions and modules ------===// // // This file implements stripping symbols out of symbol tables. // // Specifically, this allows you to strip all of the symbols out of: -// * A method -// * All methods in a module -// * All symbols in a module (all method symbols + all module scope symbols) +// * A function +// * All functions in a module +// * All symbols in a module (all function symbols + all module scope symbols) // // Notice that: // * This pass makes code much less readable, so it should only be used in @@ -16,7 +16,7 @@ #include "llvm/Transforms/SymbolStripping.h" #include "llvm/Module.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/SymbolTable.h" #include "llvm/Pass.h" @@ -43,26 +43,26 @@ static bool StripSymbolTable(SymbolTable *SymTab) { } -// DoSymbolStripping - Remove all symbolic information from a method +// DoSymbolStripping - Remove all symbolic information from a function // -static bool doSymbolStripping(Method *M) { - return StripSymbolTable(M->getSymbolTable()); +static bool doSymbolStripping(Function *F) { + return StripSymbolTable(F->getSymbolTable()); } -// doStripGlobalSymbols - Remove all symbolic information from all methods -// in a module, and all module level symbols. (method names, etc...) +// doStripGlobalSymbols - Remove all symbolic information from all functions +// in a module, and all module level symbols. (function names, etc...) // static bool doStripGlobalSymbols(Module *M) { - // Remove all symbols from methods in this module... and then strip all of the - // symbols in this module... + // Remove all symbols from functions in this module... and then strip all of + // the symbols in this module... // return StripSymbolTable(M->getSymbolTable()); } namespace { struct SymbolStripping : public MethodPass { - virtual bool runOnMethod(Method *M) { - return doSymbolStripping(M); + virtual bool runOnMethod(Function *F) { + return doSymbolStripping(F); } }; diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index 796cdc7cb4..a75aa57bcc 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -6,7 +6,6 @@ //===----------------------------------------------------------------------===// #include "TransformInternals.h" -#include "llvm/Method.h" #include "llvm/Type.h" #include "llvm/ConstantVals.h" #include "llvm/Analysis/Expressions.h" diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index f94632e3df..79c03864d8 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -21,7 +21,7 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/iMemory.h" #include "llvm/Pass.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "llvm/Assembly/Writer.h" // For debugging #include "llvm/iPHINode.h" @@ -34,8 +34,8 @@ using cfg::DominanceFrontier; namespace { -//instance of the promoter -- to keep all the local method data. -// gets re-created for each method processed +//instance of the promoter -- to keep all the local function data. +// gets re-created for each function processed class PromoteInstance { protected: @@ -54,15 +54,15 @@ class PromoteInstance void traverse(BasicBlock *f, BasicBlock * predecessor); - bool PromoteMethod(Method *M, DominanceFrontier & DF); + bool PromoteFunction(Function *F, DominanceFrontier &DF); bool queuePhiNode(BasicBlock *bb, int alloca_index); - void findSafeAllocas(Method *M); + void findSafeAllocas(Function *M); bool didchange; public: // I do this so that I can force the deconstruction of the local variables - PromoteInstance(Method *M, DominanceFrontier & DF) + PromoteInstance(Function *F, DominanceFrontier &DF) { - didchange=PromoteMethod(M, DF); + didchange=PromoteFunction(F, DF); } //This returns whether the pass changes anything operator bool () { return didchange; } @@ -72,9 +72,9 @@ class PromoteInstance // findSafeAllocas - Find allocas that are safe to promote // -void PromoteInstance::findSafeAllocas(Method *M) +void PromoteInstance::findSafeAllocas(Function *F) { - BasicBlock *BB = M->front(); // Get the entry node for the method + BasicBlock *BB = F->getEntryNode(); // Get the entry node for the function // Look at all instructions in the entry node for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) @@ -107,9 +107,9 @@ void PromoteInstance::findSafeAllocas(Method *M) -bool PromoteInstance::PromoteMethod(Method *M, DominanceFrontier & DF) { +bool PromoteInstance::PromoteFunction(Function *F, DominanceFrontier & DF) { // Calculate the set of safe allocas - findSafeAllocas(M); + findSafeAllocas(F); // Add each alloca to the killlist // note: killlist is destroyed MOST recently added to least recently. @@ -158,10 +158,10 @@ bool PromoteInstance::PromoteMethod(Method *M, DominanceFrontier & DF) { } } - // Walks all basic blocks in the method + // Walks all basic blocks in the function // performing the SSA rename algorithm // and inserting the phi nodes we marked as necessary - BasicBlock * f = M->front(); //get root basic-block + BasicBlock * f = F->front(); //get root basic-block CurrentValue.push_back(vector<Value *>(Allocas.size())); @@ -309,16 +309,13 @@ bool PromoteInstance::queuePhiNode(BasicBlock *bb, int i /*the alloca*/) namespace { - class PromotePass : public MethodPass { - public: + struct PromotePass : public MethodPass { // runOnMethod - To run this pass, first we calculate the alloca // instructions that are safe for promotion, then we promote each one. // - virtual bool runOnMethod(Method *M) - { - PromoteInstance inst(M, getAnalysis<DominanceFrontier>()); - return (bool)inst; + virtual bool runOnMethod(Function *F) { + return (bool)PromoteInstance(F, getAnalysis<DominanceFrontier>()); } diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index da7b1f609a..9a3b52c49c 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -1,4 +1,4 @@ -//===- SimplifyCFG.cpp - CFG Simplification Routines -------------*- C++ -*--=// +//===- UnifyFunctionExitNodes.cpp - Make all functions have a single exit -===// // // This file provides several routines that are useful for simplifying CFGs in // various ways... @@ -7,7 +7,7 @@ #include "llvm/Transforms/UnifyMethodExitNodes.h" #include "llvm/BasicBlock.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" #include "llvm/Type.h" @@ -20,14 +20,14 @@ AnalysisID UnifyMethodExitNodes::ID(AnalysisID::create<UnifyMethodExitNodes>()); // BasicBlock, and converting all returns to unconditional branches to this // new basic block. The singular exit node is returned. // -// If there are no return stmts in the Method, a null pointer is returned. +// If there are no return stmts in the Function, a null pointer is returned. // -bool UnifyMethodExitNodes::doit(Method *M, BasicBlock *&ExitNode) { - // Loop over all of the blocks in a method, tracking all of the blocks that +bool UnifyMethodExitNodes::doit(Function *M, BasicBlock *&ExitNode) { + // Loop over all of the blocks in a function, tracking all of the blocks that // return. // vector<BasicBlock*> ReturningBlocks; - for(Method::iterator I = M->begin(), E = M->end(); I != E; ++I) + for(Function::iterator I = M->begin(), E = M->end(); I != E; ++I) if (isa<ReturnInst>((*I)->getTerminator())) ReturningBlocks.push_back(*I); @@ -39,14 +39,14 @@ bool UnifyMethodExitNodes::doit(Method *M, BasicBlock *&ExitNode) { return false; } - // Otherwise, we need to insert a new basic block into the method, add a PHI + // Otherwise, we need to insert a new basic block into the function, add a PHI // node (if the function returns a value), and convert all of the return // instructions into unconditional branches. // BasicBlock *NewRetBlock = new BasicBlock("UnifiedExitNode", M); if (M->getReturnType() != Type::VoidTy) { - // If the method doesn't return void... add a PHI node to the block... + // If the function doesn't return void... add a PHI node to the block... PHINode *PN = new PHINode(M->getReturnType()); NewRetBlock->getInstList().push_back(PN); |