Remove Value::getName{Start,End}, the last of the old Name APIs.

llvm-svn: 77152
This commit is contained in:
Daniel Dunbar 2009-07-26 09:48:23 +00:00
parent e59313a298
commit 6115b39ffd
21 changed files with 67 additions and 81 deletions

View File

@ -110,19 +110,6 @@ public:
// All values can potentially be named...
inline bool hasName() const { return Name != 0; }
ValueName *getValueName() const { return Name; }
/// getNameStart - Return a pointer to a null terminated string for this name.
/// Note that names can have null characters within the string as well as at
/// their end. This always returns a non-null pointer.
const char *getNameStart() const {
if (!Name) return "";
return getName().begin();
}
/// getNameEnd - Return a pointer to the end of the name.
const char *getNameEnd() const {
if (!Name) return "";
return getName().end();
}
/// getName() - Return a constant reference to the value's name. This is cheap
/// and guaranteed to return the same reference as long as the value is not

View File

@ -329,7 +329,7 @@ bool DISubprogram::describes(const Function *F) {
getLinkageName(Name);
if (Name.empty())
getName(Name);
if (!Name.empty() && (strcmp(Name.c_str(), F->getNameStart()) == false))
if (F->getName() == Name)
return true;
return false;
}
@ -1057,7 +1057,7 @@ namespace llvm {
for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
GVI != E; GVI++) {
GlobalVariable *GV = GVI;
if (GV->hasName() && strncmp(GV->getNameStart(), "llvm.dbg", 8) == 0
if (GV->hasName() && GV->getName().startswith("llvm.dbg")
&& GV->isConstant() && GV->hasInitializer()) {
DICompileUnit C(GV);
if (C.isNull() == false) {

View File

@ -109,7 +109,7 @@ bool CGPassManager::runOnModule(Module &M) {
for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
Function *F = SCC[i]->getFunction();
if (F) {
dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getNameStart());
dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getName());
Changed |= FPP->runOnFunction(*F);
}
}

View File

@ -19,6 +19,7 @@
#include "llvm/Instructions.h"
#include "llvm/LLVMContext.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
@ -88,7 +89,7 @@ void SparseSolver::UpdateState(Instruction &Inst, LatticeVal V) {
/// 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 SparseSolver::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!
}
@ -99,8 +100,8 @@ void SparseSolver::markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest) {
if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second)
return; // This edge is already known to be executable!
DOUT << "Marking Edge Executable: " << Source->getNameStart()
<< " -> " << Dest->getNameStart() << "\n";
DEBUG(errs() << "Marking Edge Executable: " << Source->getName()
<< " -> " << Dest->getName() << "\n");
if (BBExecutable.count(Dest)) {
// The destination is already executable, but we just made an edge
@ -284,7 +285,7 @@ void SparseSolver::Solve(Function &F) {
Instruction *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 made a transition. See if any
// users are both live and in need of updating.
@ -301,7 +302,7 @@ void SparseSolver::Solve(Function &F) {
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.

View File

@ -1611,7 +1611,7 @@ void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
O << ':';
if (printComment && MBB->getBasicBlock())
O << '\t' << TAI->getCommentString() << ' '
<< MBB->getBasicBlock()->getNameStart();
<< MBB->getBasicBlock()->getNameStr();
}
/// printPICJumpTableSetLabel - This method prints a set label for the

View File

@ -1120,9 +1120,8 @@ void DwarfDebug::ConstructFunctionDbgScope(DbgScope *RootScope,
/// ConstructDefaultDbgScope - Construct a default scope for the subprogram.
///
void DwarfDebug::ConstructDefaultDbgScope(MachineFunction *MF) {
const char *FnName = MF->getFunction()->getNameStart();
StringMap<DIE*> &Globals = ModuleCU->getGlobals();
StringMap<DIE*>::iterator GI = Globals.find(FnName);
StringMap<DIE*>::iterator GI = Globals.find(MF->getFunction()->getName());
if (GI != Globals.end()) {
DIE *SPDie = GI->second;

View File

@ -118,7 +118,7 @@ void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
if (FrameSize >= 1<<16) {
std::string msg;
raw_string_ostream Msg(msg);
Msg << "Function '" << FI.getFunction().getNameStart()
Msg << "Function '" << FI.getFunction().getName()
<< "' is too large for the ocaml GC! "
<< "Frame size " << FrameSize << " >= 65536.\n";
Msg << "(" << uintptr_t(&FI) << ")";
@ -126,14 +126,14 @@ void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
}
OS << "\t" << TAI.getCommentString() << " live roots for "
<< FI.getFunction().getNameStart() << "\n";
<< FI.getFunction().getName() << "\n";
for (GCFunctionInfo::iterator J = FI.begin(), JE = FI.end(); J != JE; ++J) {
size_t LiveCount = FI.live_size(J);
if (LiveCount >= 1<<16) {
std::string msg;
raw_string_ostream Msg(msg);
Msg << "Function '" << FI.getFunction().getNameStart()
Msg << "Function '" << FI.getFunction().getName()
<< "' is too large for the ocaml GC! "
<< "Live root count " << LiveCount << " >= 65536.";
llvm_report_error(Msg.str()); // Very rude!

View File

@ -153,12 +153,12 @@ bool Printer::runOnFunction(Function &F) {
if (!F.hasGC()) {
GCFunctionInfo *FD = &getAnalysis<GCModuleInfo>().getFunctionInfo(F);
OS << "GC roots for " << FD->getFunction().getNameStart() << ":\n";
OS << "GC roots for " << FD->getFunction().getNameStr() << ":\n";
for (GCFunctionInfo::roots_iterator RI = FD->roots_begin(),
RE = FD->roots_end(); RI != RE; ++RI)
OS << "\t" << RI->Num << "\t" << RI->StackOffset << "[sp]\n";
OS << "GC safe points for " << FD->getFunction().getNameStart() << ":\n";
OS << "GC safe points for " << FD->getFunction().getNameStr() << ":\n";
for (GCFunctionInfo::iterator PI = FD->begin(),
PE = FD->end(); PI != PE; ++PI) {

View File

@ -84,8 +84,7 @@ JITEventListener *createMacOSJITEventListener() {
void MacOSJITEventListener::NotifyFunctionEmitted(
const Function &F, void *FnStart, size_t FnSize,
const EmittedFunctionDetails &) {
const char *const FnName = F.getNameStart();
assert(FnName != 0 && FnStart != 0 && "Bad symbol to add");
assert(F.hasName() && FnStart != 0 && "Bad symbol to add");
JITSymbolTable **SymTabPtrPtr = 0;
SymTabPtrPtr = &__jitSymbolTable;
@ -120,7 +119,7 @@ void MacOSJITEventListener::NotifyFunctionEmitted(
// Otherwise, we have enough space, just tack it onto the end of the array.
JITSymbolEntry &Entry = SymTabPtr->Symbols[SymTabPtr->NumSymbols];
Entry.FnName = strdup(FnName);
Entry.FnName = strdup(F.getName().data());
Entry.FnStart = FnStart;
Entry.FnSize = FnSize;
++SymTabPtr->NumSymbols;

View File

@ -107,13 +107,13 @@ static debug_line_info LineStartToOProfileFormat(
void OProfileJITEventListener::NotifyFunctionEmitted(
const Function &F, void *FnStart, size_t FnSize,
const EmittedFunctionDetails &Details) {
const char *const FnName = F.getNameStart();
assert(FnName != 0 && FnStart != 0 && "Bad symbol to add");
if (op_write_native_code(Agent, FnName,
assert(F.hasName() && FnStart != 0 && "Bad symbol to add");
if (op_write_native_code(Agent, F.getName().data(),
reinterpret_cast<uint64_t>(FnStart),
FnStart, FnSize) == -1) {
DOUT << "Failed to tell OProfile about native function " << FnName
<< " at [" << FnStart << "-" << ((char*)FnStart + FnSize) << "]\n";
DEBUG(errs() << "Failed to tell OProfile about native function "
<< Fn.getName() << " at ["
<< FnStart << "-" << ((char*)FnStart + FnSize) << "]\n");
return;
}
@ -139,9 +139,10 @@ void OProfileJITEventListener::NotifyFunctionEmitted(
if (!LineInfo.empty()) {
if (op_write_debug_line_info(Agent, FnStart,
LineInfo.size(), &*LineInfo.begin()) == -1) {
DOUT << "Failed to tell OProfile about line numbers for native function "
<< FnName << " at [" << FnStart << "-" << ((char*)FnStart + FnSize)
<< "]\n";
DEBUG(errs()
<< "Failed to tell OProfile about line numbers for native function "
<< F.getName() << " at ["
<< FnStart << "-" << ((char*)FnStart + FnSize) << "]\n");
}
}
}

View File

@ -620,8 +620,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
NewRetIdxs[i] = RetTypes.size() - 1;
} else {
++NumRetValsEliminated;
DOUT << "DAE - Removing return value " << i << " from "
<< F->getNameStart() << "\n";
DEBUG(errs() << "DAE - Removing return value " << i << " from "
<< F->getName() << "\n");
}
}
else
@ -630,8 +630,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
RetTypes.push_back(RetTy);
NewRetIdxs[0] = 0;
} else {
DOUT << "DAE - Removing return value from " << F->getNameStart()
<< "\n";
DEBUG(errs() << "DAE - Removing return value from " << F->getName()
<< "\n");
++NumRetValsEliminated;
}
if (RetTypes.size() > 1)
@ -685,8 +685,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), Attrs));
} else {
++NumArgumentsEliminated;
DOUT << "DAE - Removing argument " << i << " (" << I->getNameStart()
<< ") from " << F->getNameStart() << "\n";
DEBUG(errs() << "DAE - Removing argument " << i << " (" << I->getName()
<< ") from " << F->getName() << "\n");
}
}

View File

@ -139,7 +139,7 @@ static void StripSymtab(ValueSymbolTable &ST, bool PreserveDbgInfo) {
Value *V = VI->getValue();
++VI;
if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasLocalLinkage()) {
if (!PreserveDbgInfo || strncmp(V->getNameStart(), "llvm.dbg", 8))
if (!PreserveDbgInfo || !V->getName().startswith("llvm.dbg"))
// Set name to "", removing from symbol table!
V->setName("");
}
@ -181,13 +181,13 @@ bool StripSymbolNames(Module &M, bool PreserveDbgInfo) {
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
if (I->hasLocalLinkage() && llvmUsedValues.count(I) == 0)
if (!PreserveDbgInfo || strncmp(I->getNameStart(), "llvm.dbg", 8))
if (!PreserveDbgInfo || !I->getName().startswith("llvm.dbg"))
I->setName(""); // Internal symbols can't participate in linkage
}
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
if (I->hasLocalLinkage() && llvmUsedValues.count(I) == 0)
if (!PreserveDbgInfo || strncmp(I->getNameStart(), "llvm.dbg", 8))
if (!PreserveDbgInfo || !I->getName().startswith("llvm.dbg"))
I->setName(""); // Internal symbols can't participate in linkage
StripSymtab(I->getValueSymbolTable(), PreserveDbgInfo);
}
@ -231,7 +231,7 @@ bool StripDebugInfo(Module &M) {
GlobalVariable *GV = dyn_cast<GlobalVariable>(I);
if (!GV) continue;
if (!GV->use_empty() && llvmUsedValues.count(I) == 0) {
if (strncmp(GV->getNameStart(), "llvm.dbg", 8) == 0) {
if (GV->getName().startswith("llvm.dbg")) {
GV->replaceAllUsesWith(M.getContext().getUndef(GV->getType()));
}
}
@ -410,8 +410,7 @@ bool StripDebugDeclare::runOnModule(Module &M) {
I != E; ++I) {
GlobalVariable *GV = dyn_cast<GlobalVariable>(I);
if (!GV) continue;
if (GV->use_empty() && GV->hasName()
&& strncmp(GV->getNameStart(), "llvm.dbg.global_variable", 24) == 0)
if (GV->use_empty() && GV->getName().startswith("llvm.dbg.global_variable"))
DeadConstants.push_back(GV);
}

View File

@ -35,6 +35,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
STATISTIC(NumRejectedSRETUses , "Number of sret rejected due to unexpected uses");
@ -90,7 +91,8 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
if (F->arg_size() == 0 || !F->hasStructRetAttr() || F->doesNotReturn())
return false;
DOUT << "SretPromotion: Looking at sret function " << F->getNameStart() << "\n";
DEBUG(errs() << "SretPromotion: Looking at sret function "
<< F->getName() << "\n");
assert (F->getReturnType() == Type::VoidTy && "Invalid function return type");
Function::arg_iterator AI = F->arg_begin();

View File

@ -733,7 +733,7 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(1) : NewEV);
Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(1));
ICmpInst *NewEC = new ICmpInst(EC->getParent()->getTerminator(),
NewPred, LHS, RHS, EC->getNameStart());
NewPred, LHS, RHS, EC->getName());
// In the following deltions, PH may become dead and may be deleted.
// Use a WeakVH to observe whether this happens.

View File

@ -5537,7 +5537,7 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I,
// computation crosses zero.
if (VariableIdx->getType()->getPrimitiveSizeInBits() > IntPtrWidth)
VariableIdx = new TruncInst(VariableIdx, TD.getIntPtrType(),
VariableIdx->getNameStart(), &I);
VariableIdx->getName(), &I);
return VariableIdx;
}
@ -5561,7 +5561,7 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I,
if (VariableIdx->getType() != IntPtrTy)
VariableIdx = CastInst::CreateIntegerCast(VariableIdx, IntPtrTy,
true /*SExt*/,
VariableIdx->getNameStart(), &I);
VariableIdx->getName(), &I);
Constant *OffsetVal = ConstantInt::get(IntPtrTy, NewOffs);
return BinaryOperator::CreateAdd(VariableIdx, OffsetVal, "offset", &I);
}

View File

@ -858,7 +858,7 @@ 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) {
DEBUG(errs() << " Not threading BB '" << BB->getNameStart()
DEBUG(errs() << " Not threading BB '" << BB->getName()
<< "' - Cost is too high: " << JumpThreadCost << "\n");
return false;
}
@ -900,7 +900,7 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
// And finally, do it!
DEBUG(errs() << " Threading edge from '" << PredBB->getName() << "' to '"
<< SuccBB->getNameStart() << "' with cost: " << JumpThreadCost
<< SuccBB->getName() << "' with cost: " << JumpThreadCost
<< ", across block:\n "
<< *BB << "\n");
@ -933,7 +933,7 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
// mapping and using it to remap operands in the cloned instructions.
for (; !isa<TerminatorInst>(BI); ++BI) {
Instruction *New = BI->clone(BI->getContext());
New->setName(BI->getNameStart());
New->setName(BI->getName());
NewBB->getInstList().push_back(New);
ValueMapping[BI] = New;

View File

@ -41,6 +41,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ValueHandle.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLowering.h"
#include <algorithm>
using namespace llvm;
@ -2523,11 +2524,9 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) {
Changed = false;
if (!IU->IVUsesByStride.empty()) {
#ifndef NDEBUG
DOUT << "\nLSR on \"" << L->getHeader()->getParent()->getNameStart()
<< "\" ";
DEBUG(L->dump());
#endif
DEBUG(errs() << "\nLSR on \"" << L->getHeader()->getParent()->getName()
<< "\" ";
L->dump());
// Sort the StrideOrder so we process larger strides first.
std::stable_sort(IU->StrideOrder.begin(), IU->StrideOrder.end(),

View File

@ -442,7 +442,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
// Cast the start ptr to be i8* as memset requires.
const Type *i8Ptr = SI->getContext().getPointerTypeUnqual(Type::Int8Ty);
if (StartPtr->getType() != i8Ptr)
StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getNameStart(),
StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(),
InsertPt);
Value *Ops[] = {

View File

@ -135,8 +135,7 @@ bool SimplifyHalfPowrLibCalls::runOnFunction(Function &F) {
Function *Callee = CI->getCalledFunction();
if (Callee && Callee->hasExternalLinkage()) {
// Look for calls with well-known names.
const char *CalleeName = Callee->getNameStart();
if (strcmp(CalleeName, "__half_powrf4") == 0)
if (Callee->getName() == "__half_powrf4")
IsHalfPowr = true;
}
}

View File

@ -86,8 +86,8 @@ static void AddPredecessorToBlock(BasicBlock *Succ, BasicBlock *NewPred,
static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
assert(*succ_begin(BB) == Succ && "Succ is not successor of BB!");
DOUT << "Looking to fold " << BB->getNameStart() << " into "
<< Succ->getNameStart() << "\n";
DEBUG(errs() << "Looking to fold " << BB->getName() << " into "
<< Succ->getName() << "\n");
// Shortcut, if there is only a single predecessor it must be BB and merging
// is always safe
if (Succ->getSinglePredecessor()) return true;
@ -128,10 +128,10 @@ static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
PI != PE; PI++) {
if (BBPN->getIncomingValueForBlock(*PI)
!= PN->getIncomingValueForBlock(*PI)) {
DOUT << "Can't fold, phi node " << *PN->getNameStart() << " in "
<< Succ->getNameStart() << " is conflicting with "
<< BBPN->getNameStart() << " with regard to common predecessor "
<< (*PI)->getNameStart() << "\n";
DEBUG(errs() << "Can't fold, phi node " << PN->getName() << " in "
<< Succ->getName() << " is conflicting with "
<< BBPN->getName() << " with regard to common predecessor "
<< (*PI)->getName() << "\n");
return false;
}
}
@ -146,9 +146,9 @@ static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
// one for BB, in which case this phi node will not prevent the merging
// of the block.
if (Val != PN->getIncomingValueForBlock(*PI)) {
DOUT << "Can't fold, phi node " << *PN->getNameStart() << " in "
<< Succ->getNameStart() << " is conflicting with regard to common "
<< "predecessor " << (*PI)->getNameStart() << "\n";
DEBUG(errs() << "Can't fold, phi node " << PN->getName() << " in "
<< Succ->getName() << " is conflicting with regard to common "
<< "predecessor " << (*PI)->getName() << "\n");
return false;
}
}
@ -166,9 +166,9 @@ static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
for (BlockSet::iterator PI = CommonPreds.begin(), PE = CommonPreds.end();
PI != PE; PI++)
if (PN->getIncomingValueForBlock(*PI) != PN) {
DOUT << "Can't fold, phi node " << *PN->getNameStart() << " in "
<< BB->getNameStart() << " is conflicting with regard to common "
<< "predecessor " << (*PI)->getNameStart() << "\n";
DEBUG(errs() << "Can't fold, phi node " << PN->getName() << " in "
<< BB->getName() << " is conflicting with regard to common "
<< "predecessor " << (*PI)->getName() << "\n");
return false;
}
}

View File

@ -327,7 +327,7 @@ void LTOModule::addDefinedSymbol(GlobalValue* def, Mangler &mangler,
bool isFunction)
{
// ignore all llvm.* symbols
if ( strncmp(def->getNameStart(), "llvm.", 5) == 0 )
if (def->getName().startswith("llvm."))
return;
// string is owned by _defines
@ -397,7 +397,7 @@ void LTOModule::addAsmGlobalSymbol(const char *name) {
void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)
{
// ignore all llvm.* symbols
if ( strncmp(decl->getNameStart(), "llvm.", 5) == 0 )
if (decl->getName().startswith("llvm."))
return;
// ignore all aliases