Switch obvious clients to Twine instead of utostr (when they were already using

a Twine, e.g., for names).
 - I am a little ambivalent about this; we don't want the string conversion of
   utostr, but using overload '+' mixed with string and integer arguments is
   sketchy. On the other hand, this particular usage is something of an idiom.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77579 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar
2009-07-30 04:20:37 +00:00
parent e409f0a779
commit 7f93dc8345
5 changed files with 15 additions and 20 deletions

View File

@@ -35,7 +35,6 @@
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h" #include "llvm/ADT/StringSet.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
@@ -218,7 +217,7 @@ namespace {
if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")";
if (ACPV->getPCAdjustment() != 0) { if (ACPV->getPCAdjustment() != 0) {
O << "-(" << TAI->getPrivateGlobalPrefix() << "PC" O << "-(" << TAI->getPrivateGlobalPrefix() << "PC"
<< utostr(ACPV->getLabelId()) << ACPV->getLabelId()
<< "+" << (unsigned)ACPV->getPCAdjustment(); << "+" << (unsigned)ACPV->getPCAdjustment();
if (ACPV->mustAddCurrentAddress()) if (ACPV->mustAddCurrentAddress())
O << "-."; O << "-.";

View File

@@ -47,7 +47,6 @@
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include <set> #include <set>
using namespace llvm; using namespace llvm;
@@ -765,9 +764,9 @@ Function *ArgPromotion::DoPromotion(Function *F,
Idxs[1] = ConstantInt::get(Type::Int32Ty, i); Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
Value *Idx = Value *Idx =
GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2, GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2,
TheAlloca->getName()+"."+utostr(i), TheAlloca->getName()+"."+i,
InsertPt); InsertPt);
I2->setName(I->getName()+"."+utostr(i)); I2->setName(I->getName()+"."+i);
new StoreInst(I2++, Idx, InsertPt); new StoreInst(I2++, Idx, InsertPt);
} }

View File

@@ -36,7 +36,6 @@
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include <algorithm> #include <algorithm>
using namespace llvm; using namespace llvm;
@@ -495,7 +494,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
GlobalVariable *NGV = new GlobalVariable(Context, GlobalVariable *NGV = new GlobalVariable(Context,
STy->getElementType(i), false, STy->getElementType(i), false,
GlobalVariable::InternalLinkage, GlobalVariable::InternalLinkage,
In, GV->getName()+"."+utostr(i), In, GV->getName()+"."+i,
GV->isThreadLocal(), GV->isThreadLocal(),
GV->getType()->getAddressSpace()); GV->getType()->getAddressSpace());
Globals.insert(GV, NGV); Globals.insert(GV, NGV);
@@ -531,7 +530,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
GlobalVariable *NGV = new GlobalVariable(Context, GlobalVariable *NGV = new GlobalVariable(Context,
STy->getElementType(), false, STy->getElementType(), false,
GlobalVariable::InternalLinkage, GlobalVariable::InternalLinkage,
In, GV->getName()+"."+utostr(i), In, GV->getName()+"."+i,
GV->isThreadLocal(), GV->isThreadLocal(),
GV->getType()->getAddressSpace()); GV->getType()->getAddressSpace());
Globals.insert(GV, NGV); Globals.insert(GV, NGV);
@@ -585,7 +584,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i) for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i)
Idxs.push_back(GEPI->getOperand(i)); Idxs.push_back(GEPI->getOperand(i));
NewPtr = GetElementPtrInst::Create(NewPtr, Idxs.begin(), Idxs.end(), NewPtr = GetElementPtrInst::Create(NewPtr, Idxs.begin(), Idxs.end(),
GEPI->getName()+"."+utostr(Val), GEPI); GEPI->getName()+"."+Val, GEPI);
} }
} }
GEP->replaceAllUsesWith(NewPtr); GEP->replaceAllUsesWith(NewPtr);
@@ -1153,7 +1152,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo,
Result = new LoadInst(GetHeapSROAValue(LI->getOperand(0), FieldNo, Result = new LoadInst(GetHeapSROAValue(LI->getOperand(0), FieldNo,
InsertedScalarizedValues, InsertedScalarizedValues,
PHIsToRewrite, Context), PHIsToRewrite, Context),
LI->getName()+".f" + utostr(FieldNo), LI); LI->getName()+".f" + FieldNo, LI);
} else if (PHINode *PN = dyn_cast<PHINode>(V)) { } else if (PHINode *PN = dyn_cast<PHINode>(V)) {
// PN's type is pointer to struct. Make a new PHI of pointer to struct // PN's type is pointer to struct. Make a new PHI of pointer to struct
// field. // field.
@@ -1162,7 +1161,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo,
Result = Result =
PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)), PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
PN->getName()+".f"+utostr(FieldNo), PN); PN->getName()+".f"+FieldNo, PN);
PHIsToRewrite.push_back(std::make_pair(PN, FieldNo)); PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
} else { } else {
llvm_unreachable("Unknown usable value"); llvm_unreachable("Unknown usable value");
@@ -1288,12 +1287,12 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
new GlobalVariable(*GV->getParent(), new GlobalVariable(*GV->getParent(),
PFieldTy, false, GlobalValue::InternalLinkage, PFieldTy, false, GlobalValue::InternalLinkage,
Context.getNullValue(PFieldTy), Context.getNullValue(PFieldTy),
GV->getName() + ".f" + utostr(FieldNo), GV, GV->getName() + ".f" + FieldNo, GV,
GV->isThreadLocal()); GV->isThreadLocal());
FieldGlobals.push_back(NGV); FieldGlobals.push_back(NGV);
MallocInst *NMI = new MallocInst(FieldTy, MI->getArraySize(), MallocInst *NMI = new MallocInst(FieldTy, MI->getArraySize(),
MI->getName() + ".f" + utostr(FieldNo),MI); MI->getName() + ".f" + FieldNo,MI);
FieldMallocs.push_back(NMI); FieldMallocs.push_back(NMI);
new StoreInst(NMI, NGV, MI); new StoreInst(NMI, NGV, MI);
} }

