aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-26 18:01:55 +0000
committerChris Lattner <sabre@nondot.org>2002-03-26 18:01:55 +0000
commit79df7c0aaa18129e55968c8783ef8346807bd4af (patch)
tree4269fd8c25425d5164ee295b9060838df090d03f /lib/Transforms
parentb0d04726db108a8e8c43939d6321924a37199e24 (diff)
downloadexternal_llvm-79df7c0aaa18129e55968c8783ef8346807bd4af.zip
external_llvm-79df7c0aaa18129e55968c8783ef8346807bd4af.tar.gz
external_llvm-79df7c0aaa18129e55968c8783ef8346807bd4af.tar.bz2
Change references from Method to Function
change references from MethodARgument to FunctionArgument git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1991 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/DeadTypeElimination.cpp2
-rw-r--r--lib/Transforms/IPO/MutateStructTypes.cpp10
-rw-r--r--lib/Transforms/Instrumentation/TraceValues.cpp77
-rw-r--r--lib/Transforms/Scalar/DCE.cpp28
-rw-r--r--lib/Transforms/Scalar/InductionVars.cpp12
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp26
-rw-r--r--lib/Transforms/Utils/Linker.cpp84
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp45
8 files changed, 143 insertions, 141 deletions
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp
index f8a9b6e..a3dc9d8 100644
--- a/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/lib/Transforms/IPO/DeadTypeElimination.cpp
@@ -153,7 +153,7 @@ static bool PatchUpMethodReferences(Module *M) {
// used later.
//
if (Methods[i]->use_size() == 0) {
- M->getMethodList().remove(Methods[i]);
+ M->getFunctionList().remove(Methods[i]);
delete Methods[i];
Methods.erase(Methods.begin()+i);
Changed = true;
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp
index c67a2e0..04d84ad 100644
--- a/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -273,7 +273,7 @@ void MutateStructTypes::processGlobals(Module *M) {
Meth->setName("OLD."+Meth->getName());
// Insert the new method into the method list... to be filled in later...
- M->getMethodList().push_back(NewMeth);
+ M->getFunctionList().push_back(NewMeth);
// Keep track of the association...
GlobalMap[Meth] = NewMeth;
@@ -320,7 +320,7 @@ void MutateStructTypes::removeDeadGlobals(Module *M) {
#endif
for(Module::iterator I = M->begin(); I != M->end();) {
if (GlobalMap.find(*I) != GlobalMap.end())
- delete M->getMethodList().remove(I);
+ delete M->getFunctionList().remove(I);
else
++I;
}
@@ -341,9 +341,9 @@ void MutateStructTypes::transformMethod(Method *m) {
// Okay, first order of business, create the arguments...
for (unsigned i = 0; i < M->getArgumentList().size(); ++i) {
- const MethodArgument *OMA = M->getArgumentList()[i];
- MethodArgument *NMA = new MethodArgument(ConvertType(OMA->getType()),
- OMA->getName());
+ const FunctionArgument *OMA = M->getArgumentList()[i];
+ FunctionArgument *NMA = new FunctionArgument(ConvertType(OMA->getType()),
+ OMA->getName());
NewMeth->getArgumentList().push_back(NMA);
LocalValueMap[OMA] = NMA; // Keep track of value mapping
}
diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp
index 72c4541..9bbf7e5 100644
--- a/lib/Transforms/Instrumentation/TraceValues.cpp
+++ b/lib/Transforms/Instrumentation/TraceValues.cpp
@@ -12,7 +12,7 @@
#include "llvm/iMemory.h"
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
#include "llvm/Pass.h"
@@ -24,12 +24,12 @@ using std::string;
namespace {
class InsertTraceCode : public MethodPass {
- bool TraceBasicBlockExits, TraceMethodExits;
- Method *PrintfMeth;
+ bool TraceBasicBlockExits, TraceFunctionExits;
+ Function *PrintfFunc;
public:
- InsertTraceCode(bool traceBasicBlockExits, bool traceMethodExits)
+ InsertTraceCode(bool traceBasicBlockExits, bool traceFunctionExits)
: TraceBasicBlockExits(traceBasicBlockExits),
- TraceMethodExits(traceMethodExits) {}
+ TraceFunctionExits(traceFunctionExits) {}
// Add a prototype for printf if it is not already in the program.
//
@@ -39,15 +39,15 @@ namespace {
// Function InsertCodeToTraceValues
//
// Inserts tracing code for all live values at basic block and/or method
- // exits as specified by `traceBasicBlockExits' and `traceMethodExits'.
+ // exits as specified by `traceBasicBlockExits' and `traceFunctionExits'.
//
- static bool doit(Method *M, bool traceBasicBlockExits,
- bool traceMethodExits, Method *Printf);
+ static bool doit(Function *M, bool traceBasicBlockExits,
+ bool traceFunctionExits, Function *Printf);
// runOnMethod - This method does the work. Always successful.
//
- bool runOnMethod(Method *M) {
- return doit(M, TraceBasicBlockExits, TraceMethodExits, PrintfMeth);
+ bool runOnMethod(Function *F) {
+ return doit(F, TraceBasicBlockExits, TraceFunctionExits, PrintfFunc);
}
};
} // end anonymous namespace
@@ -72,14 +72,14 @@ bool InsertTraceCode::doInitialization(Module *M) {
const MethodType *MTy =
MethodType::get(Type::IntTy, vector<const Type*>(1, SBP), true);
- if (Value *Meth = ST->lookup(PointerType::get(MTy), "printf")) {
- PrintfMeth = cast<Method>(Meth);
+ if (Value *Func = ST->lookup(PointerType::get(MTy), "printf")) {
+ PrintfFunc = cast<Function>(Func);
return false;
}
// Create a new method and add it to the module
- PrintfMeth = new Method(MTy, false, "printf");
- M->getMethodList().push_back(PrintfMeth);
+ PrintfFunc = new Function(MTy, false, "printf");
+ M->getFunctionList().push_back(PrintfFunc);
return true;
}
@@ -153,7 +153,7 @@ static string getPrintfCodeFor(const Value *V) {
static void InsertPrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI,
- string Message, Method *Printf) {
+ string Message, Function *Printf) {
// Escape Message by replacing all % characters with %% chars.
unsigned Offset = 0;
while ((Offset = Message.find('%', Offset)) != string::npos) {
@@ -184,7 +184,7 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI,
static void InsertVerbosePrintInst(Value *V, BasicBlock *BB,
BasicBlock::iterator &BBI,
- const string &Message, Method *Printf) {
+ const string &Message, Function *Printf) {
std::ostringstream OutStr;
if (V) WriteAsOperand(OutStr, V);
InsertPrintInst(V, BB, BBI, Message+OutStr.str()+" = ", Printf);
@@ -195,15 +195,15 @@ static void InsertVerbosePrintInst(Value *V, BasicBlock *BB,
// for each value in valueVec[] that is live at the end of that basic block,
// or that is stored to memory in this basic block.
// If the value is stored to memory, we load it back before printing
-// We also return all such loaded values in the vector valuesStoredInMethod
+// We also return all such loaded values in the vector valuesStoredInFunction
// for printing at the exit from the method. (Note that in each invocation
// of the method, this will only get the last value stored for each static
// store instruction).
// *bb must be the block in which the value is computed;
// this is not checked here.
//
-static void TraceValuesAtBBExit(BasicBlock *BB, Method *Printf,
- vector<Instruction*> *valuesStoredInMethod) {
+static void TraceValuesAtBBExit(BasicBlock *BB, Function *Printf,
+ vector<Instruction*> *valuesStoredInFunction) {
// Get an iterator to point to the insertion location, which is
// just before the terminator instruction.
//
@@ -239,19 +239,19 @@ static void TraceValuesAtBBExit(BasicBlock *BB, Method *Printf,
IE = Insts.end(); II != IE; ++II) {
Instruction *I = *II;
if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
- assert(valuesStoredInMethod &&
+ assert(valuesStoredInFunction &&
"Should not be printing a store instruction at method exit");
LoadInst *LI = new LoadInst(SI->getPointerOperand(), SI->copyIndices(),
"reload");
InsertPos = BB->getInstList().insert(InsertPos, LI) + 1;
- valuesStoredInMethod->push_back(LI);
+ valuesStoredInFunction->push_back(LI);
}
if (ShouldTraceValue(I))
InsertVerbosePrintInst(I, BB, InsertPos, " ", Printf);
}
}
-static inline void InsertCodeToShowMethodEntry(Method *M, Method *Printf) {
+static inline void InsertCodeToShowFunctionEntry(Function *M, Function *Printf){
// Get an iterator to point to the insertion location
BasicBlock *BB = M->getEntryNode();
BasicBlock::iterator BBI = BB->begin();
@@ -261,9 +261,9 @@ static inline void InsertCodeToShowMethodEntry(Method *M, Method *Printf) {
InsertPrintInst(0, BB, BBI, "ENTERING METHOD: " + OutStr.str(), Printf);
// Now print all the incoming arguments
- const Method::ArgumentListType &argList = M->getArgumentList();
+ const Function::ArgumentListType &argList = M->getArgumentList();
unsigned ArgNo = 0;
- for (Method::ArgumentListType::const_iterator
+ for (Function::ArgumentListType::const_iterator
I = argList.begin(), E = argList.end(); I != E; ++I, ++ArgNo) {
InsertVerbosePrintInst(*I, BB, BBI,
" Arg #" + utostr(ArgNo), Printf);
@@ -271,7 +271,8 @@ static inline void InsertCodeToShowMethodEntry(Method *M, Method *Printf) {
}
-static inline void InsertCodeToShowMethodExit(BasicBlock *BB, Method *Printf) {
+static inline void InsertCodeToShowFunctionExit(BasicBlock *BB,
+ Function *Printf) {
// Get an iterator to point to the insertion location
BasicBlock::iterator BBI = BB->end()-1;
ReturnInst *Ret = cast<ReturnInst>(*BBI);
@@ -286,34 +287,34 @@ static inline void InsertCodeToShowMethodExit(BasicBlock *BB, Method *Printf) {
}
-bool InsertTraceCode::doit(Method *M, bool traceBasicBlockExits,
- bool traceMethodEvents, Method *Printf) {
- if (!traceBasicBlockExits && !traceMethodEvents)
+bool InsertTraceCode::doit(Function *M, bool traceBasicBlockExits,
+ bool traceFunctionEvents, Function *Printf) {
+ if (!traceBasicBlockExits && !traceFunctionEvents)
return false;
- vector<Instruction*> valuesStoredInMethod;
+ vector<Instruction*> valuesStoredInFunction;
vector<BasicBlock*> exitBlocks;
- if (traceMethodEvents)
- InsertCodeToShowMethodEntry(M, Printf);
+ if (traceFunctionEvents)
+ InsertCodeToShowFunctionEntry(M, Printf);
- for (Method::iterator BI = M->begin(); BI != M->end(); ++BI) {
+ for (Function::iterator BI = M->begin(); BI != M->end(); ++BI) {
BasicBlock *BB = *BI;
if (isa<ReturnInst>(BB->getTerminator()))
exitBlocks.push_back(BB); // record this as an exit block
if (traceBasicBlockExits)
- TraceValuesAtBBExit(BB, Printf, &valuesStoredInMethod);
+ TraceValuesAtBBExit(BB, Printf, &valuesStoredInFunction);
}
- if (traceMethodEvents)
+ if (traceFunctionEvents)
for (unsigned i=0; i < exitBlocks.size(); ++i) {
#if 0
- TraceValuesAtBBExit(valuesStoredInMethod, exitBlocks[i], module,
- /*indent*/ 0, /*isMethodExit*/ true,
- /*valuesStoredInMethod*/ NULL);
+ TraceValuesAtBBExit(valuesStoredInFunction, exitBlocks[i], module,
+ /*indent*/ 0, /*isFunctionExit*/ true,
+ /*valuesStoredInFunction*/ NULL);
#endif
- InsertCodeToShowMethodExit(exitBlocks[i], Printf);
+ InsertCodeToShowFunctionExit(exitBlocks[i], Printf);
}
return true;
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index 491c957..049bac3 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -26,7 +26,7 @@
#include "llvm/Transforms/Scalar/DCE.h"
#include "llvm/Module.h"
#include "llvm/GlobalVariable.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/iTerminators.h"
#include "llvm/iPHINode.h"
@@ -91,7 +91,7 @@ static bool RemoveSingularPHIs(BasicBlock *BB) {
//cerr << "Killing PHIs from " << BB;
//cerr << "Pred #0 = " << *pred_begin(BB);
- //cerr << "Method == " << BB->getParent();
+ //cerr << "Function == " << BB->getParent();
do {
PHINode *PN = cast<PHINode>(I);
@@ -167,9 +167,9 @@ static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
//
// WARNING: The entry node of a method may not be simplified.
//
-bool SimplifyCFG(Method::iterator &BBIt) {
+bool SimplifyCFG(Function::iterator &BBIt) {
BasicBlock *BB = *BBIt;
- Method *M = BB->getParent();
+ Function *M = BB->getParent();
assert(BB && BB->getParent() && "Block not embedded in method!");
assert(BB->getTerminator() && "Degenerate basic block encountered!");
@@ -226,7 +226,7 @@ bool SimplifyCFG(Method::iterator &BBIt) {
Succ->setName(BB->getName());
delete BB; // Delete basic block
- //cerr << "Method after removal: \n" << M;
+ //cerr << "Function after removal: \n" << M;
return true;
}
}
@@ -279,13 +279,13 @@ bool SimplifyCFG(Method::iterator &BBIt) {
return false;
}
-static bool DoDCEPass(Method *M) {
- Method::iterator BBIt, BBEnd = M->end();
- if (M->begin() == BBEnd) return false; // Nothing to do
+static bool DoDCEPass(Function *F) {
+ Function::iterator BBIt, BBEnd = F->end();
+ if (F->begin() == BBEnd) return false; // Nothing to do
bool Changed = false;
// Loop through now and remove instructions that have no uses...
- for (BBIt = M->begin(); BBIt != BBEnd; ++BBIt) {
+ for (BBIt = F->begin(); BBIt != BBEnd; ++BBIt) {
Changed |= RemoveUnusedDefs((*BBIt)->getInstList());
Changed |= RemoveSingularPHIs(*BBIt);
}
@@ -293,7 +293,7 @@ static bool DoDCEPass(Method *M) {
// Loop over all of the basic blocks (except the first one) and remove them
// if they are unneeded...
//
- for (BBIt = M->begin(), ++BBIt; BBIt != M->end(); ) {
+ for (BBIt = F->begin(), ++BBIt; BBIt != F->end(); ) {
if (SimplifyCFG(BBIt)) {
Changed = true;
} else {
@@ -312,11 +312,11 @@ static bool RemoveUnusedGlobalValues(Module *Mod) {
bool Changed = false;
for (Module::iterator MI = Mod->begin(); MI != Mod->end(); ) {
- Method *Meth = *MI;
+ Function *Meth = *MI;
if (Meth->isExternal() && Meth->use_size() == 0) {
// No references to prototype?
//cerr << "Removing method proto: " << Meth->getName() << endl;
- delete Mod->getMethodList().remove(MI); // Remove prototype
+ delete Mod->getFunctionList().remove(MI); // Remove prototype
// Remove moves iterator to point to the next one automatically
Changed = true;
} else {
@@ -351,9 +351,9 @@ namespace {
// It is possible that we may require multiple passes over the code to fully
// eliminate dead code. Iterate until we are done.
//
- virtual bool runOnMethod(Method *M) {
+ virtual bool runOnMethod(Function *F) {
bool Changed = false;
- while (DoDCEPass(M)) Changed = true;
+ while (DoDCEPass(F)) Changed = true;
return Changed;
}
diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp
index 617c086..83de373 100644
--- a/lib/Transforms/Scalar/InductionVars.cpp
+++ b/lib/Transforms/Scalar/InductionVars.cpp
@@ -25,7 +25,7 @@
#include "llvm/Assembly/Writer.h"
#include "llvm/SymbolTable.h"
#include "llvm/iPHINode.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/InstrTypes.h"
#include "llvm/Support/CFG.h"
@@ -38,7 +38,7 @@ using std::cerr;
// an interval invariant computation.
//
static bool isLoopInvariant(cfg::Interval *Int, Value *V) {
- assert(isa<Constant>(V) || isa<Instruction>(V) || isa<MethodArgument>(V));
+ assert(isa<Constant>(V) || isa<Instruction>(V) || isa<FunctionArgument>(V));
if (!isa<Instruction>(V))
return true; // Constants and arguments are always loop invariant
@@ -181,7 +181,7 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
std::string PHIName, AddName;
BasicBlock *Header = Int->getHeaderNode();
- Method *M = Header->getParent();
+ Function *M = Header->getParent();
if (M->hasSymbolTable()) {
// Only name the induction variable if the method isn't stripped.
@@ -373,7 +373,7 @@ static bool ProcessIntervalPartition(cfg::IntervalPartition &IP) {
// This function loops over an interval partition of a program, reducing it
// until the graph is gone.
//
-bool InductionVariableCannonicalize::doIt(Method *M,
+bool InductionVariableCannonicalize::doIt(Function *M,
cfg::IntervalPartition &IP) {
bool Changed = false;
@@ -399,8 +399,8 @@ bool InductionVariableCannonicalize::doIt(Method *M,
}
-bool InductionVariableCannonicalize::runOnMethod(Method *M) {
- return doIt(M, getAnalysis<cfg::IntervalPartition>());
+bool InductionVariableCannonicalize::runOnMethod(Function *F) {
+ return doIt(F, getAnalysis<cfg::IntervalPartition>());
}
// getAnalysisUsageInfo - This function works on the call graph of a module.
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 2bf6c86..59106cf 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -17,10 +17,9 @@
#include "llvm/Transforms/Scalar/ConstantProp.h"
#include "llvm/Transforms/Scalar/ConstantHandling.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstantVals.h"
-#include "llvm/InstrTypes.h"
#include "llvm/iPHINode.h"
#include "llvm/iMemory.h"
#include "llvm/iTerminators.h"
@@ -87,7 +86,7 @@ public:
// It's public interface consists of a constructor and a doSCCP() method.
//
class SCCP {
- Method *M; // The method that we are working on...
+ Function *M; // The function that we are working on
std::set<BasicBlock*> BBExecutable;// The basic blocks that are executable
std::map<Value*, InstVal> ValueState; // The state each value is in...
@@ -101,7 +100,7 @@ class SCCP {
public:
// SCCP Ctor - Save the method to operate on...
- inline SCCP(Method *m) : M(m) {}
+ inline SCCP(Function *f) : M(f) {}
// doSCCP() - Run the Sparse Conditional Constant Propogation algorithm, and
// return true if the method was modified.
@@ -142,8 +141,8 @@ private:
// getValueState - Return the InstVal object that corresponds to the value.
// This function is neccesary because not all values should start out in the
- // underdefined state... MethodArgument's should be overdefined, and constants
- // should be marked as constants. If a value is not known to be an
+ // underdefined state... FunctionArgument's should be overdefined, and
+ // constants should be marked as constants. If a value is not known to be an
// Instruction object, then use this accessor to get its value from the map.
//
inline InstVal &getValueState(Value *V) {
@@ -152,7 +151,7 @@ private:
if (Constant *CPV = dyn_cast<Constant>(V)) { // Constants are constant
ValueState[CPV].markConstant(CPV);
- } else if (isa<MethodArgument>(V)) { // MethodArgs are overdefined
+ } else if (isa<FunctionArgument>(V)) { // FuncArgs are overdefined
ValueState[V].markOverdefined();
}
// All others are underdefined by default...
@@ -235,7 +234,8 @@ bool SCCP::doSCCP() {
}
#if 0
- for (Method::iterator BBI = M->begin(), BBEnd = M->end(); BBI != BBEnd; ++BBI)
+ for (Function::iterator BBI = M->begin(), BBEnd = M->end();
+ BBI != BBEnd; ++BBI)
if (!BBExecutable.count(*BBI))
cerr << "BasicBlock Dead:" << *BBI;
#endif
@@ -245,7 +245,7 @@ bool SCCP::doSCCP() {
// constants if we have found them to be of constant values.
//
bool MadeChanges = false;
- for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+ for (Function::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
BasicBlock *BB = *MI;
for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) {
Instruction *Inst = *BI;
@@ -380,8 +380,8 @@ void SCCP::UpdateInstruction(Instruction *I) {
//===-----------------------------------------------------------------===//
// Handle Terminator instructions...
//
- case Instruction::Ret: return; // Method return doesn't affect anything
- case Instruction::Br: { // Handle conditional branches...
+ case Instruction::Ret: return; // Function return doesn't affect anything
+ case Instruction::Br: { // Handle conditional branches...
BranchInst *BI = cast<BranchInst>(I);
if (BI->isUnconditional())
return; // Unconditional branches are already handled!
@@ -509,8 +509,8 @@ namespace {
// to prove whether a value is constant and whether blocks are used.
//
struct SCCPPass : public MethodPass {
- inline bool runOnMethod(Method *M) {
- SCCP S(M);
+ inline bool runOnMethod(Function *F) {
+ SCCP S(F);
return S.doSCCP();
}
};
diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp
index c98295c..f3b0084 100644
--- a/lib/Transforms/Utils/Linker.cpp
+++ b/lib/Transforms/Utils/Linker.cpp
@@ -11,7 +11,7 @@
#include "llvm/Transforms/Linker.h"
#include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/GlobalVariable.h"
#include "llvm/SymbolTable.h"
@@ -165,8 +165,8 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
(V = ST->lookup(SGV->getType(), SGV->getName())) &&
cast<GlobalVariable>(V)->hasExternalLinkage()) {
// The same named thing is a global variable, because the only two things
- // that may be in a module level symbol table are Global Vars and Methods,
- // and they both have distinct, nonoverlapping, possible types.
+ // that may be in a module level symbol table are Global Vars and
+ // Functions, and they both have distinct, nonoverlapping, possible types.
//
GlobalVariable *DGV = cast<GlobalVariable>(V);
@@ -231,13 +231,13 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
return false;
}
-// LinkMethodProtos - Link the methods together between the two modules, without
-// doing method bodies... this just adds external method prototypes to the Dest
-// method...
+// LinkFunctionProtos - Link the functions together between the two modules,
+// without doing method bodies... this just adds external method prototypes to
+// the Dest function...
//
-static bool LinkMethodProtos(Module *Dest, const Module *Src,
- map<const Value*, Value*> &ValueMap,
- string *Err = 0) {
+static bool LinkFunctionProtos(Module *Dest, const Module *Src,
+ map<const Value*, Value*> &ValueMap,
+ string *Err = 0) {
// We will need a module level symbol table if the src module has a module
// level symbol table...
SymbolTable *ST = Src->getSymbolTable() ? Dest->getSymbolTableSure() : 0;
@@ -245,7 +245,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
// Loop over all of the methods in the src module, mapping them over as we go
//
for (Module::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) {
- const Method *SM = *I; // SrcMethod
+ const Function *SM = *I; // SrcFunction
Value *V;
// If the method has a name, and that name is already in use in the
@@ -253,29 +253,29 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
//
if (SM->hasExternalLinkage() && SM->hasName() &&
(V = ST->lookup(SM->getType(), SM->getName())) &&
- cast<Method>(V)->hasExternalLinkage()) {
- // The same named thing is a Method, because the only two things
- // that may be in a module level symbol table are Global Vars and Methods,
- // and they both have distinct, nonoverlapping, possible types.
+ cast<Function>(V)->hasExternalLinkage()) {
+ // The same named thing is a Function, because the only two things
+ // that may be in a module level symbol table are Global Vars and
+ // Functions, and they both have distinct, nonoverlapping, possible types.
//
- Method *DM = cast<Method>(V); // DestMethod
+ Function *DM = cast<Function>(V); // DestFunction
// Check to make sure the method is not defined in both modules...
if (!SM->isExternal() && !DM->isExternal())
- return Error(Err, "Method '" +
+ return Error(Err, "Function '" +
SM->getMethodType()->getDescription() + "':\"" +
- SM->getName() + "\" - Method is already defined!");
+ SM->getName() + "\" - Function is already defined!");
// Otherwise, just remember this mapping...
ValueMap.insert(std::make_pair(SM, DM));
} else {
- // Method does not already exist, simply insert an external method
+ // Function does not already exist, simply insert an external method
// signature identical to SM into the dest module...
- Method *DM = new Method(SM->getMethodType(), SM->hasInternalLinkage(),
- SM->getName());
+ Function *DM = new Function(SM->getMethodType(), SM->hasInternalLinkage(),
+ SM->getName());
// Add the method signature to the dest module...
- Dest->getMethodList().push_back(DM);
+ Dest->getFunctionList().push_back(DM);
// ... and remember this mapping...
ValueMap.insert(std::make_pair(SM, DM));
@@ -284,24 +284,24 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
return false;
}
-// LinkMethodBody - Copy the source method over into the dest method and fix up
-// references to values. At this point we know that Dest is an external method,
-// and that Src is not.
+// LinkFunctionBody - Copy the source method over into the dest method
+// and fix up references to values. At this point we know that Dest
+// is an external method, and that Src is not.
//
-static bool LinkMethodBody(Method *Dest, const Method *Src,
- const map<const Value*, Value*> &GlobalMap,
- string *Err = 0) {
+static bool LinkFunctionBody(Function *Dest, const Function *Src,
+ const map<const Value*, Value*> &GlobalMap,
+ string *Err = 0) {
assert(Src && Dest && Dest->isExternal() && !Src->isExternal());
map<const Value*, Value*> LocalMap; // Map for method local values
// Go through and convert method arguments over...
- for (Method::ArgumentListType::const_iterator
+ for (Function::ArgumentListType::const_iterator
I = Src->getArgumentList().begin(),
E = Src->getArgumentList().end(); I != E; ++I) {
- const MethodArgument *SMA = *I;
+ const FunctionArgument *SMA = *I;
// Create the new method argument and add to the dest method...
- MethodArgument *DMA = new MethodArgument(SMA->getType(), SMA->getName());
+ FunctionArgument *DMA = new FunctionArgument(SMA->getType(),SMA->getName());
Dest->getArgumentList().push_back(DMA);
// Add a mapping to our local map
@@ -310,7 +310,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
// Loop over all of the basic blocks, copying the instructions over...
//
- for (Method::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) {
+ for (Function::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) {
const BasicBlock *SBB = *I;
// Create new basic block and add to mapping and the Dest method...
@@ -338,7 +338,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
// in the Source method as operands. Loop through all of the operands of the
// methods and patch them up to point to the local versions...
//
- for (Method::iterator BI = Dest->begin(), BE = Dest->end();
+ for (Function::iterator BI = Dest->begin(), BE = Dest->end();
BI != BE; ++BI) {
BasicBlock *BB = *BI;
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
@@ -354,30 +354,30 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
}
-// LinkMethodBodies - Link in the method bodies that are defined in the source
+// LinkFunctionBodies - Link in the method bodies that are defined in the source
// module into the DestModule. This consists basically of copying the method
// over and fixing up references to values.
//
-static bool LinkMethodBodies(Module *Dest, const Module *Src,
- map<const Value*, Value*> &ValueMap,
- string *Err = 0) {
+static bool LinkFunctionBodies(Module *Dest, const Module *Src,
+ map<const Value*, Value*> &ValueMap,
+ string *Err = 0) {
// Loop over all of the methods in the src module, mapping them over as we go
//
for (Module::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) {
- const Method *SM = *I; // Source Method
+ const Function *SM = *I; // Source Function
if (!SM->isExternal()) { // No body if method is external
- Method *DM = cast<Method>(ValueMap[SM]); // Destination method
+ Function *DM = cast<Function>(ValueMap[SM]); // Destination method
// DM not external SM external?
if (!DM->isExternal()) {
if (Err)
- *Err = "Method '" + (SM->hasName() ? SM->getName() : string("")) +
+ *Err = "Function '" + (SM->hasName() ? SM->getName() : string("")) +
"' body multiply defined!";
return true;
}
- if (LinkMethodBody(DM, SM, ValueMap, Err)) return true;
+ if (LinkFunctionBody(DM, SM, ValueMap, Err)) return true;
}
}
return false;
@@ -418,13 +418,13 @@ bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0) {
// We do this so that when we begin processing method bodies, all of the
// global values that may be referenced are available in our ValueMap.
//
- if (LinkMethodProtos(Dest, Src, ValueMap, ErrorMsg)) return true;
+ if (LinkFunctionProtos(Dest, Src, ValueMap, ErrorMsg)) return true;
// Link in the method bodies that are defined in the source module into the
// DestModule. This consists basically of copying the method over and fixing
// up references to values.
//
- if (LinkMethodBodies(Dest, Src, ValueMap, ErrorMsg)) return true;
+ if (LinkFunctionBodies(Dest, Src, ValueMap, ErrorMsg)) return true;
return false;
}
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index dc5137e..3ee74d4 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -25,13 +25,13 @@ namespace {
// calls.
//
class LowerAllocations : public BasicBlockPass {
- Method *MallocMeth; // Methods in the module we are processing
- Method *FreeMeth; // Initialized by doInitialization
+ Function *MallocFunc; // Functions in the module we are processing
+ Function *FreeFunc; // Initialized by doInitialization
const TargetData &DataLayout;
public:
inline LowerAllocations(const TargetData &TD) : DataLayout(TD) {
- MallocMeth = FreeMeth = 0;
+ MallocFunc = FreeFunc = 0;
}
// doPassInitialization - For the lower allocations pass, this ensures that a
@@ -49,10 +49,10 @@ public:
// instruction.
//
class RaiseAllocations : public BasicBlockPass {
- Method *MallocMeth; // Methods in the module we are processing
- Method *FreeMeth; // Initialized by doPassInitializationVirt
+ Function *MallocFunc; // Functions in the module we are processing
+ Function *FreeFunc; // Initialized by doPassInitializationVirt
public:
- inline RaiseAllocations() : MallocMeth(0), FreeMeth(0) {}
+ inline RaiseAllocations() : MallocFunc(0), FreeFunc(0) {}
// doPassInitialization - For the raise allocations pass, this finds a
// declaration for malloc and free if they exist.
@@ -82,10 +82,10 @@ bool LowerAllocations::doInitialization(Module *M) {
// Check for a definition of malloc
if (Value *V = SymTab->lookup(PointerType::get(MallocType), "malloc")) {
- MallocMeth = cast<Method>(V); // Yup, got it
+ MallocFunc = cast<Function>(V); // Yup, got it
} else { // Nope, add one
- M->getMethodList().push_back(MallocMeth = new Method(MallocType, false,
- "malloc"));
+ M->getFunctionList().push_back(MallocFunc = new Function(MallocType, false,
+ "malloc"));
Changed = true;
}
@@ -96,9 +96,10 @@ bool LowerAllocations::doInitialization(Module *M) {
// Check for a definition of free
if (Value *V = SymTab->lookup(PointerType::get(FreeType), "free")) {
- FreeMeth = cast<Method>(V); // Yup, got it
+ FreeFunc = cast<Function>(V); // Yup, got it
} else { // Nope, add one
- M->getMethodList().push_back(FreeMeth = new Method(FreeType, false,"free"));
+ FreeFunc = new Function(FreeType, false,"free");
+ M->getFunctionList().push_back(FreeFunc);
Changed = true;
}
@@ -110,7 +111,7 @@ bool LowerAllocations::doInitialization(Module *M) {
//
bool LowerAllocations::runOnBasicBlock(BasicBlock *BB) {
bool Changed = false;
- assert(MallocMeth && FreeMeth && BB && "Pass not initialized!");
+ assert(MallocFunc && FreeFunc && BB && "Pass not initialized!");
// Loop over all of the instructions, looking for malloc or free instructions
for (unsigned i = 0; i < BB->size(); ++i) {
@@ -136,7 +137,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock *BB) {
}
// Create the call to Malloc...
- CallInst *MCall = new CallInst(MallocMeth,
+ CallInst *MCall = new CallInst(MallocFunc,
vector<Value*>(1, MallocArg));
BBIL.insert(BBIL.begin()+i, MCall);
@@ -157,7 +158,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock *BB) {
BBIL.insert(BBIL.begin()+i, MCast);
// Insert a call to the free function...
- CallInst *FCall = new CallInst(FreeMeth,
+ CallInst *FCall = new CallInst(FreeFunc,
vector<Value*>(1, MCast));
BBIL.insert(BBIL.begin()+i+1, FCall);
@@ -185,16 +186,16 @@ bool RaiseAllocations::doInitialization(Module *M) {
const PointerType *MallocType = // Get the type for malloc
PointerType::get(MethodType::get(PointerType::get(Type::SByteTy),
vector<const Type*>(1, Type::UIntTy), false));
- MallocMeth = cast_or_null<Method>(ST->lookup(MallocType, "malloc"));
- if (MallocMeth && !MallocMeth->isExternal())
- MallocMeth = 0; // Don't mess with locally defined versions of the fn
+ MallocFunc = cast_or_null<Function>(ST->lookup(MallocType, "malloc"));
+ if (MallocFunc && !MallocFunc->isExternal())
+ MallocFunc = 0; // Don't mess with locally defined versions of the fn
const PointerType *FreeType = // Get the type for free
PointerType::get(MethodType::get(Type::VoidTy,
vector<const Type*>(1, PointerType::get(Type::SByteTy)), false));
- FreeMeth = cast_or_null<Method>(ST->lookup(FreeType, "free"));
- if (FreeMeth && !FreeMeth->isExternal())
- FreeMeth = 0; // Don't mess with locally defined versions of the fn
+ FreeFunc = cast_or_null<Function>(ST->lookup(FreeType, "free"));
+ if (FreeFunc && !FreeFunc->isExternal())
+ FreeFunc = 0; // Don't mess with locally defined versions of the fn
return false;
}
@@ -209,7 +210,7 @@ bool RaiseAllocations::runOnBasicBlock(BasicBlock *BB) {
Instruction *I = *BI;
if (CallInst *CI = dyn_cast<CallInst>(I)) {
- if (CI->getCalledValue() == MallocMeth) { // Replace call to malloc?
+ if (CI->getCalledValue() == MallocFunc) { // Replace call to malloc?
const Type *PtrSByte = PointerType::get(Type::SByteTy);
MallocInst *MallocI = new MallocInst(PtrSByte, CI->getOperand(1),
CI->getName());
@@ -217,7 +218,7 @@ bool RaiseAllocations::runOnBasicBlock(BasicBlock *BB) {
ReplaceInstWithInst(BIL, BI, MallocI);
Changed = true;
continue; // Skip the ++BI
- } else if (CI->getCalledValue() == FreeMeth) { // Replace call to free?
+ } else if (CI->getCalledValue() == FreeFunc) { // Replace call to free?
ReplaceInstWithInst(BIL, BI, new FreeInst(CI->getOperand(1)));
Changed = true;
continue; // Skip the ++BI