diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 07:49:05 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 07:49:05 +0000 |
commit | 93b67e40de356569493c285b86b138a3f11b5035 (patch) | |
tree | c24ec4151ac85c2506a255bdb847cbe3c152baa1 /lib/Transforms | |
parent | f40761d5229322c08701049f89aa10f7f7b8b743 (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
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/JumpThreading.cpp | 69 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 34 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SimplifyLibCalls.cpp | 331 |
3 files changed, 217 insertions, 217 deletions
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")) { + if (Name == "realloc") { if (FTy->getNumParams() != 2 || !isa<PointerType>(FTy->getParamType(0)) || !isa<PointerType>(FTy->getReturnType())) @@ -1908,23 +1907,23 @@ bool SimplifyLibCalls::doInitialization(Module &M) { setDoesNotThrow(F); setDoesNotAlias(F, 0); setDoesNotCapture(F, 1); - } else if (NameLen == 4 && !strcmp(NameStr, "read")) { + } else if (Name == "read") { if (FTy->getNumParams() != 3 || !isa<PointerType>(FTy->getParamType(1))) continue; // May throw; "read" is a valid pthread cancellation point. setDoesNotCapture(F, 2); - } else if ((NameLen == 5 && !strcmp(NameStr, "rmdir")) || - (NameLen == 6 && !strcmp(NameStr, "rewind")) || - (NameLen == 6 && !strcmp(NameStr, "remove")) || - (NameLen == 8 && !strcmp(NameStr, "realpath"))) { + } else if (Name == "rmdir" || + Name == "rewind" || + Name == "remove" || + Name == "realpath") { if (FTy->getNumParams() < 1 || !isa<PointerType>(FTy->getParamType(0))) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); - } else if ((NameLen == 6 && !strcmp(NameStr, "rename")) || - (NameLen == 8 && !strcmp(NameStr, "readlink"))) { + } else if (Name == "rename" || + Name == "readlink") { if (FTy->getNumParams() < 2 || !isa<PointerType>(FTy->getParamType(0)) || !isa<PointerType>(FTy->getParamType(1))) @@ -1935,7 +1934,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) { } break; case 'w': - if (NameLen == 5 && !strcmp(NameStr, "write")) { + if (Name == "write") { if (FTy->getNumParams() != 3 || !isa<PointerType>(FTy->getParamType(1))) continue; @@ -1944,7 +1943,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) { } break; case 'b': - if (NameLen == 5 && !strcmp(NameStr, "bcopy")) { + if (Name == "bcopy") { if (FTy->getNumParams() != 3 || !isa<PointerType>(FTy->getParamType(0)) || !isa<PointerType>(FTy->getParamType(1))) @@ -1952,7 +1951,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) { setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); - } else if (NameLen == 4 && !strcmp(NameStr, "bcmp")) { + } else if (Name == "bcmp") { if (FTy->getNumParams() != 3 || !isa<PointerType>(FTy->getParamType(0)) || !isa<PointerType>(FTy->getParamType(1))) @@ -1961,7 +1960,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) { setOnlyReadsMemory(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); - } else if (NameLen == 5 && !strcmp(NameStr, "bzero")) { + } else if (Name == "bzero") { if (FTy->getNumParams() != 2 || !isa<PointerType>(FTy->getParamType(0))) continue; @@ -1970,17 +1969,17 @@ bool SimplifyLibCalls::doInitialization(Module &M) { } break; case 'c': - if (NameLen == 6 && !strcmp(NameStr, "calloc")) { + if (Name == "calloc") { if (FTy->getNumParams() != 2 || !isa<PointerType>(FTy->getReturnType())) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); - } else if ((NameLen == 5 && !strcmp(NameStr, "chmod")) || - (NameLen == 5 && !strcmp(NameStr, "chown")) || - (NameLen == 7 && !strcmp(NameStr, "ctermid")) || - (NameLen == 8 && !strcmp(NameStr, "clearerr")) || - (NameLen == 8 && !strcmp(NameStr, "closedir"))) { + } else if (Name == "chmod" || + Name == "chown" || + Name == "ctermid" || + Name == "clearerr" || + Name == "closedir") { if (FTy->getNumParams() == 0 || !isa<PointerType>(FTy->getParamType(0))) continue; @@ -1989,17 +1988,17 @@ bool SimplifyLibCalls::doInitialization(Module &M) { } break; case 'a': - if ((NameLen == 4 && !strcmp(NameStr, "atoi")) || - (NameLen == 4 && !strcmp(NameStr, "atol")) || - (NameLen == 4 && !strcmp(NameStr, "atof")) || - (NameLen == 5 && !strcmp(NameStr, "atoll"))) { + if (Name == "atoi" || + Name == "atol" || + Name == "atof" || + Name == "atoll") { if (FTy->getNumParams() != 1 || !isa<PointerType>(FTy->getParamType(0))) continue; setDoesNotThrow(F); setOnlyReadsMemory(F); setDoesNotCapture(F, 1); - } else if (NameLen == 6 && !strcmp(NameStr, "access")) { + } else if (Name == "access") { if (FTy->getNumParams() != 2 || !isa<PointerType>(FTy->getParamType(0))) continue; @@ -2008,7 +2007,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) { } break; case 'f': - if (NameLen == 5 && !strcmp(NameStr, "fopen")) { + if (Name == "fopen") { if (FTy->getNumParams() != 2 || !isa<PointerType>(FTy->getReturnType()) || !isa<PointerType>(FTy->getParamType(0)) || @@ -2018,7 +2017,7 @@ bool SimplifyLibCalls::doInitialization(Module &M) { setDoesNotAlias(F, 0); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); - } else if (NameLen == 6 && !strcmp(NameStr, "fdopen")) { + } else if (Name == "fdopen") { if (FTy->getNumParams() != 2 || !isa<PointerType>(FTy->getReturnType()) || !isa<PointerType>(FTy->getParamType(1))) @@ -2026,52 +2025,52 @@ bool SimplifyLibCalls::doInitialization(Module &M) { setDoesNotThrow(F); setDoesNotAlias(F, 0); setDoesNotCapture(F, 2); - } else if ((NameLen == 4 && !strcmp(NameStr, "feof")) || - (NameLen == 4 && !strcmp(NameStr, "free")) || - (NameLen == 5 && !strcmp(NameStr, "fseek")) || - (NameLen == 5 && !strcmp(NameStr, "ftell")) || - (NameLen == 5 && !strcmp(NameStr, "fgetc")) || - (NameLen == 6 && !strcmp(NameStr, "fseeko")) || - (NameLen == 6 && !strcmp(NameStr, "ftello")) || - (NameLen == 6 && !strcmp(NameStr, "fileno")) || - (NameLen == 6 && !strcmp(NameStr, "fflush")) || - (NameLen == 6 && !strcmp(NameStr, "fclose")) || - (NameLen == 7 && !strcmp(NameStr, "fsetpos")) || - (NameLen == 9 && !strcmp(NameStr, "flockfile")) || - (NameLen == 11 && !strcmp(NameStr, "funlockfile")) || - (NameLen == 12 && !strcmp(NameStr, "ftrylockfile"))) { + } else if (Name == "feof" || + Name == "free" || + Name == "fseek" || + Name == "ftell" || + Name == "fgetc" || + Name == "fseeko" || + Name == "ftello" || + Name == "fileno" || + Name == "fflush" || + Name == "fclose" || + Name == "fsetpos" || + Name == "flockfile" || + Name == "funlockfile" || + Name == "ftrylockfile") { if (FTy->getNumParams() == 0 || !isa<PointerType>(FTy->getParamType(0))) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); - } else if (NameLen == 6 && !strcmp(NameStr, "ferror")) { + } else if (Name == "ferror") { if (FTy->getNumParams() != 1 || !isa<PointerType>(FTy->getParamType(0))) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); setOnlyReadsMemory(F); - } else if ((NameLen == 5 && !strcmp(NameStr, "fputc")) || - (NameLen == 5 && !strcmp(NameStr, "fstat")) || - (NameLen == 5 && !strcmp(NameStr, "frexp")) || - (NameLen == 6 && !strcmp(NameStr, "frexpf")) || - (NameLen == 6 && !strcmp(NameStr, "frexpl")) || - (NameLen == 8 && !strcmp(NameStr, "fstatvfs"))) { + } else if (Name == "fputc" || + Name == "fstat" || + Name == "frexp" || + Name == "frexpf" || + Name == "frexpl" || + Name == "fstatvfs") { if (FTy->getNumParams() != 2 || !isa<PointerType>(FTy->getParamType(1))) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); - } else if (NameLen == 5 && !strcmp(NameStr, "fgets")) { + } else if (Name == "fgets") { if (FTy->getNumParams() != 3 || !isa<PointerType>(FTy->getParamType(0)) || !isa<PointerType>(FTy->getParamType(2))) continue; setDoesNotThrow(F); setDoesNotCapture(F, 3); - } else if ((NameLen == 5 && !strcmp(NameStr, "fread")) || - (NameLen == 6 && !strcmp(NameStr, "fwrite"))) { + } else if (Name == "fread" || + Name == "fwrite") { if (FTy->getNumParams() != 4 || !isa<PointerType>(FTy->getParamType(0)) || !isa<PointerType>(FTy->getParamType(3))) @@ -2079,10 +2078,10 @@ bool SimplifyLibCalls::doInitialization(Module &M) { setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 4); - } else if ((NameLen == 5 && !strcmp(NameStr, "fputs")) || - (NameLen == 6 && !strcmp(NameStr, "fscanf")) || - (NameLen == 7 && !strcmp(NameStr, "fprintf")) || - (NameLen == 7 && !strcmp(NameStr, "fgetpos"))) { + } else if (Name == "fputs" || + Name == "fscanf" || |