diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-07 20:49:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-07 20:49:59 +0000 |
commit | 2fbfdcffd3e0cf41422aaa6c526c37cb02b81341 (patch) | |
tree | c1991eac5d23807b38e5909f861609b243562f70 | |
parent | dcc6d4cada290857ee74164816ec3c502c1db7a4 (diff) |
Change references to the Method class to be references to the Function
class. The Method class is obsolete (renamed) and all references to it
are being converted over to Function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2144 91177308-0d34-0410-b5e6-96231b3b80d8
57 files changed, 750 insertions, 788 deletions
diff --git a/include/llvm/Analysis/IntervalIterator.h b/include/llvm/Analysis/IntervalIterator.h index 3c27f1ae8b..55413d4ada 100644 --- a/include/llvm/Analysis/IntervalIterator.h +++ b/include/llvm/Analysis/IntervalIterator.h @@ -4,7 +4,7 @@ // graph of some sort. This iterator is parametric, allowing iterator over the // following types of graphs: // -// 1. A Method* object, composed of BasicBlock nodes. +// 1. A Function* object, composed of BasicBlock nodes. // 2. An IntervalPartition& object, composed of Interval nodes. // // This iterator is defined to walk the control flow graph, returning intervals @@ -27,7 +27,7 @@ #define LLVM_INTERVAL_ITERATOR_H #include "llvm/Analysis/IntervalPartition.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "llvm/Support/CFG.h" #include <stack> @@ -47,7 +47,7 @@ inline BasicBlock *getNodeHeader(Interval *I) { return I->getHeaderNode(); } // source graph node that corresponds to the BasicBlock. This is the opposite // of getNodeHeader. // -inline BasicBlock *getSourceGraphNode(Method *, BasicBlock *BB) { +inline BasicBlock *getSourceGraphNode(Function *, BasicBlock *BB) { return BB; } inline Interval *getSourceGraphNode(IntervalPartition *IP, BasicBlock *BB) { @@ -93,7 +93,7 @@ public: typedef std::forward_iterator_tag iterator_category; IntervalIterator() {} // End iterator, empty stack - IntervalIterator(Method *M, bool OwnMemory) : IOwnMem(OwnMemory) { + IntervalIterator(Function *M, bool OwnMemory) : IOwnMem(OwnMemory) { OrigContainer = M; if (!ProcessInterval(M->front())) { assert(0 && "ProcessInterval should never fail for first interval!"); @@ -227,16 +227,16 @@ private: } }; -typedef IntervalIterator<BasicBlock, Method> method_interval_iterator; +typedef IntervalIterator<BasicBlock, Function> function_interval_iterator; typedef IntervalIterator<Interval, IntervalPartition> interval_part_interval_iterator; -inline method_interval_iterator intervals_begin(Method *M, - bool DeleteInts = true) { - return method_interval_iterator(M, DeleteInts); +inline function_interval_iterator intervals_begin(Function *F, + bool DeleteInts = true) { + return function_interval_iterator(F, DeleteInts); } -inline method_interval_iterator intervals_end(Method *M) { - return method_interval_iterator(); +inline function_interval_iterator intervals_end(Function *) { + return function_interval_iterator(); } inline interval_part_interval_iterator diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h index b6aa56e385..db4c0c322e 100644 --- a/include/llvm/Support/CFG.h +++ b/include/llvm/Support/CFG.h @@ -1,6 +1,6 @@ //===-- llvm/Support/CFG.h - Process LLVM structures as graphs ---*- C++ -*--=// // -// This file defines specializations of GraphTraits that allow Methods and +// This file defines specializations of GraphTraits that allow Function and // BasicBlock graphs to be treated as proper graphs for generic algorithms. // //===----------------------------------------------------------------------===// @@ -9,7 +9,7 @@ #define LLVM_CFG_H #include "Support/GraphTraits.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "llvm/InstrTypes.h" #include <iterator> @@ -137,7 +137,7 @@ inline succ_const_iterator succ_end(const BasicBlock *BB) { // GraphTraits specializations for basic block graphs (CFGs) //===--------------------------------------------------------------------===// -// Provide specializations of GraphTraits to be able to treat a method as a +// Provide specializations of GraphTraits to be able to treat a function as a // graph of basic blocks... template <> struct GraphTraits<BasicBlock*> { @@ -167,9 +167,9 @@ template <> struct GraphTraits<const BasicBlock*> { } }; -// Provide specializations of GraphTraits to be able to treat a method as a +// Provide specializations of GraphTraits to be able to treat a function as a // graph of basic blocks... and to walk it in inverse order. Inverse order for -// a method is considered to be when traversing the predecessor edges of a BB +// a function is considered to be when traversing the predecessor edges of a BB // instead of the successor edges. // template <> struct GraphTraits<Inverse<BasicBlock*> > { @@ -201,34 +201,36 @@ template <> struct GraphTraits<Inverse<const BasicBlock*> > { //===--------------------------------------------------------------------===// -// GraphTraits specializations for method basic block graphs (CFGs) +// GraphTraits specializations for function basic block graphs (CFGs) //===--------------------------------------------------------------------===// -// Provide specializations of GraphTraits to be able to treat a method as a +// Provide specializations of GraphTraits to be able to treat a function as a // graph of basic blocks... these are the same as the basic block iterators, -// except that the root node is implicitly the first node of the method. +// except that the root node is implicitly the first node of the function. // -template <> struct GraphTraits<Method*> : public GraphTraits<BasicBlock*> { - static NodeType *getEntryNode(Method *M) { return M->front(); } +template <> struct GraphTraits<Function*> : public GraphTraits<BasicBlock*> { + static NodeType *getEntryNode(Function *F) { return F->getEntryNode(); } }; -template <> struct GraphTraits<const Method*> : +template <> struct GraphTraits<const Function*> : public GraphTraits<const BasicBlock*> { - static NodeType *getEntryNode(const Method *M) { return M->front(); } + static NodeType *getEntryNode(const Function *F) { return F->getEntryNode(); } }; -// Provide specializations of GraphTraits to be able to treat a method as a +// Provide specializations of GraphTraits to be able to treat a function as a // graph of basic blocks... and to walk it in inverse order. Inverse order for -// a method is considered to be when traversing the predecessor edges of a BB +// a function is considered to be when traversing the predecessor edges of a BB // instead of the successor edges. // -template <> struct GraphTraits<Inverse<Method*> > : +template <> struct GraphTraits<Inverse<Function*> > : public GraphTraits<Inverse<BasicBlock*> > { - static NodeType *getEntryNode(Inverse<Method *> G) { return G.Graph->front();} + static NodeType *getEntryNode(Inverse<Function*> G) { + return G.Graph->front(); + } }; -template <> struct GraphTraits<Inverse<const Method*> > : +template <> struct GraphTraits<Inverse<const Function*> > : public GraphTraits<Inverse<const BasicBlock*> > { - static NodeType *getEntryNode(Inverse<const Method *> G) { + static NodeType *getEntryNode(Inverse<const Function *> G) { return G.Graph->front(); } }; diff --git a/include/llvm/Support/InstIterator.h b/include/llvm/Support/InstIterator.h index 517e6d26a4..b2b1058056 100644 --- a/include/llvm/Support/InstIterator.h +++ b/include/llvm/Support/InstIterator.h @@ -1,7 +1,7 @@ //===-- llvm/Support/InstIterator.h - Classes for inst iteration -*- C++ -*--=// // // This file contains definitions of two iterators for iterating over the -// instructions in a method. This is effectively a wrapper around a two level +// instructions in a function. This is effectively a wrapper around a two level // iterator that can probably be genericized later. // // Note that this iterator gets invalidated any time that basic blocks or @@ -13,7 +13,7 @@ #define LLVM_INST_ITERATOR_H #include "llvm/BasicBlock.h" -#include "llvm/Method.h" +#include "llvm/Function.h" // This class is implements inst_begin() & inst_end() for // inst_iterator and const_inst_iterator's. @@ -96,20 +96,21 @@ private: }; -typedef InstIterator<ValueHolder<BasicBlock, Method, Method>, Method::iterator, - BasicBlock::iterator, Instruction*> inst_iterator; -typedef InstIterator<const ValueHolder<BasicBlock, Method, Method>, - Method::const_iterator, +typedef InstIterator<ValueHolder<BasicBlock, Function, Function>, + Function::iterator, BasicBlock::iterator, + Instruction*> inst_iterator; +typedef InstIterator<const ValueHolder<BasicBlock, Function, Function>, + Function::const_iterator, BasicBlock::const_iterator, const Instruction*> const_inst_iterator; -inline inst_iterator inst_begin(Method *M) { return inst_iterator(*M); } -inline inst_iterator inst_end(Method *M) { return inst_iterator(*M, true); } -inline const_inst_iterator inst_begin(const Method *M) { - return const_inst_iterator(*M); +inline inst_iterator inst_begin(Function *F) { return inst_iterator(*F); } +inline inst_iterator inst_end(Function *F) { return inst_iterator(*F, true); } +inline const_inst_iterator inst_begin(const Function *F) { + return const_inst_iterator(*F); } -inline const_inst_iterator inst_end(const Method *M) { - return const_inst_iterator(*M, true); +inline const_inst_iterator inst_end(const Function *F) { + return const_inst_iterator(*F, true); } #endif diff --git a/include/llvm/Transforms/Scalar/DCE.h b/include/llvm/Transforms/Scalar/DCE.h index a8dcb59146..35b929d7e7 100644 --- a/include/llvm/Transforms/Scalar/DCE.h +++ b/include/llvm/Transforms/Scalar/DCE.h @@ -8,7 +8,7 @@ #ifndef LLVM_TRANSFORMS_SCALAR_DCE_H #define LLVM_TRANSFORMS_SCALAR_DCE_H -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/BasicBlock.h" class Pass; @@ -60,6 +60,6 @@ Pass *createAgressiveDCEPass(); // // WARNING: The entry node of a method may not be simplified. // -bool SimplifyCFG(Method::iterator &BBIt); +bool SimplifyCFG(Function::iterator &BBIt); #endif diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index 0179cbb74c..d689d93cd4 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -1,4 +1,4 @@ -//===- SafePointerAccess.cpp - Check pointer usage safety -------------------=// +//===- FindUnsafePointerTypes.cpp - Check pointer usage safety --------------=// // // This file defines a pass that can be used to determine, interprocedurally, // which pointer types are accessed unsafely in a program. If there is an @@ -20,7 +20,7 @@ #include "llvm/Assembly/CachedWriter.h" #include "llvm/Type.h" #include "llvm/Instruction.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/Module.h" #include "llvm/Support/InstIterator.h" #include "Support/CommandLine.h" @@ -51,14 +51,10 @@ static inline bool isSafeInstruction(const Instruction *I) { } -// runOnMethod - Inspect the operations that the specified method does on -// values of various types. If they are deemed to be 'unsafe' note that the -// type is not safe to transform. -// bool FindUnsafePointerTypes::run(Module *Mod) { for (Module::iterator MI = Mod->begin(), ME = Mod->end(); MI != ME; ++MI) { - const Method *M = *MI; // We don't need/want write access + const Function *M = *MI; // We don't need/want write access for (const_inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I) { const Instruction *Inst = *I; const Type *ITy = Inst->getType(); diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index e67fe322f7..5c961d2beb 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -1,4 +1,4 @@ -//===- FindUsedTypes.h - Find all Types used by a module --------------------=// +//===- FindUsedTypes.cpp - Find all Types used by a module ------------------=// // // This pass is used to seek out all of the types in use by the program. // @@ -10,7 +10,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/Instruction.h" #include "llvm/Support/InstIterator.h" @@ -41,7 +41,7 @@ void FindUsedTypes::IncorporateSymbolTable(const SymbolTable *ST) { assert(0 && "Unimp"); } -// doPerMethodWork - This incorporates all types used by the specified method +// run - This incorporates all types used by the specified module // bool FindUsedTypes::run(Module *m) { UsedTypes.clear(); // reset if run multiple times... @@ -54,12 +54,12 @@ bool FindUsedTypes::run(Module *m) { IncorporateType((*I)->getType()); for (Module::iterator MI = m->begin(), ME = m->end(); MI != ME; ++MI) { - const Method *M = *MI; + const Function *M = *MI; if (IncludeSymbolTables && M->hasSymbolTable()) IncorporateSymbolTable(M->getSymbolTable()); // Add symtab first... - // Loop over all of the instructions in the method, adding their return type - // as well as the types of their operands. + // Loop over all of the instructions in the function, adding their return + // type as well as the types of their operands. // for (const_inst_iterator II = inst_begin(M), IE = inst_end(M); II != IE; ++II) { diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index f524d016f1..197bed26d7 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -1,7 +1,7 @@ //===- IntervalPartition.cpp - Interval Partition module code ----*- C++ -*--=// // // This file contains the definition of the cfg::IntervalPartition class, which -// calculates and represent the interval partition of a method. +// calculates and represent the interval partition of a function. // //===----------------------------------------------------------------------===// @@ -17,7 +17,7 @@ AnalysisID IntervalPartition::ID(AnalysisID::create<IntervalPartition>()); // IntervalPartition Implementation //===----------------------------------------------------------------------===// -// destroy - Reset state back to before method was analyzed +// destroy - Reset state back to before function was analyzed void IntervalPartition::destroy() { for_each(begin(), end(), deleter<cfg::Interval>); IntervalMap.clear(); @@ -50,14 +50,14 @@ void IntervalPartition::updatePredecessors(cfg::Interval *Int) { } // IntervalPartition ctor - Build the first level interval partition for the -// specified method... +// specified function... // -bool IntervalPartition::runOnMethod(Method *M) { +bool IntervalPartition::runOnMethod(Function *M) { assert(M->front() && "Cannot operate on prototypes!"); // Pass false to intervals_begin because we take ownership of it's memory - method_interval_iterator I = intervals_begin(M, false); - assert(I != intervals_end(M) && "No intervals in method!?!?!"); + function_interval_iterator I = intervals_begin(M, false); + assert(I != intervals_end(M) && "No intervals in function!?!?!"); addIntervalToPartition(RootInterval = *I); @@ -80,8 +80,8 @@ bool IntervalPartition::runOnMethod(Method *M) { // distinguish it from a copy constructor. Always pass in false for now. // IntervalPartition::IntervalPartition(IntervalPartition &IP, bool) { - Interval *MethodStart = IP.getRootInterval(); - assert(MethodStart && "Cannot operate on empty IntervalPartitions!"); + Interval *FunctionStart = IP.getRootInterval(); + assert(FunctionStart && "Cannot operate on empty IntervalPartitions!"); // Pass false to intervals_begin because we take ownership of it's memory interval_part_interval_iterator I = intervals_begin(IP, false); diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 48cc86fcaf..71ee3d74cf 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -1,12 +1,13 @@ //===- DominatorSet.cpp - Dominator Set Calculation --------------*- C++ -*--=// // -// This file provides a simple class to calculate the dominator set of a method. +// This file provides a simple class to calculate the dominator set of a +// function. // //===----------------------------------------------------------------------===// #include "llvm/Analysis/Dominators.h" #include "llvm/Transforms/UnifyMethodExitNodes.h" -#include "llvm/Method.h" +#include "llvm/Function.h" #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" @@ -21,31 +22,31 @@ using std::set; AnalysisID cfg::DominatorSet::ID(AnalysisID::create<cfg::DominatorSet>()); AnalysisID cfg::DominatorSet::PostDomID(AnalysisID::create<cfg::DominatorSet>()); -bool cfg::DominatorSet::runOnMethod(Method *M) { +bool cfg::DominatorSet::runOnMethod(Function *F) { Doms.clear(); // Reset from the last time we were run... if (isPostDominator()) - calcPostDominatorSet(M); + calcPostDominatorSet(F); else - calcForwardDominatorSet(M); + calcForwardDominatorSet(F); return false; } // calcForwardDominatorSet - This method calculates the forward dominator sets -// for the specified method. +// for the specified function. // -void cfg::DominatorSet::calcForwardDominatorSet(Method *M) { +void cfg::DominatorSet::calcForwardDominatorSet(Function *M) { Root = M->getEntryNode(); assert(pred_begin(Root) == pred_end(Root) && - "Root node has predecessors in method!"); + "Root node has predecessors in function!"); bool Changed; do { Changed = false; DomSetType WorkingSet; - df_iterator<Method*> It = df_begin(M), End = df_end(M); + df_iterator<Function*> It = df_begin(M), End = df_end(M); for ( ; It != End; ++It) { const BasicBlock *BB = *It; pred_const_iterator PI = pred_begin(BB), PEnd = pred_end(BB); @@ -75,19 +76,19 @@ void cfg::DominatorSet::calcForwardDominatorSet(Method *M) { } while (Changed); } -// Postdominator set constructor. This ctor converts the specified method to +// Postdominator set constructor. This ctor converts the specified function to // only have a single exit node (return stmt), then calculates the post -// dominance sets for the method. +// dominance sets for the function. // -void cfg::DominatorSet::calcPostDominatorSet(Method *M) { +void cfg::DominatorSet::calcPostDominatorSet(Function *M) { // Since we require that the unify all exit nodes pass has been run, we know - // that there can be at most one return instruction in the method left. + // that there can be at most one return instruction in the function left. // Get it. // Root = getAnalysis<UnifyMethodExitNodes>().getExitNode(); - if (Root == 0) { // No exit node for the method? Postdomsets are all empty - for (Method::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) + if (Root == 0) { // No exit node for the function? Postdomsets are all empty + for (Function::const_iterator MI = M->begin(), ME = M->end(); MI!=ME; ++MI) Doms[*MI] = DomSetType(); return; } @@ -207,12 +208,12 @@ void cfg::DominatorTree::reset() { // Given immediate dominators, we can also calculate the dominator tree cfg::DominatorTree::DominatorTree(const ImmediateDominators &IDoms) : DominatorBase(IDoms.getRoot()) { - const Method *M = Root->getParent(); + const Function *M = Root->getParent(); Nodes[Root] = new Node(Root, 0); // Add a node for the root... // Iterate over all nodes in depth first order... - for (df_iterator<const Method*> I = df_begin(M), E = df_end(M); I != E; ++I) { + for (df_iterator<const Function*> I = df_begin(M), E = df_end(M); I!=E; ++I) { const BasicBlock *BB = *I, *IDom = IDoms[*I]; if (IDom != 0) { // Ignore the root node and other nasty nodes @@ -249,7 +250,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) { // current node, and it is our idom! We know that we have already added // a DominatorTree node for our idom, because the idom must be a // predecessor in the depth first order that we are iterating through the - // method. + // function. // DominatorSet::DomSetType::const_iterator I = Dominators.begin(); DominatorSet::DomSetType::const_iterator End = Dominators.end( |