diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVNPRE.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/VMCore/BasicBlock.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Function.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Globals.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 160 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Value.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 10 | 
9 files changed, 104 insertions, 98 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 95f0ecefa5f..8831d3520b6 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -34,8 +34,8 @@ using namespace llvm;  // Error - Simple wrapper function to conditionally assign to E and return true.  // This just makes error return conditions a little bit simpler... -static inline bool Error(std::string *E, const std::string &Message) { -  if (E) *E = Message; +static inline bool Error(std::string *E, const Twine &Message) { +  if (E) *E = Message.str();    return true;  } diff --git a/llvm/lib/Transforms/Scalar/GVNPRE.cpp b/llvm/lib/Transforms/Scalar/GVNPRE.cpp index 4588a7f24c5..459636156a4 100644 --- a/llvm/lib/Transforms/Scalar/GVNPRE.cpp +++ b/llvm/lib/Transforms/Scalar/GVNPRE.cpp @@ -869,7 +869,8 @@ Value* GVNPRE::phi_translate(Value* V, BasicBlock* pred, BasicBlock* succ) {                                   newOp1, newOp2,                                   C->getName()+".expr");        else if (ExtractElementInst* E = dyn_cast<ExtractElementInst>(U)) -        newVal = ExtractElementInst::Create(newOp1, newOp2, E->getName()+".expr"); +        newVal = ExtractElementInst::Create(newOp1, newOp2,  +                                            E->getName()+".expr");        uint32_t v = VN.lookup_or_add(newVal); diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 3376e867563..a182943c784 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1443,7 +1443,8 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, uint64_t Offset) {      if (StoreInst *SI = dyn_cast<StoreInst>(User)) {        assert(SI->getOperand(0) != Ptr && "Consistency error!"); -      Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str()); +      // FIXME: Remove once builder has Twine API. +      Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str());        Value *New = ConvertScalar_InsertValue(SI->getOperand(0), Old, Offset,                                               Builder);        Builder.CreateStore(New, NewAI); @@ -1467,7 +1468,8 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, uint64_t Offset) {            for (unsigned i = 1; i != NumBytes; ++i)              APVal |= APVal << 8; -        Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str()); +        // FIXME: Remove once builder has Twine API. +        Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str());          Value *New = ConvertScalar_InsertValue(                                      ConstantInt::get(User->getContext(), APVal),                                                 Old, Offset, Builder); diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp index df27811ee63..d0fa02ce1cd 100644 --- a/llvm/lib/VMCore/BasicBlock.cpp +++ b/llvm/lib/VMCore/BasicBlock.cpp @@ -39,7 +39,7 @@ LLVMContext &BasicBlock::getContext() const {  template class SymbolTableListTraits<Instruction, BasicBlock>; -BasicBlock::BasicBlock(const std::string &Name, Function *NewParent, +BasicBlock::BasicBlock(const Twine &Name, Function *NewParent,                         BasicBlock *InsertBefore)    : Value(Type::LabelTy, Value::BasicBlockVal), Parent(0) { @@ -240,7 +240,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,  /// cause a degenerate basic block to be formed, having a terminator inside of  /// the basic block).  /// -BasicBlock *BasicBlock::splitBasicBlock(iterator I, const std::string &BBName) { +BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {    assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");    assert(I != InstList.end() &&           "Trying to get me to create degenerate basic block!"); diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index 49238429640..cdf2dd07fa6 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -36,7 +36,7 @@ template class SymbolTableListTraits<BasicBlock, Function>;  // Argument Implementation  //===----------------------------------------------------------------------===// -Argument::Argument(const Type *Ty, const std::string &Name, Function *Par) +Argument::Argument(const Type *Ty, const Twine &Name, Function *Par)    : Value(Ty, Value::ArgumentVal) {    Parent = 0; @@ -144,7 +144,7 @@ void Function::eraseFromParent() {  //===----------------------------------------------------------------------===//  Function::Function(const FunctionType *Ty, LinkageTypes Linkage, -                   const std::string &name, Module *ParentModule) +                   const Twine &name, Module *ParentModule)    : GlobalValue(PointerType::getUnqual(Ty),                   Value::FunctionVal, 0, 0, Linkage, name) {    assert(FunctionType::isValidReturnType(getReturnType()) && diff --git a/llvm/lib/VMCore/Globals.cpp b/llvm/lib/VMCore/Globals.cpp index bb750be8ada..aa4c30aab08 100644 --- a/llvm/lib/VMCore/Globals.cpp +++ b/llvm/lib/VMCore/Globals.cpp @@ -96,7 +96,7 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {  GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,                                 bool constant, LinkageTypes Link, -                               Constant *InitVal, const std::string &Name, +                               Constant *InitVal, const Twine &Name,                                 bool ThreadLocal, unsigned AddressSpace)    : GlobalValue(Context.getPointerType(Ty, AddressSpace),                   Value::GlobalVariableVal, @@ -114,7 +114,7 @@ GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,  GlobalVariable::GlobalVariable(Module &M, const Type *Ty, bool constant,                                 LinkageTypes Link, Constant *InitVal, -                               const std::string &Name, +                               const Twine &Name,                                 GlobalVariable *Before, bool ThreadLocal,                                 unsigned AddressSpace)    : GlobalValue(M.getContext().getPointerType(Ty, AddressSpace),  diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index e1583c9ffd2..20de3fecf86 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -351,7 +351,7 @@ void CallInst::init(Value *Func) {    assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");  } -CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name, +CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,                     Instruction *InsertBefore)    : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())                                     ->getElementType())->getReturnType(), @@ -362,7 +362,7 @@ CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,    setName(Name);  } -CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name, +CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,                     BasicBlock  *InsertAtEnd)    : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())                                     ->getElementType())->getReturnType(), @@ -372,7 +372,7 @@ CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,    init(Func, Actual);    setName(Name);  } -CallInst::CallInst(Value *Func, const std::string &Name, +CallInst::CallInst(Value *Func, const Twine &Name,                     Instruction *InsertBefore)    : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())                                     ->getElementType())->getReturnType(), @@ -383,7 +383,7 @@ CallInst::CallInst(Value *Func, const std::string &Name,    setName(Name);  } -CallInst::CallInst(Value *Func, const std::string &Name, +CallInst::CallInst(Value *Func, const Twine &Name,                     BasicBlock *InsertAtEnd)    : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())                                     ->getElementType())->getReturnType(), @@ -714,7 +714,7 @@ static Value *getAISize(LLVMContext &Context, Value *Amt) {  }  AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, -                               unsigned Align, const std::string &Name, +                               unsigned Align, const Twine &Name,                                 Instruction *InsertBefore)    : UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,                       getAISize(Ty->getContext(), ArraySize), InsertBefore) { @@ -724,7 +724,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,  }  AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, -                               unsigned Align, const std::string &Name, +                               unsigned Align, const Twine &Name,                                 BasicBlock *InsertAtEnd)    : UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,                       getAISize(Ty->getContext(), ArraySize), InsertAtEnd) { @@ -806,7 +806,7 @@ void LoadInst::AssertOK() {           "Ptr must have pointer type.");  } -LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) +LoadInst::LoadInst(Value *Ptr, const Twine &Name, Instruction *InsertBef)    : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),                       Load, Ptr, InsertBef) {    setVolatile(false); @@ -815,7 +815,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)    setName(Name);  } -LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE) +LoadInst::LoadInst(Value *Ptr, const Twine &Name, BasicBlock *InsertAE)    : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),                       Load, Ptr, InsertAE) {    setVolatile(false); @@ -824,7 +824,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)    setName(Name);  } -LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, +LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,                     Instruction *InsertBef)    : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),                       Load, Ptr, InsertBef) { @@ -834,7 +834,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,    setName(Name);  } -LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,  +LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,                      unsigned Align, Instruction *InsertBef)    : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),                       Load, Ptr, InsertBef) { @@ -844,7 +844,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,    setName(Name);  } -LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,  +LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,                      unsigned Align, BasicBlock *InsertAE)    : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),                       Load, Ptr, InsertAE) { @@ -854,7 +854,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,    setName(Name);  } -LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, +LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,                     BasicBlock *InsertAE)    : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),                       Load, Ptr, InsertAE) { @@ -1013,7 +1013,7 @@ static unsigned retrieveAddrSpace(const Value *Val) {  }  void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx, -                             const std::string &Name) { +                             const Twine &Name) {    assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");    Use *OL = OperandList;    OL[0] = Ptr; @@ -1024,7 +1024,7 @@ void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx,    setName(Name);  } -void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) { +void GetElementPtrInst::init(Value *Ptr, Value *Idx, const Twine &Name) {    assert(NumOperands == 2 && "NumOperands not initialized?");    Use *OL = OperandList;    OL[0] = Ptr; @@ -1045,7 +1045,7 @@ GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)  }  GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, -                                     const std::string &Name, Instruction *InBe) +                                     const Twine &Name, Instruction *InBe)    : Instruction(Ptr->getType()->getContext().getPointerType(        checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)),                  GetElementPtr, @@ -1055,7 +1055,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,  }  GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, -                                     const std::string &Name, BasicBlock *IAE) +                                     const Twine &Name, BasicBlock *IAE)    : Instruction(Ptr->getType()->getContext().getPointerType(              checkType(getIndexedType(Ptr->getType(),Idx)),                    retrieveAddrSpace(Ptr)), @@ -1164,7 +1164,7 @@ bool GetElementPtrInst::hasAllConstantIndices() const {  //===----------------------------------------------------------------------===//  ExtractElementInst::ExtractElementInst(Value *Val, Value *Index, -                                       const std::string &Name, +                                       const Twine &Name,                                         Instruction *InsertBef)    : Instruction(cast<VectorType>(Val->getType())->getElementType(),                  ExtractElement, @@ -1178,7 +1178,7 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,  }  ExtractElementInst::ExtractElementInst(Value *Val, Value *Index, -                                       const std::string &Name, +                                       const Twine &Name,                                         BasicBlock *InsertAE)    : Instruction(cast<VectorType>(Val->getType())->getElementType(),                  ExtractElement, @@ -1212,7 +1212,7 @@ InsertElementInst::InsertElementInst(const InsertElementInst &IE)    Op<2>() = IE.Op<2>();  }  InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, -                                     const std::string &Name, +                                     const Twine &Name,                                       Instruction *InsertBef)    : Instruction(Vec->getType(), InsertElement,                  OperandTraits<InsertElementInst>::op_begin(this), @@ -1226,7 +1226,7 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,  }  InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, -                                     const std::string &Name, +                                     const Twine &Name,                                       BasicBlock *InsertAE)    : Instruction(Vec->getType(), InsertElement,                  OperandTraits<InsertElementInst>::op_begin(this), @@ -1268,7 +1268,7 @@ ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV)  }  ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, -                                     const std::string &Name, +                                     const Twine &Name,                                       Instruction *InsertBefore)  : Instruction(V1->getType()->getContext().getVectorType(                                cast<VectorType>(V1->getType())->getElementType(), @@ -1286,7 +1286,7 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,  }  ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, -                                     const std::string &Name, +                                     const Twine &Name,                                       BasicBlock *InsertAtEnd)    : Instruction(V1->getType(), ShuffleVector,                  OperandTraits<ShuffleVectorInst>::op_begin(this), @@ -1333,7 +1333,7 @@ int ShuffleVectorInst::getMaskValue(unsigned i) const {  //===----------------------------------------------------------------------===//  void InsertValueInst::init(Value *Agg, Value *Val, const unsigned *Idx,  -                           unsigned NumIdx, const std::string &Name) { +                           unsigned NumIdx, const Twine &Name) {    assert(NumOperands == 2 && "NumOperands not initialized?");    Op<0>() = Agg;    Op<1>() = Val; @@ -1343,7 +1343,7 @@ void InsertValueInst::init(Value *Agg, Value *Val, const unsigned *Idx,  }  void InsertValueInst::init(Value *Agg, Value *Val, unsigned Idx,  -                           const std::string &Name) { +                           const Twine &Name) {    assert(NumOperands == 2 && "NumOperands not initialized?");    Op<0>() = Agg;    Op<1>() = Val; @@ -1363,7 +1363,7 @@ InsertValueInst::InsertValueInst(const InsertValueInst &IVI)  InsertValueInst::InsertValueInst(Value *Agg,                                   Value *Val,                                   unsigned Idx,  -                                 const std::string &Name, +                                 const Twine &Name,                                   Instruction *InsertBefore)    : Instruction(Agg->getType(), InsertValue,                  OperandTraits<InsertValueInst>::op_begin(this), @@ -1374,7 +1374,7 @@ InsertValueInst::InsertValueInst(Value *Agg,  InsertValueInst::InsertValueInst(Value *Agg,                                   Value *Val,                                   unsigned Idx,  -                                 const std::string &Name, +                                 const Twine &Name,                                   BasicBlock *InsertAtEnd)    : Instruction(Agg->getType(), InsertValue,                  OperandTraits<InsertValueInst>::op_begin(this), @@ -1387,14 +1387,14 @@ InsertValueInst::InsertValueInst(Value *Agg,  //===----------------------------------------------------------------------===//  void ExtractValueInst::init(const unsigned *Idx, unsigned NumIdx, -                            const std::string &Name) { +                            const Twine &Name) {    assert(NumOperands == 1 && "NumOperands not initialized?");    Indices.insert(Indices.end(), Idx, Idx + NumIdx);    setName(Name);  } -void ExtractValueInst::init(unsigned Idx, const std::string &Name) { +void ExtractValueInst::init(unsigned Idx, const Twine &Name) {    assert(NumOperands == 1 && "NumOperands not initialized?");    Indices.push_back(Idx); @@ -1457,7 +1457,7 @@ static BinaryOperator::BinaryOps AdjustIType(BinaryOperator::BinaryOps iType,  }  BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, -                               const Type *Ty, const std::string &Name, +                               const Type *Ty, const Twine &Name,                                 Instruction *InsertBefore)    : Instruction(Ty, AdjustIType(iType, Ty),                  OperandTraits<BinaryOperator>::op_begin(this), @@ -1470,7 +1470,7 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,  }  BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,  -                               const Type *Ty, const std::string &Name, +                               const Type *Ty, const Twine &Name,                                 BasicBlock *InsertAtEnd)    : Instruction(Ty, AdjustIType(iType, Ty),                  OperandTraits<BinaryOperator>::op_begin(this), @@ -1559,7 +1559,7 @@ void BinaryOperator::init(BinaryOps iType) {  }  BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2, -                                       const std::string &Name, +                                       const Twine &Name,                                         Instruction *InsertBefore) {    assert(S1->getType() == S2->getType() &&           "Cannot create binary operator with two operands of differing type!"); @@ -1567,7 +1567,7 @@ BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,  }  BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2, -                                       const std::string &Name, +                                       const Twine &Name,                                         BasicBlock *InsertAtEnd) {    BinaryOperator *Res = Create(Op, S1, S2, Name);    InsertAtEnd->getInstList().push_back(Res); @@ -1575,7 +1575,7 @@ BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,  }  BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context, -                                          Value *Op, const std::string &Name, +                                          Value *Op, const Twine &Name,                                            Instruction *InsertBefore) {    Value *zero = Context.getZeroValueForNegation(Op->getType());    return new BinaryOperator(Instruction::Sub, @@ -1584,7 +1584,7 @@ BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,  }  BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,  -                                          Value *Op, const std::string &Name, +                                          Value *Op, const Twine &Name,                                            BasicBlock *InsertAtEnd) {    Value *zero = Context.getZeroValueForNegation(Op->getType());    return new BinaryOperator(Instruction::Sub, @@ -1593,7 +1593,7 @@ BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,  }  BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context, -                                           Value *Op, const std::string &Name, +                                           Value *Op, const Twine &Name,                                             Instruction *InsertBefore) {    Value *zero = Context.getZeroValueForNegation(Op->getType());    return new BinaryOperator(Instruction::FSub, @@ -1602,7 +1602,7 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,  }  BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context, -                                           Value *Op, const std::string &Name, +                                           Value *Op, const Twine &Name,                                             BasicBlock *InsertAtEnd) {    Value *zero = Context.getZeroValueForNegation(Op->getType());    return new BinaryOperator(Instruction::FSub, @@ -1611,7 +1611,7 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,  }  BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context, -                                          Value *Op, const std::string &Name, +                                          Value *Op, const Twine &Name,                                            Instruction *InsertBefore) {    Constant *C;    if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) { @@ -1627,7 +1627,7 @@ BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,  }  BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context, -                                          Value *Op, const std::string &Name, +                                          Value *Op, const Twine &Name,                                            BasicBlock *InsertAtEnd) {    Constant *AllOnes;    if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) { @@ -1952,7 +1952,7 @@ unsigned CastInst::isEliminableCastPair(  }  CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,  -  const std::string &Name, Instruction *InsertBefore) { +  const Twine &Name, Instruction *InsertBefore) {    // Construct and return the appropriate CastInst subclass    switch (op) {      case Trunc:    return new TruncInst    (S, Ty, Name, InsertBefore); @@ -1974,7 +1974,7 @@ CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,  }  CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty, -  const std::string &Name, BasicBlock *InsertAtEnd) { +  const Twine &Name, BasicBlock *InsertAtEnd) {    // Construct and return the appropriate CastInst subclass    switch (op) {      case Trunc:    return new TruncInst    (S, Ty, Name, InsertAtEnd); @@ -1996,7 +1996,7 @@ CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,  }  CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,  -                                        const std::string &Name, +                                        const Twine &Name,                                          Instruction *InsertBefore) {    if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())      return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); @@ -2004,7 +2004,7 @@ CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,  }  CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,  -                                        const std::string &Name, +                                        const Twine &Name,                                          BasicBlock *InsertAtEnd) {    if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())      return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); @@ -2012,7 +2012,7 @@ CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,  }  CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,  -                                        const std::string &Name, +                                        const Twine &Name,                                          Instruction *InsertBefore) {    if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())      return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); @@ -2020,7 +2020,7 @@ CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,  }  CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,  -                                        const std::string &Name, +                                        const Twine &Name,                                          BasicBlock *InsertAtEnd) {    if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())      return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); @@ -2028,7 +2028,7 @@ CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,  }  CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty, -                                         const std::string &Name, +                                         const Twine &Name,                                           Instruction *InsertBefore) {    if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())      return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); @@ -2036,7 +2036,7 @@ CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,  }  CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty, -                                         const std::string &Name,  +                                         const Twine &Name,                                            BasicBlock *InsertAtEnd) {    if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())      return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); @@ -2044,7 +2044,7 @@ CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,  }  CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty, -                                      const std::string &Name, +                                      const Twine &Name,                                        BasicBlock *InsertAtEnd) {    assert(isa<PointerType>(S->getType()) && "Invalid cast");    assert((Ty->isInteger() || isa<PointerType>(Ty)) && @@ -2057,7 +2057,7 @@ CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,  /// @brief Create a BitCast or a PtrToInt cast instruction  CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,  -                                      const std::string &Name,  +                                      const Twine &Name,                                         Instruction *InsertBefore) {    assert(isa<PointerType>(S->getType()) && "Invalid cast");    assert((Ty->isInteger() || isa<PointerType>(Ty)) && @@ -2069,7 +2069,7 @@ CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,  }  CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,  -                                      bool isSigned, const std::string &Name, +                                      bool isSigned, const Twine &Name,                                        Instruction *InsertBefore) {    assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");    unsigned SrcBits = C->getType()->getScalarSizeInBits(); @@ -2082,7 +2082,7 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,  }  CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,  -                                      bool isSigned, const std::string &Name, +                                      bool isSigned, const Twine &Name,                                        BasicBlock *InsertAtEnd) {    assert(C->getType()->isIntOrIntVector() && Ty->isIntOrIntVector() &&           "Invalid cast"); @@ -2096,7 +2096,7 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,  }  CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,  -                                 const std::string &Name,  +                                 const Twine &Name,                                    Instruction *InsertBefore) {    assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&           "Invalid cast"); @@ -2109,7 +2109,7 @@ CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,  }  CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,  -                                 const std::string &Name,  +                                 const Twine &Name,                                    BasicBlock *InsertAtEnd) {    assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&           "Invalid cast"); @@ -2353,144 +2353,144 @@ CastInst::castIsValid(Instruction::CastOps op, Value *S, const Type *DstTy) {  }  TruncInst::TruncInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, Trunc, S, Name, InsertBefore) {    assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");  }  TruncInst::TruncInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, Trunc, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");  }  ZExtInst::ZExtInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  )  : CastInst(Ty, ZExt, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");  }  ZExtInst::ZExtInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  )  : CastInst(Ty, ZExt, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");  }  SExtInst::SExtInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, SExt, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");  }  SExtInst::SExtInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  )  : CastInst(Ty, SExt, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");  }  FPTruncInst::FPTruncInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, FPTrunc, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");  }  FPTruncInst::FPTruncInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, FPTrunc, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");  }  FPExtInst::FPExtInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, FPExt, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");  }  FPExtInst::FPExtInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, FPExt, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");  }  UIToFPInst::UIToFPInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, UIToFP, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");  }  UIToFPInst::UIToFPInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, UIToFP, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");  }  SIToFPInst::SIToFPInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, SIToFP, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");  }  SIToFPInst::SIToFPInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, SIToFP, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");  }  FPToUIInst::FPToUIInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, FPToUI, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");  }  FPToUIInst::FPToUIInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, FPToUI, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");  }  FPToSIInst::FPToSIInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, FPToSI, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");  }  FPToSIInst::FPToSIInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, FPToSI, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");  }  PtrToIntInst::PtrToIntInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, PtrToInt, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");  }  PtrToIntInst::PtrToIntInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, PtrToInt, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");  }  IntToPtrInst::IntToPtrInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, IntToPtr, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");  }  IntToPtrInst::IntToPtrInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, IntToPtr, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");  }  BitCastInst::BitCastInst( -  Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore +  Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore  ) : CastInst(Ty, BitCast, S, Name, InsertBefore) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");  }  BitCastInst::BitCastInst( -  Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd +  Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd  ) : CastInst(Ty, BitCast, S, Name, InsertAtEnd) {     assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");  } @@ -2500,7 +2500,7 @@ BitCastInst::BitCastInst(  //===----------------------------------------------------------------------===//  CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate, -                 Value *LHS, Value *RHS, const std::string &Name, +                 Value *LHS, Value *RHS, const Twine &Name,                   Instruction *InsertBefore)    : Instruction(ty, op,                  OperandTraits<CmpInst>::op_begin(this), @@ -2513,7 +2513,7 @@ CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,  }  CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate, -                 Value *LHS, Value *RHS, const std::string &Name, +                 Value *LHS, Value *RHS, const Twine &Name,                   BasicBlock *InsertAtEnd)    : Instruction(ty, op,                  OperandTraits<CmpInst>::op_begin(this), @@ -2528,7 +2528,7 @@ CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,  CmpInst *  CmpInst::Create(LLVMContext &Context, OtherOps Op, unsigned short predicate,                  Value *S1, Value *S2,  -                const std::string &Name, Instruction *InsertBefore) { +                const Twine &Name, Instruction *InsertBefore) {    if (Op == Instruction::ICmp) {      if (InsertBefore)        return new ICmpInst(InsertBefore, CmpInst::Predicate(predicate), @@ -2548,7 +2548,7 @@ CmpInst::Create(LLVMContext &Context, OtherOps Op, unsigned short predicate,  CmpInst *  CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2,  -                const std::string &Name, BasicBlock *InsertAtEnd) { +                const Twine &Name, BasicBlock *InsertAtEnd) {    if (Op == Instruction::ICmp) {      return new ICmpInst(*InsertAtEnd, CmpInst::Predicate(predicate),                          S1, S2, Name); diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp index 71dec841f45..d020c399fd0 100644 --- a/llvm/lib/VMCore/Value.cpp +++ b/llvm/lib/VMCore/Value.cpp @@ -20,6 +20,7 @@  #include "llvm/Module.h"  #include "llvm/MDNode.h"  #include "llvm/ValueSymbolTable.h" +#include "llvm/ADT/SmallString.h"  #include "llvm/Support/Debug.h"  #include "llvm/Support/ErrorHandling.h"  #include "llvm/Support/LeakDetector.h" @@ -183,8 +184,10 @@ StringRef Value::getNameRef() const {    return StringRef(Name->getKeyData(), Name->getKeyLength());  } -void Value::setName(const std::string &name) { -  setName(&name[0], name.size()); +void Value::setName(const Twine &Name) { +  SmallString<32> NameData; +  Name.toVector(NameData); +  setName(NameData.begin(), NameData.size());  }  void Value::setName(const char *Name) { diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index 4b15e3acb3f..f900dcad2a4 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -304,10 +304,10 @@ namespace {      // CheckFailed - A check failed, so print out the condition and the message      // that failed.  This provides a nice place to put a breakpoint if you want      // to see why something is not correct. -    void CheckFailed(const std::string &Message, +    void CheckFailed(const Twine &Message,                       const Value *V1 = 0, const Value *V2 = 0,                       const Value *V3 = 0, const Value *V4 = 0) { -      msgs << Message << "\n"; +      msgs << Message.str() << "\n";        WriteValue(V1);        WriteValue(V2);        WriteValue(V3); @@ -315,9 +315,9 @@ namespace {        Broken = true;      } -    void CheckFailed( const std::string& Message, const Value* V1, -                      const Type* T2, const Value* V3 = 0 ) { -      msgs << Message << "\n"; +    void CheckFailed(const Twine &Message, const Value* V1, +                     const Type* T2, const Value* V3 = 0) { +      msgs << Message.str() << "\n";        WriteValue(V1);        WriteType(T2);        WriteValue(V3);  | 