View File

@@ -41,7 +41,6 @@
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
using namespace llvm; using namespace llvm;
STATISTIC(NumReplaced, "Number of allocas broken up"); STATISTIC(NumReplaced, "Number of allocas broken up");
@@ -336,7 +335,7 @@ void SROA::DoScalarReplacement(AllocationInst *AI,
for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) { for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) {
AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0, AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0,
AI->getAlignment(), AI->getAlignment(),
AI->getName() + "." + utostr(i), AI); AI->getName() + "." + i, AI);
ElementAllocas.push_back(NA); ElementAllocas.push_back(NA);
WorkList.push_back(NA); // Add to worklist for recursive processing WorkList.push_back(NA); // Add to worklist for recursive processing
} }
@@ -346,7 +345,7 @@ void SROA::DoScalarReplacement(AllocationInst *AI,
const Type *ElTy = AT->getElementType(); const Type *ElTy = AT->getElementType();
for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) {
AllocaInst *NA = new AllocaInst(ElTy, 0, AI->getAlignment(), AllocaInst *NA = new AllocaInst(ElTy, 0, AI->getAlignment(),
AI->getName() + "." + utostr(i), AI); AI->getName() + "." + i, AI);
ElementAllocas.push_back(NA); ElementAllocas.push_back(NA);
WorkList.push_back(NA); // Add to worklist for recursive processing WorkList.push_back(NA); // Add to worklist for recursive processing
} }
@@ -777,7 +776,7 @@ void SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *BCInst,
if (OtherPtr) { if (OtherPtr) {
Value *Idx[2] = { Zero, ConstantInt::get(Type::Int32Ty, i) }; Value *Idx[2] = { Zero, ConstantInt::get(Type::Int32Ty, i) };
OtherElt = GetElementPtrInst::Create(OtherPtr, Idx, Idx + 2, OtherElt = GetElementPtrInst::Create(OtherPtr, Idx, Idx + 2,
OtherPtr->getNameStr()+"."+utostr(i), OtherPtr->getNameStr()+"."+i,
MI); MI);
uint64_t EltOffset; uint64_t EltOffset;
const PointerType *OtherPtrTy = cast<PointerType>(OtherPtr->getType()); const PointerType *OtherPtrTy = cast<PointerType>(OtherPtr->getType());

View File

@@ -30,7 +30,6 @@
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CFG.h" #include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
@@ -868,8 +867,8 @@ bool PromoteMem2Reg::QueuePhiNode(BasicBlock *BB, unsigned AllocaNo,
// Create a PhiNode using the dereferenced type... and add the phi-node to the // Create a PhiNode using the dereferenced type... and add the phi-node to the
// BasicBlock. // BasicBlock.
PN = PHINode::Create(Allocas[AllocaNo]->getAllocatedType(), PN = PHINode::Create(Allocas[AllocaNo]->getAllocatedType(),
Allocas[AllocaNo]->getName() + "." + Allocas[AllocaNo]->getName() + "." + Version++,
utostr(Version++), BB->begin()); BB->begin());
++NumPHIInsert; ++NumPHIInsert;
PhiToAllocaMap[PN] = AllocaNo; PhiToAllocaMap[PN] = AllocaNo;
PN->reserveOperandSpace(getNumPreds(BB)); PN->reserveOperandSpace(getNumPreds(BB));