aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-26 07:49:05 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-26 07:49:05 +0000
commit93b67e40de356569493c285b86b138a3f11b5035 (patch)
treec24ec4151ac85c2506a255bdb847cbe3c152baa1
parentf40761d5229322c08701049f89aa10f7f7b8b743 (diff)
Eliminate some uses of DOUT, cerr, and getNameStart().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77145 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/PassManagers.h10
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp3
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp11
-rw-r--r--lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp11
-rw-r--r--lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp11
-rw-r--r--lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp11
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp10
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp69
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp34
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp331
-rw-r--r--lib/VMCore/Core.cpp2
-rw-r--r--lib/VMCore/PassManager.cpp88
12 files changed, 299 insertions, 292 deletions
diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h
index 1aa0d3a6fa..2fc404116f 100644
--- a/include/llvm/PassManagers.h
+++ b/include/llvm/PassManagers.h
@@ -91,9 +91,10 @@
#include "llvm/Support/PrettyStackTrace.h"
namespace llvm {
+ class Module;
class Pass;
+ class StringRef;
class Value;
- class Module;
/// FunctionPassManager and PassManager, two top level managers, serve
/// as the public interface of pass manager infrastructure.
@@ -285,7 +286,8 @@ public:
void removeNotPreservedAnalysis(Pass *P);
/// Remove dead passes
- void removeDeadPasses(Pass *P, const char *Msg, enum PassDebuggingString);
+ void removeDeadPasses(Pass *P, const StringRef &Msg,
+ enum PassDebuggingString);
/// Add pass P into the PassVector. Update
/// AvailableAnalysis appropriately if ProcessAnalysis is true.
@@ -340,7 +342,7 @@ public:
void dumpLastUses(Pass *P, unsigned Offset) const;
void dumpPassArguments() const;
void dumpPassInfo(Pass *P, enum PassDebuggingString S1,
- enum PassDebuggingString S2, const char *Msg);
+ enum PassDebuggingString S2, const StringRef &Msg);
void dumpRequiredSet(const Pass *P) const;
void dumpPreservedSet(const Pass *P) const;
@@ -379,7 +381,7 @@ protected:
std::map<AnalysisID, Pass *> *InheritedAnalysis[PMT_Last];
private:
- void dumpAnalysisUsage(const char *Msg, const Pass *P,
+ void dumpAnalysisUsage(const StringRef &Msg, const Pass *P,
const AnalysisUsage::VectorType &Set) const;
// Set of available Analysis. This information is used while scheduling
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index cb2888025b..8a999da3d3 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -120,7 +120,8 @@ Function *ExecutionEngine::FindFunctionNamed(const char *FnName) {
void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
MutexGuard locked(lock);
- DOUT << "JIT: Map \'" << GV->getNameStart() << "\' to [" << Addr << "]\n";
+ DEBUG(errs() << "JIT: Map \'" << GV->getName()
+ << "\' to [" << Addr << "]\n";);
void *&CurVal = state.getGlobalAddressMap(locked)[GV];
assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
CurVal = Addr;
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index 5ee5e6d5cd..3c1f6cb00a 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
@@ -1086,11 +1086,12 @@ bool ARMAsmPrinter::doInitialization(Module &M) {
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
- for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
- Name != E; ++Name)
- if (isprint(*Name))
- OS << *Name;
+static void PrintUnmangledNameSafely(const Value *V,
+ formatted_raw_ostream &OS) {
+ for (StringRef::iterator it = V->getName().begin(),
+ ie = V->getName().end(); it != ie; ++it)
+ if (isprint(*it))
+ OS << *it;
}
void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
diff --git a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
index df39710f3e..fd1df767dc 100644
--- a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
+++ b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
@@ -490,11 +490,12 @@ bool LinuxAsmPrinter::doInitialization(Module &M) {
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
- for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
- Name != E; ++Name)
- if (isprint(*Name))
- OS << *Name;
+static void PrintUnmangledNameSafely(const Value *V,
+ formatted_raw_ostream &OS) {
+ for (StringRef::iterator it = V->getName().begin(),
+ ie = V->getName().end(); it != ie; ++it)
+ if (isprint(*it))
+ OS << *it;
}
/*!
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index 69b67db809..88663c488b 100644
--- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
@@ -652,11 +652,12 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
- for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
- Name != E; ++Name)
- if (isprint(*Name))
- OS << *Name;
+static void PrintUnmangledNameSafely(const Value *V,
+ formatted_raw_ostream &OS) {
+ for (StringRef::iterator it = V->getName().begin(),
+ ie = V->getName().end(); it != ie; ++it)
+ if (isprint(*it))
+ OS << *it;
}
void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
diff --git a/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp b/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
index 572326e76d..7a16684959 100644
--- a/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
+++ b/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
@@ -303,11 +303,12 @@ void SystemZAsmPrinter::printRRIAddrOperand(const MachineInstr *MI, int OpNum,
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
- for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
- Name != E; ++Name)
- if (isprint(*Name))
- OS << *Name;
+static void PrintUnmangledNameSafely(const Value *V,
+ formatted_raw_ostream &OS) {
+ for (StringRef::iterator it = V->getName().begin(),
+ ie = V->getName().end(); it != ie; ++it)
+ if (isprint(*it))
+ OS << *it;
}
void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index 16d8482086..1260cedfcd 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -60,12 +60,12 @@ void X86ATTAsmPrinter::PrintPICBaseSymbol() const {
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V,
+static void PrintUnmangledNameSafely(const Value *V,
formatted_raw_ostream &OS) {
- for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
- Name != E; ++Name)
- if (isprint(*Name))
- OS << *Name;
+ for (StringRef::iterator it = V->getName().begin(),
+ ie = V->getName().end(); it != ie; ++it)
+ if (isprint(*it))
+ OS << *it;
}
static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 1e43e2eb79..9f8cce53ba 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -29,6 +29,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ValueHandle.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
STATISTIC(NumThreads, "Number of jumps threaded");
@@ -98,7 +99,7 @@ FunctionPass *llvm::createJumpThreadingPass() { return new JumpThreading(); }
/// runOnFunction - Top level algorithm.
///
bool JumpThreading::runOnFunction(Function &F) {
- DOUT << "Jump threading on function '" << F.getNameStart() << "'\n";
+ DEBUG(errs() << "Jump threading on function '" << F.getName() << "'\n");
TD = getAnalysisIfAvailable<TargetData>();
FindLoopHeaders(F);
@@ -118,8 +119,8 @@ bool JumpThreading::runOnFunction(Function &F) {
// edges which simplifies the CFG.
if (pred_begin(BB) == pred_end(BB) &&
BB != &BB->getParent()->getEntryBlock()) {
- DOUT << " JT: Deleting dead block '" << BB->getNameStart()
- << "' with terminator: " << *BB->getTerminator();
+ DEBUG(errs() << " JT: Deleting dead block '" << BB->getName()
+ << "' with terminator: " << *BB->getTerminator());
LoopHeaders.erase(BB);
DeleteDeadBlock(BB);
Changed = true;
@@ -172,8 +173,8 @@ BasicBlock *JumpThreading::FactorCommonPHIPreds(PHINode *PN, Value *Val) {
if (CommonPreds.size() == 1)
return CommonPreds[0];
- DOUT << " Factoring out " << CommonPreds.size()
- << " common predecessors.\n";
+ DEBUG(errs() << " Factoring out " << CommonPreds.size()
+ << " common predecessors.\n");
return SplitBlockPredecessors(PN->getParent(),
&CommonPreds[0], CommonPreds.size(),
".thr_comm", this);
@@ -261,8 +262,8 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) {
// terminator to an unconditional branch. This can occur due to threading in
// other blocks.
if (isa<ConstantInt>(Condition)) {
- DOUT << " In block '" << BB->getNameStart()
- << "' folding terminator: " << *BB->getTerminator();
+ DEBUG(errs() << " In block '" << BB->getName()
+ << "' folding terminator: " << *BB->getTerminator());
++NumFolds;
ConstantFoldTerminator(BB);
return true;
@@ -291,8 +292,8 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) {
BBTerm->getSuccessor(i)->removePredecessor(BB);
}
- DOUT << " In block '" << BB->getNameStart()
- << "' folding undef terminator: " << *BBTerm;
+ DEBUG(errs() << " In block '" << BB->getName()
+ << "' folding undef terminator: " << *BBTerm);
BranchInst::Create(BBTerm->getSuccessor(MinSucc), BBTerm);
BBTerm->eraseFromParent();
return true;
@@ -418,8 +419,8 @@ bool JumpThreading::ProcessBranchOnDuplicateCond(BasicBlock *PredBB,
else if (PredBI->getSuccessor(0) != BB)
BranchDir = false;
else {
- DOUT << " In block '" << PredBB->getNameStart()
- << "' folding terminator: " << *PredBB->getTerminator();
+ DEBUG(errs() << " In block '" << PredBB->getName()
+ << "' folding terminator: " << *PredBB->getTerminator());
++NumFolds;
ConstantFoldTerminator(PredBB);
return true;
@@ -430,9 +431,9 @@ bool JumpThreading::ProcessBranchOnDuplicateCond(BasicBlock *PredBB,
// If the dest block has one predecessor, just fix the branch condition to a
// constant and fold it.
if (BB->getSinglePredecessor()) {
- DOUT << " In block '" << BB->getNameStart()
- << "' folding condition to '" << BranchDir << "': "
- << *BB->getTerminator();
+ DEBUG(errs() << " In block '" << BB->getName()
+ << "' folding condition to '" << BranchDir << "': "
+ << *BB->getTerminator());
++NumFolds;
DestBI->setCondition(ConstantInt::get(Type::Int1Ty, BranchDir));
ConstantFoldTerminator(BB);
@@ -443,8 +444,8 @@ bool JumpThreading::ProcessBranchOnDuplicateCond(BasicBlock *PredBB,
// involves code duplication. Check to see if it is worth it.
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
if (JumpThreadCost > Threshold) {
- DOUT << " Not threading BB '" << BB->getNameStart()
- << "' - Cost is too high: " << JumpThreadCost << "\n";
+ DEBUG(errs() << " Not threading BB '" << BB->getName()
+ << "' - Cost is too high: " << JumpThreadCost << "\n");
return false;
}
@@ -507,8 +508,8 @@ bool JumpThreading::ProcessSwitchOnDuplicateCond(BasicBlock *PredBB,
// Otherwise, we're safe to make the change. Make sure that the edge from
// DestSI to DestSucc is not critical and has no PHI nodes.
- DOUT << "FORWARDING EDGE " << *DestVal << " FROM: " << *PredSI;
- DOUT << "THROUGH: " << *DestSI;
+ DEBUG(errs() << "FORWARDING EDGE " << *DestVal << " FROM: " << *PredSI);
+ DEBUG(errs() << "THROUGH: " << *DestSI);
// If the destination has PHI nodes, just split the edge for updating
// simplicity.
@@ -706,8 +707,8 @@ bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) {
BasicBlock *BB = PN->getParent();
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
if (JumpThreadCost > Threshold) {
- DOUT << " Not threading BB '" << BB->getNameStart()
- << "' - Cost is too high: " << JumpThreadCost << "\n";
+ DEBUG(errs() << " Not threading BB '" << BB->getName()
+ << "' - Cost is too high: " << JumpThreadCost << "\n");
return false;
}
@@ -771,8 +772,8 @@ bool JumpThreading::ProcessBranchOnLogical(Value *V, BasicBlock *BB,
// See if the cost of duplicating this block is low enough.
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
if (JumpThreadCost > Threshold) {
- DOUT << " Not threading BB '" << BB->getNameStart()
- << "' - Cost is too high: " << JumpThreadCost << "\n";
+ DEBUG(errs() << " Not threading BB '" << BB->getName()
+ << "' - Cost is too high: " << JumpThreadCost << "\n");
return false;
}
@@ -857,8 +858,8 @@ bool JumpThreading::ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB) {
// See if the cost of duplicating this block is low enough.
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
if (JumpThreadCost > Threshold) {
- DOUT << " Not threading BB '" << BB->getNameStart()
- << "' - Cost is too high: " << JumpThreadCost << "\n";
+ DEBUG(errs() << " Not threading BB '" << BB->getNameStart()
+ << "' - Cost is too high: " << JumpThreadCost << "\n");
return false;
}
@@ -882,26 +883,26 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
// If threading to the same block as we come from, we would infinite loop.
if (SuccBB == BB) {
- DOUT << " Not threading across BB '" << BB->getNameStart()
- << "' - would thread to self!\n";
+ DEBUG(errs() << " Not threading across BB '" << BB->getName()
+ << "' - would thread to self!\n");
return false;
}
// If threading this would thread across a loop header, don't thread the edge.
// See the comments above FindLoopHeaders for justifications and caveats.
if (LoopHeaders.count(BB)) {
- DOUT << " Not threading from '" << PredBB->getNameStart()
- << "' across loop header BB '" << BB->getNameStart()
- << "' to dest BB '" << SuccBB->getNameStart()
- << "' - it might create an irreducible loop!\n";
+ DEBUG(errs() << " Not threading from '" << PredBB->getName()
+ << "' across loop header BB '" << BB->getName()
+ << "' to dest BB '" << SuccBB->getName()
+ << "' - it might create an irreducible loop!\n");
return false;
}
// And finally, do it!
- DOUT << " Threading edge from '" << PredBB->getNameStart() << "' to '"
- << SuccBB->getNameStart() << "' with cost: " << JumpThreadCost
- << ", across block:\n "
- << *BB << "\n";
+ DEBUG(errs() << " Threading edge from '" << PredBB->getName() << "' to '"
+ << SuccBB->getNameStart() << "' with cost: " << JumpThreadCost
+ << ", across block:\n "
+ << *BB << "\n");
// Jump Threading can not update SSA properties correctly if the values
// defined in the duplicated block are used outside of the block itself. For
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 6b589151cf..98abfcce2b 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -186,7 +186,7 @@ public:
/// MarkBlockExecutable - This method can be used by clients to mark all of
/// the blocks that are known to be intrinsically live in the processed unit.
void MarkBlockExecutable(BasicBlock *BB) {
- DOUT << "Marking Block Executable: " << BB->getNameStart() << "\n";
+ DEBUG(errs() << "Marking Block Executable: " << BB->getName() << "\n");
BBExecutable.insert(BB); // Basic block is executable!
BBWorkList.push_back(BB); // Add the block to the work list!
}
@@ -262,14 +262,14 @@ private:
//
inline void markConstant(LatticeVal &IV, Value *V, Constant *C) {
if (IV.markConstant(C)) {
- DOUT << "markConstant: " << *C << ": " << *V;
+ DEBUG(errs() << "markConstant: " << *C << ": " << *V);
InstWorkList.push_back(V);
}
}
inline void markForcedConstant(LatticeVal &IV, Value *V, Constant *C) {
IV.markForcedConstant(C);
- DOUT << "markForcedConstant: " << *C << ": " << *V;
+ DEBUG(errs() << "markForcedConstant: " << *C << ": " << *V);
InstWorkList.push_back(V);
}
@@ -339,8 +339,8 @@ private:
return; // This edge is already known to be executable!
if (BBExecutable.count(Dest)) {
- DOUT << "Marking Edge Executable: " << Source->getNameStart()
- << " -> " << Dest->getNameStart() << "\n";
+ DEBUG(errs() << "Marking Edge Executable: " << Source->getName()
+ << " -> " << Dest->getName() << "\n");
// The destination is already executable, but we just made an edge
// feasible that wasn't before. Revisit the PHI nodes in the block
@@ -1278,7 +1278,7 @@ void SCCPSolver::Solve() {
Value *I = OverdefinedInstWorkList.back();
OverdefinedInstWorkList.pop_back();
- DOUT << "\nPopped off OI-WL: " << *I;
+ DEBUG(errs() << "\nPopped off OI-WL: " << *I);
// "I" got into the work list because it either made the transition from
// bottom to constant
@@ -1296,7 +1296,7 @@ void SCCPSolver::Solve() {
Value *I = InstWorkList.back();
InstWorkList.pop_back();
- DOUT << "\nPopped off I-WL: " << *I;
+ DEBUG(errs() << "\nPopped off I-WL: " << *I);
// "I" got into the work list because it either made the transition from
// bottom to constant
@@ -1316,7 +1316,7 @@ void SCCPSolver::Solve() {
BasicBlock *BB = BBWorkList.back();
BBWorkList.pop_back();
- DOUT << "\nPopped off BBWL: " << *BB;
+ DEBUG(errs() << "\nPopped off BBWL: " << *BB);
// Notify all instructions in this basic block that they are newly
// executable.
@@ -1536,7 +1536,7 @@ FunctionPass *llvm::createSCCPPass() {
// and return true if the function was modified.
//
bool SCCP::runOnFunction(Function &F) {
- DOUT << "SCCP on function '" << F.getNameStart() << "'\n";
+ DEBUG(errs() << "SCCP on function '" << F.getName() << "'\n");
SCCPSolver Solver;
Solver.setContext(&F.getContext());
@@ -1551,7 +1551,7 @@ bool SCCP::runOnFunction(Function &F) {
bool ResolvedUndefs = true;
while (ResolvedUndefs) {
Solver.Solve();
- DOUT << "RESOLVING UNDEFs\n";
+ DEBUG(errs() << "RESOLVING UNDEFs\n");
ResolvedUndefs = Solver.ResolvedUndefsIn(F);
}
@@ -1566,7 +1566,7 @@ bool SCCP::runOnFunction(Function &F) {
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
if (!Solver.isBlockExecutable(BB)) {
- DOUT << " BasicBlock Dead:" << *BB;
+ DEBUG(errs() << " BasicBlock Dead:" << *BB);
++NumDeadBlocks;
// Delete the instructions backwards, as it has a reduced likelihood of
@@ -1599,7 +1599,7 @@ bool SCCP::runOnFunction(Function &F) {
Constant *Const = IV.isConstant()
? IV.getConstant() : F.getContext().getUndef(Inst->getType());
- DOUT << " Constant: " << *Const << " = " << *Inst;
+ DEBUG(errs() << " Constant: " << *Const << " = " << *Inst);
// Replaces all of the uses of a variable with uses of the constant.
Inst->replaceAllUsesWith(Const);
@@ -1695,7 +1695,7 @@ bool IPSCCP::runOnModule(Module &M) {
while (ResolvedUndefs) {
Solver.Solve();
- DOUT << "RESOLVING UNDEFS\n";
+ DEBUG(errs() << "RESOLVING UNDEFS\n");
ResolvedUndefs = false;
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
ResolvedUndefs |= Solver.ResolvedUndefsIn(*F);
@@ -1718,7 +1718,7 @@ bool IPSCCP::runOnModule(Module &M) {
if (IV.isConstant() || IV.isUndefined()) {
Constant *CST = IV.isConstant() ?
IV.getConstant() : Context->getUndef(AI->getType());
- DOUT << "*** Arg " << *AI << " = " << *CST <<"\n";
+ DEBUG(errs() << "*** Arg " << *AI << " = " << *CST <<"\n");
// Replaces all of the uses of a variable with uses of the
// constant.
@@ -1729,7 +1729,7 @@ bool IPSCCP::runOnModule(Module &M) {
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
if (!Solver.isBlockExecutable(BB)) {
- DOUT << " BasicBlock Dead:" << *BB;
+ DEBUG(errs() << " BasicBlock Dead:" << *BB);
++IPNumDeadBlocks;
// Delete the instructions backwards, as it has a reduced likelihood of
@@ -1774,7 +1774,7 @@ bool IPSCCP::runOnModule(Module &M) {
Constant *Const = IV.isConstant()
? IV.getConstant() : Context->getUndef(Inst->getType());
- DOUT << " Constant: " << *Const << " = " << *Inst;
+ DEBUG(errs() << " Constant: " << *Const << " = " << *Inst);
// Replaces all of the uses of a variable with uses of the
// constant.
@@ -1858,7 +1858,7 @@ bool IPSCCP::runOnModule(Module &M) {
GlobalVariable *GV = I->first;
assert(!I->second.isOverdefined() &&
"Overdefined values should have been taken out of the map!");
- DOUT << "Found that GV '" << GV->getNameStart() << "' is constant!\n";
+ DEBUG(errs() << "Found that GV '" << GV->getName() << "' is constant!\n");
while (!GV->use_empty()) {
StoreInst *SI = cast<StoreInst>(GV->use_back());
SI->eraseFromParent();
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index 60895f3e8f..9a5ed456ba 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -1127,7 +1127,7 @@ struct VISIBILITY_HIDDEN UnaryDoubleFPOpt : public LibCallOptimization {
// floor((double)floatval) -> (double)floorf(floatval)
Value *V = Cast->getOperand(0);
- V = EmitUnaryFloatFnCall(V, Callee->getNameStart(), B);
+ V = EmitUnaryFloatFnCall(V, Callee->getName().data(), B);
return B.CreateFPExt(V, Type::DoubleTy);
}
};
@@ -1736,40 +1736,39 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
if (!F.isDeclaration())
continue;
- unsigned NameLen = F.getNameLen();
- if (!NameLen)
+ if (!F.hasName())
continue;
const FunctionType *FTy = F.getFunctionType();
- const char *NameStr = F.getNameStart();
- switch (NameStr[0]) {
+ StringRef Name = F.getName();
+ switch (Name[0]) {
case 's':
- if (NameLen == 6 && !strcmp(NameStr, "strlen")) {
+ if (Name == "strlen") {
if (FTy->getNumParams() != 1 ||
!isa<PointerType>(FTy->getParamType(0)))
continue;
setOnlyReadsMemory(F);
setDoesNotThrow(F);
setDoesNotCapture(F, 1);
- } else if ((NameLen == 6 && !strcmp(NameStr, "strcpy")) ||
- (NameLen == 6 && !strcmp(NameStr, "stpcpy")) ||
- (NameLen == 6 && !strcmp(NameStr, "strcat")) ||
- (NameLen == 6 && !strcmp(NameStr, "strtol")) ||
- (NameLen == 6 && !strcmp(NameStr, "strtod")) ||
- (NameLen == 6 && !strcmp(NameStr, "strtof")) ||
- (NameLen == 7 && !strcmp(NameStr, "strtoul")) ||
- (NameLen == 7 && !strcmp(NameStr, "strtoll")) ||
- (NameLen == 7 && !strcmp(NameStr, "strtold")) ||
- (NameLen == 7 && !strcmp(NameStr, "strncat")) ||
- (NameLen == 7 && !strcmp(NameStr, "strncpy")) ||
- (NameLen == 8 && !strcmp(NameStr, "strtoull"))) {
+ } else if (Name == "strcpy" ||
+ Name == "stpcpy" ||
+ Name == "strcat" ||
+ Name == "strtol" ||
+ Name == "strtod" ||
+ Name == "strtof" ||
+ Name == "strtoul" ||
+ Name == "strtoll" ||
+ Name == "strtold" ||
+ Name == "strncat" ||
+ Name == "strncpy" ||
+ Name == "strtoull") {
if (FTy->getNumParams() < 2 ||
!isa<PointerType>(FTy->getParamType(1)))
continue;
setDoesNotThrow(F);
setDoesNotCapture(F, 2);
- } else if (NameLen == 7 && !strcmp(NameStr, "strxfrm")) {
+ } else if (Name == "strxfrm") {
if (FTy->getNumParams() != 3 ||
!isa<PointerType>(FTy->getParamType(0)) ||
!isa<PointerType>(FTy->getParamType(1)))
@@ -1777,13 +1776,13 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
setDoesNotThrow(F);
setDoesNotCapture(F, 1);
setDoesNotCapture(F, 2);
- } else if ((NameLen == 6 && !strcmp(NameStr, "strcmp")) ||
- (NameLen == 6 && !strcmp(NameStr, "strspn")) ||
- (NameLen == 7 && !strcmp(NameStr, "strncmp")) ||
- (NameLen == 7 && !strcmp(NameStr, "strcspn")) ||
- (NameLen == 7 && !strcmp(NameStr, "strcoll")) ||
- (NameLen == 10 && !strcmp(NameStr, "strcasecmp")) ||
- (NameLen == 11 && !strcmp(NameStr, "strncasecmp"))) {
+ } else if (Name == "strcmp" ||
+ Name == "strspn" ||
+ Name == "strncmp" ||
+ Name ==" strcspn" ||
+ Name == "strcoll" ||
+ Name == "strcasecmp" ||
+ Name == "strncasecmp") {
if (FTy->getNumParams() < 2 ||
!isa<PointerType>(FTy->getParamType(0)) ||
!isa<PointerType>(FTy->getParamType(1)))
@@ -1792,31 +1791,31 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
setDoesNotThrow(F);
setDoesNotCapture(F, 1);
setDoesNotCapture(F, 2);
- } else if ((NameLen == 6 && !strcmp(NameStr, "strstr")) ||
- (NameLen == 7 && !strcmp(NameStr, "strpbrk"))) {
+ } else if (Name == "strstr" ||
+ Name == "strpbrk") {
if (FTy->getNumParams() != 2 ||
!isa<PointerType>(FTy->getParamType(1)))
continue;
setOnlyReadsMemory(F);
setDoesNotThrow(F);
setDoesNotCapture(F, 2);
- } else if ((NameLen == 6 && !strcmp(NameStr, "strtok")) ||
- (NameLen == 8 && !strcmp(NameStr, "strtok_r"))) {
+ } else if (Name == "strtok" ||
+ Name == "strtok_r") {
if (FTy->getNumParams() < 2 ||
!isa<PointerType>(FTy->getParamType(1)))
continue;
setDoesNotThrow(F);
setDoesNotCapture(F, 2);
- } else if ((NameLen == 5 && !strcmp(NameStr, "scanf")) ||
- (NameLen == 6 && !strcmp(NameStr, "setbuf")) ||
- (NameLen == 7 && !strcmp(NameStr, "setvbuf"))) {
+ } else if (Name == "scanf" ||
+ Name == "setbuf" ||
+ Name == "setvbuf") {
if (FTy->getNumParams() < 1 ||
!isa<PointerType>(FTy->getParamType(0)))
continue;
setDoesNotThrow(F);
setDoesNotCapture(F, 1);
- } else if ((NameLen == 6 && !strcmp(NameStr, "strdup")) ||
- (NameLen == 7 && !strcmp(NameStr, "strndup"))) {
+ } else if (Name == "strdup" ||
+ Name == "strndup") {
if (FTy->getNumParams() < 1 ||
!isa<PointerType>(FTy->getReturnType()) ||
!isa<PointerType>(FTy->getParamType(0)))
@@ -1824,10 +1823,10 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
setDoesNotThrow(F);
setDoesNotAlias(F, 0);
setDoesNotCapture(F, 1);
- } else if ((NameLen == 4 && !strcmp(NameStr, "stat")) ||
- (NameLen == 6 && !strcmp(NameStr, "sscanf")) ||
- (NameLen == 7 && !strcmp(NameStr, "sprintf")) ||
- (NameLen == 7 && !strcmp(NameStr, "statvfs"))) {
+ } else if (Name == "stat" ||
+ Name == "sscanf" ||
+ Name == "sprintf" ||
+ Name == "statvfs") {
if (FTy->getNumParams() < 2 ||
!isa<PointerType>(FTy->getParamType(0)) ||
!isa<PointerType>(FTy->getParamType(1)))
@@ -1835,7 +1834,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
setDoesNotThrow(F);
setDoesNotCapture(F, 1);
setDoesNotCapture(F, 2);
- } else if (NameLen == 8 && !strcmp(NameStr, "snprintf")) {
+ } else if (Name == "snprintf") {
if (FTy->getNumParams() != 3 ||
!isa<PointerType>(FTy->getParamType(0)) ||
!isa<PointerType>(FTy->getParamType(2)))
@@ -1843,7 +1842,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
setDoesNotThrow(F);
setDoesNotCapture(F, 1);
setDoesNotCapture(F, 3);
- } else if (NameLen == 9 && !strcmp(NameStr, "setitimer")) {
+ } else if (Name == "setitimer") {
if (FTy->getNumParams() != 3 ||
!isa<PointerType>(FTy->getParamType(1)) ||
!isa<PointerType>(FTy->getParamType(2)))
@@ -1851,7 +1850,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
setDoesNotThrow(F);
setDoesNotCapture(F, 2);
setDoesNotCapture(F, 3);
- } else if (NameLen == 6 && !strcmp(NameStr, "system")) {
+ } else if (Name == "system") {
if (FTy->getNumParams() != 1 ||
!isa<PointerType>(FTy->getParamType(0)))
continue;
@@ -1860,7 +1859,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
}
break;
case 'm':
- if (NameLen == 6 && !strcmp(NameStr, "memcmp")) {
+ if (Name == "memcmp") {
if (FTy->getNumParams() != 3 ||
!isa<PointerType>(FTy->getParamType(0)) ||
!isa<PointerType>(FTy->getParamType(1)))
@@ -1869,29 +1868,29 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
setDoesNotThrow(F);
setDoesNotCapture(F, 1);
setDoesNotCapture(F, 2);
- } else if ((NameLen == 6 && !strcmp(NameStr, "memchr")) ||
- (NameLen == 7 && !strcmp(NameStr, "memrchr"))) {
+ } else if (Name == "memchr" ||
+ Name == "memrchr") {
if (FTy->getNumParams() != 3)
continue;
setOnlyReadsMemory(F);
setDoesNotThrow(F);
- } else if ((NameLen == 4 && !strcmp(NameStr, "modf")) ||
- (NameLen == 5 && !strcmp(NameStr, "modff")) ||
- (NameLen == 5 && !strcmp(NameStr, "modfl")) ||
- (NameLen == 6 && !strcmp(NameStr, "memcpy")) ||
- (NameLen == 7 && !strcmp(NameStr, "memccpy")) ||
- (NameLen == 7 && !strcmp(NameStr, "memmove"))) {
+ } else if (Name == "modf" ||
+ Name == "modff" ||
+ Name == "modfl" ||
+ Name == "memcpy" ||
+ Name == "memccpy" ||
+ Name == "memmove") {
if (FTy->getNumParams() < 2 ||
!isa<PointerType>(FTy->getParamType(1)))
continue;
setDoesNotThrow(F);
setDoesNotCapture(F, 2);
- } else if (NameLen == 8 && !strcmp(NameStr, "memalign")) {
+ } else if (Name == "memalign") {
if (!isa<PointerType>(FTy->getReturnType()))
continue;
setDoesNotAlias(F, 0);
- } else if ((NameLen == 5 && !strcmp(NameStr, "mkdir")) ||
- (NameLen == 6 && !strcmp(NameStr, "mktime"))) {
+ } else if (Name == "mkdir" ||
+ Name == "mktime") {
if (FTy->getNumParams() == 0 ||
!isa<PointerType>(FTy->getParamType(0)))
continue;
@@ -1900,7 +1899,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) {
}
break;
case 'r':
- if (NameLen == 7 && !strcmp(NameStr, "realloc")) {
+