summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-27 06:56:12 +0000
committerChris Lattner <sabre@nondot.org>2002-04-27 06:56:12 +0000
commitf57b845547302d24ecb6a9e79d7bc386f761a6c9 (patch)
tree369bc5be013a3a6d0373dbf26820d701e01c5297 /include/llvm
parentf2361c5e5c2917e6f19a55927b221d8671753a40 (diff)
downloadllvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.gz
llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.bz2
llvm-f57b845547302d24ecb6a9e79d7bc386f761a6c9.tar.xz
* 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 'include/llvm')
-rw-r--r--include/llvm/Analysis/CallGraph.h9
-rw-r--r--include/llvm/Analysis/DataStructure.h9
-rw-r--r--include/llvm/Analysis/DataStructure/DataStructure.h9
-rw-r--r--include/llvm/Analysis/Dominators.h83
-rw-r--r--include/llvm/Analysis/FindUnsafePointerTypes.h17
-rw-r--r--include/llvm/Analysis/FindUsedTypes.h9
-rw-r--r--include/llvm/Analysis/IntervalPartition.h23
-rw-r--r--include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h25
-rw-r--r--include/llvm/Analysis/LoopInfo.h15
-rw-r--r--include/llvm/Assembly/PrintModulePass.h17
-rw-r--r--include/llvm/CodeGen/FunctionLiveVarInfo.h25
-rw-r--r--include/llvm/CodeGen/InstrScheduling.h4
-rw-r--r--include/llvm/CodeGen/RegisterAllocation.h3
-rw-r--r--include/llvm/Pass.h133
-rw-r--r--include/llvm/Transforms/FunctionInlining.h18
-rw-r--r--include/llvm/Transforms/Instrumentation/TraceValues.h4
-rw-r--r--include/llvm/Transforms/MutateStructTypes.h19
-rw-r--r--include/llvm/Transforms/Scalar/InductionVars.h12
-rw-r--r--include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h25
19 files changed, 232 insertions, 227 deletions
diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h
index 3c8b2c4107..61693876c4 100644
--- a/include/llvm/Analysis/CallGraph.h
+++ b/include/llvm/Analysis/CallGraph.h
@@ -118,11 +118,10 @@ public:
// run - Compute the call graph for the specified module.
virtual bool run(Module *TheModule);
- // getAnalysisUsageInfo - This obviously provides a call graph
- virtual void getAnalysisUsageInfo(AnalysisSet &Required,
- AnalysisSet &Destroyed,
- AnalysisSet &Provided) {
- Provided.push_back(ID);
+ // getAnalysisUsage - This obviously provides a call graph
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addProvided(ID);
}
// releaseMemory - Data structures can be large, so free memory agressively.
diff --git a/include/llvm/Analysis/DataStructure.h b/include/llvm/Analysis/DataStructure.h
index 2d21545aeb..90a4b5df23 100644
--- a/include/llvm/Analysis/DataStructure.h
+++ b/include/llvm/Analysis/DataStructure.h
@@ -485,11 +485,10 @@ public:
// If the pass pipeline is done with this pass, we can release our memory...
virtual void releaseMemory();
- // getAnalysisUsageInfo - This obviously provides a call graph
- virtual void getAnalysisUsageInfo(AnalysisSet &Required,
- AnalysisSet &Destroyed,
- AnalysisSet &Provided) {
- Provided.push_back(ID);
+ // getAnalysisUsage - This obviously provides a call graph
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addProvided(ID);
}
};
diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h
index 2d21545aeb..90a4b5df23 100644
--- a/include/llvm/Analysis/DataStructure/DataStructure.h
+++ b/include/llvm/Analysis/DataStructure/DataStructure.h
@@ -485,11 +485,10 @@ public:
// If the pass pipeline is done with this pass, we can release our memory...
virtual void releaseMemory();
- // getAnalysisUsageInfo - This obviously provides a call graph
- virtual void getAnalysisUsageInfo(AnalysisSet &Required,
- AnalysisSet &Destroyed,
- AnalysisSet &Provided) {
- Provided.push_back(ID);
+ // getAnalysisUsage - This obviously provides a call graph
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addProvided(ID);
}
};
diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h
index d860ec5504..1f35331b92 100644
--- a/include/llvm/Analysis/Dominators.h
+++ b/include/llvm/Analysis/Dominators.h
@@ -1,13 +1,13 @@
//===- llvm/Analysis/Dominators.h - Dominator Info Calculation ---*- C++ -*--=//
//
// This file defines the following classes:
-// 1. DominatorSet: Calculates the [reverse] dominator set for a method
+// 1. DominatorSet: Calculates the [reverse] dominator set for a function
// 2. ImmediateDominators: Calculates and holds a mapping between BasicBlocks
// and their immediate dominator.
// 3. DominatorTree: Represent the ImmediateDominator as an explicit tree
// structure.
// 4. DominanceFrontier: Calculate and hold the dominance frontier for a
-// method.
+// function.
//
// These data structures are listed in increasing order of complexity. It
// takes longer to calculate the dominator frontier, for example, than the
@@ -28,7 +28,7 @@ namespace cfg {
// DominatorBase - Base class that other, more interesting dominator analyses
// inherit from.
//
-class DominatorBase : public MethodPass {
+class DominatorBase : public FunctionPass {
protected:
BasicBlock *Root;
const bool IsPostDominators;
@@ -45,7 +45,7 @@ public:
//===----------------------------------------------------------------------===//
//
// DominatorSet - Maintain a set<const BasicBlock*> for every basic block in a
-// method, that represents the blocks that dominate the block.
+// function, that represents the blocks that dominate the block.
//
class DominatorSet : public DominatorBase {
public:
@@ -59,14 +59,14 @@ private:
void calcPostDominatorSet(Function *F);
public:
// DominatorSet ctor - Build either the dominator set or the post-dominator
- // set for a method...
+ // set for a function...
//
static AnalysisID ID; // Build dominator set
static AnalysisID PostDomID; // Build postdominator set
DominatorSet(AnalysisID id) : DominatorBase(id == PostDomID) {}
- virtual bool runOnMethod(Function *F);
+ virtual bool runOnFunction(Function *F);
// Accessor interface:
typedef DomSetMapType::const_iterator const_iterator;
@@ -83,7 +83,7 @@ public:
//
inline const DomSetType &getDominators(const BasicBlock *BB) const {
const_iterator I = find(BB);
- assert(I != end() && "BB not in method!");
+ assert(I != end() && "BB not in function!");
return I->second;
}
@@ -93,19 +93,17 @@ public:
return getDominators(B).count(A) != 0;
}
- // getAnalysisUsageInfo - This obviously provides a dominator set, but it also
- // uses the UnifyMethodExitNode pass if building post-dominators
+ // getAnalysisUsage - This obviously provides a dominator set, but it also
+ // uses the UnifyFunctionExitNode pass if building post-dominators
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided);
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const;
};
//===----------------------------------------------------------------------===//
//
// ImmediateDominators - Calculate the immediate dominator for each node in a
-// method.
+// function.
//
class ImmediateDominators : public DominatorBase {
std::map<const BasicBlock*, const BasicBlock*> IDoms;
@@ -113,14 +111,14 @@ class ImmediateDominators : public DominatorBase {
public:
// ImmediateDominators ctor - Calculate the idom or post-idom mapping,
- // for a method...
+ // for a function...
//
static AnalysisID ID; // Build immediate dominators
static AnalysisID PostDomID; // Build immediate postdominators
ImmediateDominators(AnalysisID id) : DominatorBase(id == PostDomID) {}
- virtual bool runOnMethod(Function *F) {
+ virtual bool runOnFunction(Function *F) {
IDoms.clear(); // Reset from the last time we were run...
DominatorSet *DS;
if (isPostDominator())
@@ -149,18 +147,17 @@ public:
return I != IDoms.end() ? I->second : 0;
}
- // getAnalysisUsageInfo - This obviously provides a dominator tree, but it
+ // getAnalysisUsage - This obviously provides a dominator tree, but it
// can only do so with the input of dominator sets
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided) {
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
if (isPostDominator()) {
- Requires.push_back(DominatorSet::PostDomID);
- Provided.push_back(PostDomID);
+ AU.addRequired(DominatorSet::PostDomID);
+ AU.addProvided(PostDomID);
} else {
- Requires.push_back(DominatorSet::ID);
- Provided.push_back(ID);
+ AU.addRequired(DominatorSet::ID);
+ AU.addProvided(ID);
}
}
};
@@ -168,7 +165,7 @@ public:
//===----------------------------------------------------------------------===//
//
-// DominatorTree - Calculate the immediate dominator tree for a method.
+// DominatorTree - Calculate the immediate dominator tree for a function.
//
class DominatorTree : public DominatorBase {
class Node2;
@@ -213,7 +210,7 @@ public:
DominatorTree(AnalysisID id) : DominatorBase(id == PostDomID) {}
~DominatorTree() { reset(); }
- virtual bool runOnMethod(Function *F) {
+ virtual bool runOnFunction(Function *F) {
reset();
DominatorSet *DS;
if (isPostDominator())
@@ -230,18 +227,17 @@ public:
return (i != Nodes.end()) ? i->second : 0;
}
- // getAnalysisUsageInfo - This obviously provides a dominator tree, but it
+ // getAnalysisUsage - This obviously provides a dominator tree, but it
// uses dominator sets
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided) {
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
if (isPostDominator()) {
- Requires.push_back(DominatorSet::PostDomID);
- Provided.push_back(PostDomID);
+ AU.addRequired(DominatorSet::PostDomID);
+ AU.addProvided(PostDomID);
} else {
- Requires.push_back(DominatorSet::ID);
- Provided.push_back(ID);
+ AU.addRequired(DominatorSet::ID);
+ AU.addProvided(ID);
}
}
};
@@ -249,7 +245,7 @@ public:
//===----------------------------------------------------------------------===//
//
-// DominanceFrontier - Calculate the dominance frontiers for a method.
+// DominanceFrontier - Calculate the dominance frontiers for a function.
//
class DominanceFrontier : public DominatorBase {
public:
@@ -263,14 +259,14 @@ private:
const DominatorTree::Node *Node);
public:
- // DominatorFrontier ctor - Compute dominator frontiers for a method
+ // DominatorFrontier ctor - Compute dominator frontiers for a function
//
static AnalysisID ID; // Build dominator frontier
static AnalysisID PostDomID; // Build postdominator frontier
DominanceFrontier(AnalysisID id) : DominatorBase(id == PostDomID) {}
- virtual bool runOnMethod(Function *) {
+ virtual bool runOnFunction(Function *) {
Frontiers.clear();
DominatorTree *DT;
if (isPostDominator())
@@ -292,18 +288,17 @@ public:
inline const_iterator end() const { return Frontiers.end(); }
inline const_iterator find(const BasicBlock* B) const { return Frontiers.find(B); }
- // getAnalysisUsageInfo - This obviously provides a dominator tree, but it
+ // getAnalysisUsage - This obviously provides the dominance frontier, but it
// uses dominator sets
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided) {
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
if (isPostDominator()) {
- Requires.push_back(DominatorTree::PostDomID);
- Provided.push_back(PostDomID);
+ AU.addRequired(DominatorTree::PostDomID);
+ AU.addProvided(PostDomID);
} else {
- Requires.push_back(DominatorTree::ID);
- Provided.push_back(ID);
+ AU.addRequired(DominatorTree::ID);
+ AU.addProvided(ID);
}
}
};
diff --git a/include/llvm/Analysis/FindUnsafePointerTypes.h b/include/llvm/Analysis/FindUnsafePointerTypes.h
index cd34676727..82cc28a06f 100644
--- a/include/llvm/Analysis/FindUnsafePointerTypes.h
+++ b/include/llvm/Analysis/FindUnsafePointerTypes.h
@@ -1,4 +1,4 @@
-//===- llvm/Analysis/SafePointerAccess.h - Check pointer safety ---*- C++ -*-=//
+//===- llvm/Analysis/FindUnsafePointerTypes.h - Unsafe pointers ---*- C++ -*-=//
//
// 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
@@ -10,12 +10,12 @@
//
// Additionally, this analysis exports a hidden command line argument that (when
// enabled) prints out the reasons a type was determined to be unsafe. Just add
-// -unsafeptrinst to the command line of the tool you want to get it.
+// -printunsafeptrinst to the command line of the tool you want to get it.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_ANALYSIS_SAFEPOINTERACCESS_H
-#define LLVM_ANALYSIS_SAFEPOINTERACCESS_H
+#ifndef LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
+#define LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
#include "llvm/Pass.h"
#include <set>
@@ -46,11 +46,12 @@ public:
//
void printResults(const Module *Mod, std::ostream &o) const;
- // getAnalysisUsageInfo - This function needs FindUsedTypes to do its job...
+ // getAnalysisUsage - Of course, we provide ourself...
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided);
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addProvided(ID);
+ }
};
#endif
diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h
index bbaf8dff6b..5c02b2cc5f 100644
--- a/include/llvm/Analysis/FindUsedTypes.h
+++ b/include/llvm/Analysis/FindUsedTypes.h
@@ -52,11 +52,12 @@ public:
//
bool run(Module *M);
- // getAnalysisUsageInfo - This function needs FindUsedTypes to do its job...
+ // getAnalysisUsage - Of course, we provide ourself...
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided);
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addProvided(ID);
+ }
};
#endif
diff --git a/include/llvm/Analysis/IntervalPartition.h b/include/llvm/Analysis/IntervalPartition.h
index 10f53173bc..d31b5fd750 100644
--- a/include/llvm/Analysis/IntervalPartition.h
+++ b/include/llvm/Analysis/IntervalPartition.h
@@ -1,7 +1,7 @@
//===- IntervalPartition.h - Interval partition Calculation ------*- C++ -*--=//
//
// This file contains the declaration of the cfg::IntervalPartition class, which
-// calculates and represents the interval partition of a method, or a
+// calculates and represents the interval partition of a function, or a
// preexisting interval partition.
//
// In this way, the interval partition may be used to reduce a flow graph down
@@ -24,12 +24,12 @@ namespace cfg {
//===----------------------------------------------------------------------===//
//
// IntervalPartition - This class builds and holds an "interval partition" for
-// a method. This partition divides the control flow graph into a set of
+// a function. This partition divides the control flow graph into a set of
// maximal intervals, as defined with the properties above. Intuitively, a
// BasicBlock is a (possibly nonexistent) loop with a "tail" of non looping
// nodes following it.
//
-class IntervalPartition : public MethodPass, public std::vector<Interval*> {
+class IntervalPartition : public FunctionPass, public std::vector<Interval*> {
typedef std::map<BasicBlock*, Interval*> IntervalMapTy;
IntervalMapTy IntervalMap;
@@ -41,8 +41,8 @@ public:
IntervalPartition(AnalysisID AID) : RootInterval(0) { assert(AID == ID); }
- // run - Calculate the interval partition for this method
- virtual bool runOnMethod(Function *F);
+ // run - Calculate the interval partition for this function
+ virtual bool runOnFunction(Function *F);
// IntervalPartition ctor - Build a reduced interval partition from an
// existing interval graph. This takes an additional boolean parameter to
@@ -54,7 +54,7 @@ public:
~IntervalPartition() { destroy(); }
// getRootInterval() - Return the root interval that contains the starting
- // block of the method.
+ // block of the function.
inline Interval *getRootInterval() { return RootInterval; }
// isDegeneratePartition() - Returns true if the interval partition contains
@@ -69,15 +69,14 @@ public:
return I != IntervalMap.end() ? I->second : 0;
}
- // getAnalysisUsageInfo - Implement the Pass API
- virtual void getAnalysisUsageInfo(AnalysisSet &Required,
- AnalysisSet &Destroyed,
- AnalysisSet &Provided) {
- Provided.push_back(ID);
+ // getAnalysisUsage - Implement the Pass API
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addProvided(ID);
}
private:
- // destroy - Reset state back to before method was analyzed
+ // destroy - Reset state back to before function was analyzed
void destroy();
// addIntervalToPartition - Add an interval to the internal list of intervals,
diff --git a/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h b/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
index 435f177045..eabae4bddc 100644
--- a/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
+++ b/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
@@ -1,15 +1,15 @@
-/* Title: MethodLiveVarInfo.h -*- C++ -*-
+/* Title: FunctionLiveVarInfo.h -*- C++ -*-
Author: Ruchira Sasanka
Date: Jun 30, 01
Purpose:
- This is the interface for live variable info of a method that is required
+ This is the interface for live variable info of a function that is required
by any other part of the compiler
It must be called like:
- MethodLiveVarInfo MLVI(Function *); // initializes data structures
- MLVI.analyze(); // do the actural live variable anal
+ FunctionLiveVarInfo FLVI(Function *); // initializes data structures
+ FLVI.analyze(); // do the actural live variable anal
After the analysis, getInSetOfBB or getOutSetofBB can be called to get
live var info of a BB.
@@ -79,7 +79,7 @@ enum LiveVarDebugLevel_t {
extern cl::Enum<LiveVarDebugLevel_t> DEBUG_LV;
-class MethodLiveVarInfo : public MethodPass {
+class MethodLiveVarInfo : public FunctionPass {
// Machine Instr to LiveVarSet Map for providing LVset BEFORE each inst
std::map<const MachineInstr *, const ValueSet *> MInst2LVSetBI;
@@ -105,19 +105,18 @@ public:
MethodLiveVarInfo(AnalysisID id = ID) { assert(id == ID); }
- // --------- Implement the MethodPass interface ----------------------
+ // --------- Implement the FunctionPass interface ----------------------
- // runOnMethod - Perform analysis, update internal data structures.
- virtual bool runOnMethod(Function *F);
+ // runOnFunction - Perform analysis, update internal data structures.
+ virtual bool runOnFunction(Function *F);
// releaseMemory - After LiveVariable analysis has been used, forget!
virtual void releaseMemory();
- // getAnalysisUsageInfo - Provide self!
- virtual void getAnalysisUsageInfo(AnalysisSet &Required,
- AnalysisSet &Destroyed,
- AnalysisSet &Provided) {
- Provided.push_back(ID);
+ // getAnalysisUsage - Provide self!
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addProvided(ID);
}
// --------- Functions to access analysis results -------------------
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h
index 5b6000d450..6c9468c7d3 100644
--- a/include/llvm/Analysis/LoopInfo.h
+++ b/include/llvm/Analysis/LoopInfo.h
@@ -62,9 +62,9 @@ private:
//===----------------------------------------------------------------------===//
// LoopInfo - This class builds and contains all of the top level loop
-// structures in the specified method.
+// structures in the specified function.
//
-class LoopInfo : public MethodPass {
+class LoopInfo : public FunctionPass {
// BBMap - Mapping of basic blocks to the inner most loop they occur in
std::map<const BasicBlock *, Loop*> BBMap;
std::vector<Loop*> TopLevelLoops;
@@ -105,16 +105,15 @@ public:
bool isLoopExit(const BasicBlock *BB) const;
#endif
- // runOnMethod - Pass framework implementation
- virtual bool runOnMethod(Function *F);
+ // runOnFunction - Pass framework implementation
+ virtual bool runOnFunction(Function *F);
virtual void releaseMemory();
- // getAnalysisUsageInfo - Provide loop info, require dominator set
+ // getAnalysisUsage - Provide loop info, require dominator set
//
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided);
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const;
+
private:
void Calculate(const DominatorSet &DS);
Loop *ConsiderForLoop(const BasicBlock *BB, const DominatorSet &DS);
diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h
index eceaf3a888..fbab4e4a45 100644
--- a/include/llvm/Assembly/PrintModulePass.h
+++ b/include/llvm/Assembly/PrintModulePass.h
@@ -1,9 +1,10 @@
//===- llvm/Assembly/PrintModulePass.h - Printing Pass -----------*- C++ -*--=//
//
-// This file defines two passes to print out a module. The PrintModulePass
-// pass simply prints out the entire module when it is executed. The
-// PrintMethodPass class is designed to be pipelined with other MethodPass's,
-// and prints out the methods of the class as they are processed.
+// This file defines two passes to print out a module. The PrintModulePass pass
+// simply prints out the entire module when it is executed. The
+// PrintFunctionPass class is designed to be pipelined with other
+// FunctionPass's, and prints out the functions of the class as they are
+// processed.
//
//===----------------------------------------------------------------------===//
@@ -32,8 +33,8 @@ public:
}
};
-class PrintFunctionPass : public MethodPass {
- std::string Banner; // String to print before each method
+class PrintFunctionPass : public FunctionPass {
+ std::string Banner; // String to print before each function
std::ostream *Out; // ostream to print on
bool DeleteStream; // Delete the ostream in our dtor?
public:
@@ -46,10 +47,10 @@ public:
if (DeleteStream) delete Out;
}
- // runOnMethod - This pass just prints a banner followed by the method as
+ // runOnFunction - This pass just prints a banner followed by the function as
// it's processed.
//
- bool runOnMethod(Function *F) {
+ bool runOnFunction(Function *F) {
(*Out) << Banner << (Value*)F;
return false;
}
diff --git a/include/llvm/CodeGen/FunctionLiveVarInfo.h b/include/llvm/CodeGen/FunctionLiveVarInfo.h
index 435f177045..eabae4bddc 100644
--- a/include/llvm/CodeGen/FunctionLiveVarInfo.h
+++ b/include/llvm/CodeGen/FunctionLiveVarInfo.h
@@ -1,15 +1,15 @@
-/* Title: MethodLiveVarInfo.h -*- C++ -*-
+/* Title: FunctionLiveVarInfo.h -*- C++ -*-
Author: Ruchira Sasanka
Date: Jun 30, 01
Purpose:
- This is the interface for live variable info of a method that is required
+ This is the interface for live variable info of a function that is required
by any other part of the compiler
It must be called like:
- MethodLiveVarInfo MLVI(Function *); // initializes data structures
- MLVI.analyze(); // do the actural live variable anal
+ FunctionLiveVarInfo FLVI(Function *); // initializes data structures
+ FLVI.analyze(); // do the actural live variable anal
After the analysis, getInSetOfBB or getOutSetofBB can be called to get
live var info of a BB.
@@ -79,7 +79,7 @@ enum LiveVarDebugLevel_t {
extern cl::Enum<LiveVarDebugLevel_t> DEBUG_LV;
-class MethodLiveVarInfo : public MethodPass {
+class MethodLiveVarInfo : public FunctionPass {
// Machine Instr to LiveVarSet Map for providing LVset BEFORE each inst
std::map<const MachineInstr *, const ValueSet *> MInst2LVSetBI;
@@ -105,19 +105,18 @@ public:
MethodLiveVarInfo(AnalysisID id = ID) { assert(id == ID); }
- // --------- Implement the MethodPass interface ----------------------
+ // --------- Implement the FunctionPass interface ----------------------
- // runOnMethod - Perform analysis, update internal data structures.
- virtual bool runOnMethod(Function *F);
+ // runOnFunction - Perform analysis, update internal data structures.
+ virtual bool runOnFunction(Function *F);
// releaseMemory - After LiveVariable analysis has been used, forget!
virtual void releaseMemory();
- // getAnalysisUsageInfo - Provide self!
- virtual void getAnalysisUsageInfo(AnalysisSet &Required,
- AnalysisSet &Destroyed,
- AnalysisSet &Provided) {
- Provided.push_back(ID);
+ // getAnalysisUsage - Provide self!
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ AU.addProvided(ID);
}
// --------- Functions to access analysis results -------------------
diff --git a/include/llvm/CodeGen/InstrScheduling.h b/include/llvm/CodeGen/InstrScheduling.h
index 4ca4086b60..d740f1892b 100644
--- a/include/llvm/CodeGen/InstrScheduling.h
+++ b/include/llvm/CodeGen/InstrScheduling.h
@@ -8,7 +8,7 @@
#ifndef LLVM_CODEGEN_INSTR_SCHEDULING_H
#define LLVM_CODEGEN_INSTR_SCHEDULING_H
-class MethodPass;
+class Pass;
class TargetMachine;
//---------------------------------------------------------------------------
@@ -21,7 +21,7 @@ class TargetMachine;
// are still in SSA form.
//---------------------------------------------------------------------------
-MethodPass *createInstructionSchedulingWithSSAPass(const TargetMachine &Target);
+Pass *createInstructionSchedulingWithSSAPass(const TargetMachine &Target);
//---------------------------------------------------------------------------
diff --git a/include/llvm/CodeGen/RegisterAllocation.h b/include/llvm/CodeGen/RegisterAllocation.h
index e552fbe887..2227f8eaab 100644
--- a/include/llvm/CodeGen/RegisterAllocation.h
+++ b/include/llvm/CodeGen/RegisterAllocation.h
@@ -9,12 +9,11 @@
#include "llvm/Pass.h"
class TargetMachine;
-class MethodPass;
//----------------------------------------------------------------------------
// Entry point for register allocation for a module
//----------------------------------------------------------------------------
-MethodPass *getRegisterAllocator(TargetMachine &T);
+Pass *getRegisterAllocator(TargetMachine &T);
#endif
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h
index af68d42eb7..0fcf6b33ec 100644
--- a/include/llvm/Pass.h
+++ b/include/llvm/Pass.h
@@ -10,8 +10,8 @@
//
// Passes should extend one of the classes below, depending on the guarantees
// that it can make about what will be modified as it is run. For example, most
-// global optimizations should derive from MethodPass, because they do not add
-// or delete methods, they operate on the internals of the method.
+// global optimizations should derive from FunctionPass, because they do not add
+// or delete functionss, they operate on the internals of the function.
//
//===----------------------------------------------------------------------===//
@@ -24,6 +24,7 @@ class Value;
class BasicBlock;
class Function;
class Module;
+class AnalysisUsage;
class AnalysisID;
class Pass;
template<class UnitType> class PassManagerT;
@@ -33,7 +34,6 @@ struct AnalysisResolver;
// Implemented in PassManager.h
typedef PassManagerT<Module> PassManager;
-
//===----------------------------------------------------------------------===//
// Pass interface - Implemented by all 'passes'. Subclass this if you are an
// interprocedural optimization or you do not fit into any of the more
@@ -43,8 +43,6 @@ class Pass {
friend class AnalysisResolver;
AnalysisResolver *Resolver; // AnalysisResolver this pass is owned by...
public:
- typedef std::vector<AnalysisID> AnalysisSet;
-
inline Pass(AnalysisResolver *AR = 0) : Resolver(AR) {}
inline virtual ~Pass() {} // Destructor is virtual so we can be subclassed
@@ -54,24 +52,13 @@ public:
//
virtual bool run(Module *M) = 0;
- // getAnalysisUsageInfo - This function should be overriden by passes that
- // need analysis information to do their job. If a pass specifies that it
- // uses a particular analysis result to this function, it can then use the
+ // getAnalysisUsage - This function should be overriden by passes that need
+ // analysis information to do their job. If a pass specifies that it uses a
+ // particular analysis result to this function, it can then use the
// getAnalysis<AnalysisType>() function, below.
//
- // The Destroyed vector is used to communicate what analyses are invalidated
- // by this pass. This is critical to specify so that the PassManager knows
- // which analysis must be rerun after this pass has proceeded. Analysis are
- // only invalidated if run() returns true.
- //
- // The Provided vector is used for passes that provide analysis information,
- // these are the analysis passes themselves. All analysis passes should
- // override this method to return themselves in the provided set.
- //
- virtual void getAnalysisUsageInfo(AnalysisSet &Required,
- AnalysisSet &Destroyed,
- AnalysisSet &Provided) {
- // By default, no analysis results are used or destroyed.
+ virtual void getAnalysisUsage(AnalysisUsage &Info) const {
+ // By default, no analysis results are used, all are invalidated.
}
// releaseMemory() - This member can be implemented by a pass if it wants to
@@ -93,7 +80,7 @@ public:
protected:
// getAnalysis<AnalysisType>() - This function is used by subclasses to get to
// the analysis information that they claim to use by overriding the
- // getAnalysisUsageInfo function.
+ // getAnalysisUsage function.
//
template<typename AnalysisType>
AnalysisType &getAnalysis(AnalysisID AID = AnalysisType::ID) {
@@ -118,52 +105,50 @@ private:
friend class PassManagerT<Module>;
friend class PassManagerT<Function>;
friend class PassManagerT<BasicBlock>;
- virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisSet &Req,
- AnalysisSet &Destroyed, AnalysisSet &Provided);
+ virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU);
};
//===----------------------------------------------------------------------===//
-// MethodPass class - This class is used to implement most global optimizations.
-// Optimizations should subclass this class if they meet the following
-// constraints:
-// 1. Optimizations are organized globally, ie a method at a time
-// 2. Optimizing a method does not cause the addition or removal of any methods
-// in the module
+// FunctionPass class - This class is used to implement most global
+// optimizations. Optimizations should subclass this class if they meet the
+// following constraints:
+//
+// 1. Optimizations are organized globally, ie a function at a time
+// 2. Optimizing a function does not cause the addition or removal of any
+// functions in the module
//
-struct MethodPass : public Pass {
+struct FunctionPass : public Pass {
// doInitialization - Virtual method overridden by subclasses to do
// any neccesary per-module initialization.
//
virtual bool doInitialization(Module *M) { return false; }
- // runOnMethod - Virtual method overriden by subclasses to do the per-method
- // processing of the pass.
+ // runOnFunction - Virtual method overriden by subclasses to do the
+ // per-function processing of the pass.
//
- virtual bool runOnMethod(Function *M) = 0;
+ virtual bool runOnFunction(Function *F) = 0;
// doFinalization - Virtual method overriden by subclasses to do any post
// processing needed after all passes have run.
//
virtual bool doFinalization(Module *M) { return false; }
- // run - On a module, we run this pass by initializing, ronOnMethod'ing once
- // for every method in the module, then by finalizing.
+ // run - On a module, we run this pass by initializing, ronOnFunction'ing once
+ // for every function in the module, then by finalizing.
//
virtual bool run(Module *M);
- // run - On a method, we simply initialize, run the method, then finalize.
+ // run - On a function, we simply initialize, run the function, then finalize.
//
- bool run(Function *M);
+ bool run(Function *F);
private:
friend class PassManagerT<Module>;
friend class PassManagerT<Function>;
friend class PassManagerT<BasicBlock>;
- virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisSet &Req,
- AnalysisSet &Dest, AnalysisSet &Prov);
- virtual void addToPassManager(PassManagerT<Function> *PM,AnalysisSet &Req,
- AnalysisSet &Dest, AnalysisSet &Prov);
+ virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU);
+ virtual void addToPassManager(PassManagerT<Function> *PM, AnalysisUsage &AU);
};
@@ -174,20 +159,20 @@ private:
// meet the following constraints:
// 1. Optimizations are local, operating on either a basic block or
// instruction at a time.
-// 2. Optimizations do not modify the CFG of the contained method, or any
-// other basic block in the method.
-// 3. Optimizations conform to all of the contstraints of MethodPass's.
+// 2. Optimizations do not modify the CFG of the contained function, or any
+// other basic block in the function.
+// 3. Optimizations conform to all of the contstraints of FunctionPass's.
//
-struct BasicBlockPass : public MethodPass {
+struct BasicBlockPass : public FunctionPass {
// runOnBasicBlock - Virtual method overriden by subclasses to do the
// per-basicblock processing of the pass.
//
virtual bool runOnBasicBlock(BasicBlock *M) = 0;
- // To run this pass on a method, we simply call runOnBasicBlock once for each
- // method.
+ // To run this pass on a function, we simply call runOnBasicBlock once for
+ // each function.
//
- virtual bool runOnMethod(Function *F);
+ virtual bool runOnFunction(Function *F);
// To run directly on the basic block, we initialize, runOnBasicBlock, then
// finalize.
@@ -197,10 +182,8 @@ struct BasicBlockPass : public MethodPass {
private:
friend class PassManagerT<Function>;
friend class PassManagerT<BasicBlock>;
- virtual void addToPassManager(PassManagerT<Function> *PM, AnalysisSet &,
- AnalysisSet &, AnalysisSet &);
- virtual void addToPassManager(PassManagerT<BasicBlock> *PM, AnalysisSet &,
- AnalysisSet &, AnalysisSet &);
+ virtual void addToPassManager(PassManagerT<Function> *PM, AnalysisUsage &AU);
+ virtual void addToPassManager(PassManagerT<BasicBlock> *PM,AnalysisUsage &AU);
};
@@ -249,6 +232,50 @@ public:
}
};
+//===----------------------------------------------------------------------===//
+// AnalysisUsage - Represent the analysis usage information of a pass. This
+// tracks analyses that the pass REQUIRES (must available when the pass runs),
+// and analyses that the pass PRESERVES (the pass does not invalidate the
+// results of these analyses). This information is provided by a pass to the
+// Pass infrastructure through the getAnalysisUsage virtual function.
+//
+class AnalysisUsage {
+ // Sets of analyses required and preserved by a pass
+ std::vector<AnalysisID> Required, Preserved, Provided;
+ bool PreservesAll;
+public:
+ AnalysisUsage() : PreservesAll(false) {}
+
+ // addRequires - Add the specified ID to the required set of the usage info
+ // for a pass.
+ //
+ AnalysisUsage &addRequired(AnalysisID ID) {
+ Required.push_back(ID);
+ return *this;
+ }
+
+ // addPreserves - Add the specified ID to the set of analyses preserved by
+ // this pass
+ //
+ AnalysisUsage &addPreserved(AnalysisID ID) {
+ Preserved.push_back(ID);
+ return *this;
+ }
+
+ void addProvided(AnalysisID ID) {
+ Provided.push_back(ID);
+ }
+
+ // PreservesAll - Set by analyses that do not transform their input at all
+ void setPreservesAll() { PreservesAll = true; }
+ bool preservesAll() const { return PreservesAll; }
+
+ const std::vector<AnalysisID> &getRequiredSet() const { return Required; }
+ const std::vector<AnalysisID> &getPreservedSet() const { return Preserved; }
+ const std::vector<AnalysisID> &getProvidedSet() const { return Provided; }
+};
+
+
//===----------------------------------------------------------------------===//
// AnalysisResolver - Simple interface implemented by PassManagers objects that
diff --git a/include/llvm/Transforms/FunctionInlining.h b/include/llvm/Transforms/FunctionInlining.h
index e321df52f7..08fe9d93a6 100644
--- a/include/llvm/Transforms/FunctionInlining.h
+++ b/include/llvm/Transforms/FunctionInlining.h
@@ -1,19 +1,19 @@
-//===-- MethodInlining.h - Functions that perform Inlining -------*- C++ -*--=//
+//===-- FunctionInlining.h - Functions that perform Inlining -----*- C++ -*--=//
//
-// This family of functions is useful for performing method inlining.
+// This family of functions is useful for performing function inlining.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TRANSFORMS_METHOD_INLINING_H
-#define LLVM_TRANSFORMS_METHOD_INLINING_H
+#ifndef LLVM_TRANSFORMS_FUNCTION_INLINING_H
+#define LLVM_TRANSFORMS_FUNCTION_INLINING_H
#include "llvm/BasicBlock.h"
class CallInst;
class Pass;
-Pass *createMethodInliningPass();
+Pass *createFunctionInliningPass();
-// InlineMethod - This function forcibly inlines the called method into the
+// InlineFunction - This function forcibly inlines the called function into the
// basic block of the caller. This returns true if it is not possible to inline
// this call. The program is still in a well defined state if this occurs
// though.
@@ -21,9 +21,9 @@ Pass *createMethodInliningPass();
// 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(CallInst *C);
-bool InlineMethod(BasicBlock::iterator CI); // *CI must be CallInst
+bool InlineFunction(CallInst *C);
+bool InlineFunction(BasicBlock::iterator CI); // *CI must be CallInst
#endif
diff --git a/include/llvm/Transforms/Instrumentation/TraceValues.h b/include/llvm/Transforms/Instrumentation/TraceValues.h
index 0519e1d67c..8afed48e29 100644
--- a/include/llvm/Transforms/Instrumentation/TraceValues.h
+++ b/include/llvm/Transforms/Instrumentation/TraceValues.h
@@ -1,6 +1,6 @@
//===- llvm/Transforms/Instrumentation/TraceValues.h - Tracing ---*- C++ -*--=//
//
-// Support for inserting LLVM code to print values at basic block and method
+// Support for inserting LLVM code to print values at basic block and function
// exits.
//
//===----------------------------------------------------------------------===//
@@ -9,7 +9,7 @@
#define LLVM_TRANSFORMS_INSTRUMENTATION_TRACEVALUES_H
class Pass;
-Pass *createTraceValuesPassForMethod(); // Just trace methods
+Pass *createTraceValuesPassForFunction(); // Just trace function entry/exit
Pass *createTraceValuesPassForBasicBlocks(); // Trace BB's and methods
#endif
diff --git a/include/llvm/Transforms/MutateStructTypes.h b/include/llvm/Transforms/MutateStructTypes.h
index 947606d1f5..e1fbeda2d4 100644
--- a/include/llvm/Transforms/MutateStructTypes.h
+++ b/include/llvm/Transforms/MutateStructTypes.h
@@ -41,7 +41,7 @@ class MutateStructTypes : public Pass {
// Mapping from global value of old type, to a global value of the new type...
std::map<const GlobalValue*, GlobalValue*> GlobalMap;
- // Mapping from intra method value to intra method value
+ // Mapping from intra function value to intra function value
std::map<const Value*, Value*> LocalValueMap;
public:
@@ -60,13 +60,6 @@ public:
// run - do the transformation
virtual bool run(Module *M);
- // getAnalysisUsageInfo - This function needs the results of the
- // FindUsedTypes and FindUnsafePointerTypes analysis passes...
- //
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided);
-
protected:
// Alternatively, it is valid to subclass this class and provide transforms
@@ -80,17 +73,17 @@ private:
// processGlobals - This loops over global constants defined in the
// module, converting them to their new type. Also this creates placeholder
- // methods for methods than need to be copied because they have a new
+ // functions for functions than need to be copied because they have a new
// signature type.
//
void processGlobals(Module *M);
- // transformMethod - This transforms the instructions of the method to use the
- // new types.
+ // transformFunction - This transforms the instructions of the function to use
+ // the new types.
//
- void transformMethod(Function *F);
+ void transformFunction(Function *F);
- // removeDeadGlobals - This removes the old versions of methods that are no
+ // removeDeadGlobals - This removes the old versions of functions that are no
// longer needed.
//
void removeDeadGlobals(Module *M);
diff --git a/include/llvm/Transforms/Scalar/InductionVars.h b/include/llvm/Transforms/Scalar/InductionVars.h
index b40f8f3c93..b8d951bb2b 100644
--- a/include/llvm/Transforms/Scalar/InductionVars.h
+++ b/include/llvm/Transforms/Scalar/InductionVars.h
@@ -11,17 +11,15 @@
#include "llvm/Pass.h"
namespace cfg { class IntervalPartition; }
-struct InductionVariableCannonicalize : public MethodPass {
+struct InductionVariableCannonicalize : public FunctionPass {
// doInductionVariableCannonicalize - Simplify induction variables in loops
//
- static bool doIt(Function *M, cfg::IntervalPartition &IP);
+ static bool doIt(Function *F, cfg::IntervalPartition &IP);
- virtual bool runOnMethod(Function *M);
+ virtual bool runOnFunction(Function *F);
- // getAnalysisUsageInfo - Declare that we need IntervalPartitions
- void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided);
+ // getAnalysisUsage - Declare that we need IntervalPartitions
+ void getAnalysisUsage(AnalysisUsage &AU) const;
};
#endif
diff --git a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
index 86784ed1cf..af82f6b3f2 100644
--- a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
+++ b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
@@ -1,17 +1,17 @@
-//===-- UnifyMethodExitNodes.h - Ensure methods have one return --*- C++ -*--=//
+//===-- UnifyFunctionExitNodes.h - Ensure fn's have one return ---*- C++ -*--=//
//
-// This pass is used to ensure that methods have at most one return instruction
-// in them. It also holds onto the return instruction of the last unified
-// method.
+// This pass is used to ensure that functions have at most one return
+// instruction in them. It also holds onto the return instruction of the last
+// unified function.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_XFORMS_UNIFY_METHOD_EXIT_NODES_H
-#define LLVM_XFORMS_UNIFY_METHOD_EXIT_NODES_H
+#ifndef LLVM_XFORMS_UNIFY_FUNCTION_EXIT_NODES_H
+#define LLVM_XFORMS_UNIFY_FUNCTION_EXIT_NODES_H
#include "llvm/Pass.h"
-struct UnifyMethodExitNodes : public MethodPass {
+struct UnifyMethodExitNodes : public FunctionPass {
BasicBlock *ExitNode;
public:
static AnalysisID ID; // Pass ID
@@ -21,22 +21,19 @@ public:
// BasicBlock, and converting all returns to unconditional branches to this
// new basic block. The singular exit node is returned in ExitNode.
//
- // 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.
//
static bool doit(Function *F, BasicBlock *&ExitNode);
- virtual bool runOnMethod(Function *F) {
+ virtual bool runOnFunction(Function *F) {
return doit(F, ExitNode);
}
BasicBlock *getExitNode() const { return ExitNode; }
- virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
- Pass::AnalysisSet &Destroyed,
- Pass::AnalysisSet &Provided) {
- // FIXME: Should invalidate CFG
- Provided.push_back(ID); // Provide self!
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addProvided(ID); // Provide self!
}
};