Change references from Method to Function
change references from MethodARgument to FunctionArgument
llvm-svn: 1991
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index 491c957..049bac3 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/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 @@
//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 @@
//
// 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 @@
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 @@
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 @@
// 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 @@
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 @@
// 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/llvm/lib/Transforms/Scalar/InductionVars.cpp b/llvm/lib/Transforms/Scalar/InductionVars.cpp
index 617c086..83de373 100644
--- a/llvm/lib/Transforms/Scalar/InductionVars.cpp
+++ b/llvm/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 @@
// 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 @@
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 @@
// 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::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/llvm/lib/Transforms/Scalar/LowerAllocations.cpp b/llvm/lib/Transforms/Scalar/LowerAllocations.cpp
index dc5137e..3ee74d4 100644
--- a/llvm/lib/Transforms/Scalar/LowerAllocations.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerAllocations.cpp
@@ -25,13 +25,13 @@
// 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 @@
// 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 @@
// 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 @@
// 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::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 @@
}
// 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 @@
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 @@
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 @@
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 @@
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
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 2bf6c86..59106cf 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/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 @@
// 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 @@
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 @@
// 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 @@
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 @@
}
#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 @@
// 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 @@
//===-----------------------------------------------------------------===//
// 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 @@
// 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();
}
};