llvm.org GIT mirror llvm / 6e0d1cb
Initial update to VMCore to use Twines for string arguments. - The only meat here is in Value.{h,cpp} the rest is essential 'const std::string &' -> 'const Twine &'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77048 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 11 years ago
19 changed file(s) with 393 addition(s) and 277 deletion(s). Raw diff Collapse all Expand all
2828
2929
  • The isa<>, cast<>
  • 3030 and dyn_cast<> templates
    31
  • Passing strings (the StringRef
  • 32 and Twine classes)
    33
    34
  • The StringRef class
  • 35
  • The Twine class
  • 36
    3137
  • The DEBUG() macro and -debug
  • 3238 option
    3339
    423429
    424430
    425431
    432
    433
    434
    435 Passing strings (the StringRef
    436 and Twine classes)
    437
    438
    439
    440
    441

    Although LLVM generally does not do much string manipulation, we do have

    442 several important APIs which take string. Several important examples are the
    443 Value class -- which has names for instructions, functions, etc. -- and the
    444 StringMap class which is used extensively in LLVM and Clang.

    445
    446

    These are generic classes, and they need to be able to accept strings which

    447 may have embedded null characters. Therefore, they cannot simply take
    448 a const char *, and taking a const std::string& requires
    449 clients to perform a heap allocation which is usually unnecessary. Instead,
    450 many LLVM APIs use a const StringRef& or a const Twine& for
    451 passing strings efficiently.

    452
    453
    454
    455
    456
    457 The StringRef class
    458
    459
    460
    461
    462

    The StringRef data type represents a reference to a constant string

    463 (a character array and a length) and supports the common operations available
    464 on std:string, but does not require heap allocation.

    465
    466 It can be implicitly constructed using either a C style null-terminated string
    467 or an std::string, or explicitly with a character pointer and length.
    468 For example, the StringRef find function is declared as:

    469
    470 iterator find(const StringRef &Key);
    471
    472
    473

    and clients can call it using any one of:

    474
    475
    476
    
                      
                    
    477 Map.find("foo"); // Lookup "foo"
    478 Map.find(std::string("bar")); // Lookup "bar"
    479 Map.find(StringRef("\0baz", 4)); // Lookup "\0baz"
    480
    481
    482
    483

    Similarly, APIs which need to return a string may return a StringRef

    484 instance, which can be used directly or converted to an std::string
    485 using the str member function. See
    486 "llvm/ADT/StringRef.h"
    487 for more information.

    488
    489

    You should rarely use the StringRef class directly, because it contains

    490 pointers to external memory it is not generally safe to store an instance of the
    491 class (since the external storage may be freed).

    492
    493
    494
    495
    496
    497 The Twine class
    498
    499
    500
    501
    502

    The Twine class is an efficient way for APIs to accept concatenated

    503 strings. For example, a common LLVM paradigm is to name one instruction based on
    504 the name of another instruction with a suffix, for example:

    505
    506
    507
    
                      
                    
    508 New = CmpInst::Create(..., SO->getName() + ".cmp");
    509
    510
    511
    512

    The Twine class is effectively a

    513 lightweight rope
    514 which points to temporary (stack allocated) objects. Twines can be implicitly
    515 constructed as the result of the plus operator applied to strings (i.e., a C
    516 strings, an std::string, or a StringRef). The twine delays the
    517 actual concatentation of strings until it is actually required, at which point
    518 it can be efficiently rendered directly into a character array. This avoids
    519 unnecessary heap allocation involved in constructing the temporary results of
    520 string concatenation. See
    521 "llvm/ADT/Twine.h"
    522 for more information.

    523
    524

    As with a StringRef, Twine objects point to external memory

    525 and should almost never be stored or mentioned directly. They are intended
    526 solely for use when defining a function which should be able to efficiently
    527 accept concatenated strings.

    528
    529
    530
    531
    426532
    427533
    428534 The DEBUG() macro and -debug option
    459459
  • SCEVHandle no longer exists, because reference counting is no
  • 460460 longer done for SCEV* objects, instead const SCEV* should be
    461461 used.
    462
  • Many APIs, notably llvm::Value, now use the StringRef
  • 463 and Twine classes instead of passing const char*
    464 or std::string, as described in
    465 the Programmer's Manual. Most
    466 clients should be uneffected by this transition.
    462467
  • llvm-dis now fails if output file exists, instead of dumping to stdout.
  • 463 FIXME: describe any other tool changes due to the raw_fd_ostream change
    468 FIXME: describe any other tool changes due to the raw_fd_ostream change. FIXME:
    469 This is not an API change, maybe there should be a tool changes section?
    464470
  • temporarely due to Context API change passes should call doInitialization()
  • 465471 method of the pass they inherit from, otherwise Context is NULL.
    466472 FIXME: remove this entry when this is no longer needed.
  • 3737 /// Argument ctor - If Function argument is specified, this argument is
    3838 /// inserted at the end of the argument list for the function.
    3939 ///
    40 explicit Argument(const Type *Ty, const std::string &Name = "",
    41 Function *F = 0);
    40 explicit Argument(const Type *Ty, const Twine &Name = "", Function *F = 0);
    4241
    4342 inline const Function *getParent() const { return Parent; }
    4443 inline Function *getParent() { return Parent; }
    8282 /// is automatically inserted at either the end of the function (if
    8383 /// InsertBefore is null), or before the specified basic block.
    8484 ///
    85 explicit BasicBlock(const std::string &Name = "", Function *Parent = 0,
    85 explicit BasicBlock(const Twine &Name = "", Function *Parent = 0,
    8686 BasicBlock *InsertBefore = 0);
    8787 public:
    8888 /// getContext - Get the context in which this basic block lives,
    9696 /// Create - Creates a new BasicBlock. If the Parent parameter is specified,
    9797 /// the basic block is automatically inserted at either the end of the
    9898 /// function (if InsertBefore is 0), or before the specified basic block.
    99 static BasicBlock *Create(const std::string &Name = "", Function *Parent = 0,
    99 static BasicBlock *Create(const Twine &Name = "", Function *Parent = 0,
    100100 BasicBlock *InsertBefore = 0) {
    101101 return new BasicBlock(Name, Parent, InsertBefore);
    102102 }
    231231 /// cause a degenerate basic block to be formed, having a terminator inside of
    232232 /// the basic block).
    233233 ///
    234 BasicBlock *splitBasicBlock(iterator I, const std::string &BBName = "");
    234 BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "");
    235235 };
    236236
    237237 } // End llvm namespace
    113113 /// the module.
    114114 ///
    115115 Function(const FunctionType *Ty, LinkageTypes Linkage,
    116 const std::string &N = "", Module *M = 0);
    116 const Twine &N = "", Module *M = 0);
    117117
    118118 public:
    119119 static Function *Create(const FunctionType *Ty, LinkageTypes Linkage,
    120 const std::string &N = "", Module *M = 0) {
    120 const Twine &N = "", Module *M = 0) {
    121121 return new(0) Function(Ty, Linkage, N, M);
    122122 }
    123123
    5555
    5656 protected:
    5757 GlobalValue(const Type *ty, ValueTy vty, Use *Ops, unsigned NumOps,
    58 LinkageTypes linkage, const std::string &name = "")
    58 LinkageTypes linkage, const Twine &Name = "")
    5959 : Constant(ty, vty, Ops, NumOps), Parent(0),
    6060 Linkage(linkage), Visibility(DefaultVisibility), Alignment(0) {
    61 if (!name.empty()) setName(name);
    61 setName(Name);
    6262 }
    6363
    6464 Module *Parent;
    5151 /// automatically inserted into the end of the specified modules global list.
    5252 GlobalVariable(LLVMContext &Context, const Type *Ty, bool isConstant,
    5353 LinkageTypes Linkage,
    54 Constant *Initializer = 0, const std::string &Name = "",
    54 Constant *Initializer = 0, const Twine &Name = "",
    5555 bool ThreadLocal = false, unsigned AddressSpace = 0);
    5656 /// GlobalVariable ctor - This creates a global and inserts it before the
    5757 /// specified other global.
    5858 GlobalVariable(Module &M, const Type *Ty, bool isConstant,
    5959 LinkageTypes Linkage, Constant *Initializer,
    60 const std::string &Name,
    60 const Twine &Name,
    6161 GlobalVariable *InsertBefore = 0, bool ThreadLocal = false,
    6262 unsigned AddressSpace = 0);
    6363
    143143 protected:
    144144 void init(BinaryOps iType);
    145145 BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
    146 const std::string &Name, Instruction *InsertBefore);
    146 const Twine &Name, Instruction *InsertBefore);
    147147 BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
    148 const std::string &Name, BasicBlock *InsertAtEnd);
    148 const Twine &Name, BasicBlock *InsertAtEnd);
    149149 public:
    150150 // allocate space for exactly two operands
    151151 void *operator new(size_t s) {
    161161 /// Instruction is allowed to be a dereferenced end iterator.
    162162 ///
    163163 static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
    164 const std::string &Name = "",
    164 const Twine &Name = "",
    165165 Instruction *InsertBefore = 0);
    166166
    167167 /// Create() - Construct a binary instruction, given the opcode and the two
    169169 /// BasicBlock specified.
    170170 ///
    171171 static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
    172 const std::string &Name,
    173 BasicBlock *InsertAtEnd);
    172 const Twine &Name, BasicBlock *InsertAtEnd);
    174173
    175174 /// Create* - These methods just forward to Create, and are useful when you
    176175 /// statically know what type of instruction you're going to create. These
    177176 /// helpers just save some typing.
    178177 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
    179178 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
    180 const std::string &Name = "") {\
    179 const Twine &Name = "") {\
    181180 return Create(Instruction::OPC, V1, V2, Name);\
    182181 }
    183182 #include "llvm/Instruction.def"
    184183 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
    185184 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
    186 const std::string &Name, BasicBlock *BB) {\
    185 const Twine &Name, BasicBlock *BB) {\
    187186 return Create(Instruction::OPC, V1, V2, Name, BB);\
    188187 }
    189188 #include "llvm/Instruction.def"
    190189 #define HANDLE_BINARY_INST(N, OPC, CLASS) \
    191190 static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
    192 const std::string &Name, Instruction *I) {\
    191 const Twine &Name, Instruction *I) {\
    193192 return Create(Instruction::OPC, V1, V2, Name, I);\
    194193 }
    195194 #include "llvm/Instruction.def"
    202201 /// instructions out of SUB and XOR instructions.
    203202 ///
    204203 static BinaryOperator *CreateNeg(LLVMContext &Context,
    205 Value *Op, const std::string &Name = "",
    204 Value *Op, const Twine &Name = "",
    206205 Instruction *InsertBefore = 0);
    207206 static BinaryOperator *CreateNeg(LLVMContext &Context,
    208 Value *Op, const std::string &Name,
    207 Value *Op, const Twine &Name,
    209208 BasicBlock *InsertAtEnd);
    210209 static BinaryOperator *CreateFNeg(LLVMContext &Context,
    211 Value *Op, const std::string &Name = "",
    210 Value *Op, const Twine &Name = "",
    212211 Instruction *InsertBefore = 0);
    213212 static BinaryOperator *CreateFNeg(LLVMContext &Context,
    214 Value *Op, const std::string &Name,
    213 Value *Op, const Twine &Name,
    215214 BasicBlock *InsertAtEnd);
    216215 static BinaryOperator *CreateNot(LLVMContext &Context,
    217 Value *Op, const std::string &Name = "",
    216 Value *Op, const Twine &Name = "",
    218217 Instruction *InsertBefore = 0);
    219218 static BinaryOperator *CreateNot(LLVMContext &Context,
    220 Value *Op, const std::string &Name,
    219 Value *Op, const Twine &Name,
    221220 BasicBlock *InsertAtEnd);
    222221
    223222 /// isNeg, isFNeg, isNot - Check if the given Value is a
    287286 protected:
    288287 /// @brief Constructor with insert-before-instruction semantics for subclasses
    289288 CastInst(const Type *Ty, unsigned iType, Value *S,
    290 const std::string &NameStr = "", Instruction *InsertBefore = 0)
    289 const Twine &NameStr = "", Instruction *InsertBefore = 0)
    291290 : UnaryInstruction(Ty, iType, S, InsertBefore) {
    292291 setName(NameStr);
    293292 }
    294293 /// @brief Constructor with insert-at-end-of-block semantics for subclasses
    295294 CastInst(const Type *Ty, unsigned iType, Value *S,
    296 const std::string &NameStr, BasicBlock *InsertAtEnd)
    295 const Twine &NameStr, BasicBlock *InsertAtEnd)
    297296 : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
    298297 setName(NameStr);
    299298 }
    308307 Instruction::CastOps, ///< The opcode of the cast instruction
    309308 Value *S, ///< The value to be casted (operand 0)
    310309 const Type *Ty, ///< The type to which cast should be made
    311 const std::string &Name = "", ///< Name for the instruction
    310 const Twine &Name = "", ///< Name for the instruction
    312311 Instruction *InsertBefore = 0 ///< Place to insert the instruction
    313312 );
    314313 /// Provides a way to construct any of the CastInst subclasses using an
    321320 Instruction::CastOps, ///< The opcode for the cast instruction
    322321 Value *S, ///< The value to be casted (operand 0)
    323322 const Type *Ty, ///< The type to which operand is casted
    324 const std::string &Name, ///< The name for the instruction
    323 const Twine &Name, ///< The name for the instruction
    325324 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    326325 );
    327326
    329328 static CastInst *CreateZExtOrBitCast(
    330329 Value *S, ///< The value to be casted (operand 0)
    331330 const Type *Ty, ///< The type to which cast should be made
    332 const std::string &Name = "", ///< Name for the instruction
    331 const Twine &Name = "", ///< Name for the instruction
    333332 Instruction *InsertBefore = 0 ///< Place to insert the instruction
    334333 );
    335334
    337336 static CastInst *CreateZExtOrBitCast(
    338337 Value *S, ///< The value to be casted (operand 0)
    339338 const Type *Ty, ///< The type to which operand is casted
    340 const std::string &Name, ///< The name for the instruction
    339 const Twine &Name, ///< The name for the instruction
    341340 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    342341 );
    343342
    345344 static CastInst *CreateSExtOrBitCast(
    346345 Value *S, ///< The value to be casted (operand 0)
    347346 const Type *Ty, ///< The type to which cast should be made
    348 const std::string &Name = "", ///< Name for the instruction
    347 const Twine &Name = "", ///< Name for the instruction
    349348 Instruction *InsertBefore = 0 ///< Place to insert the instruction
    350349 );
    351350
    353352 static CastInst *CreateSExtOrBitCast(
    354353 Value *S, ///< The value to be casted (operand 0)
    355354 const Type *Ty, ///< The type to which operand is casted
    356 const std::string &Name, ///< The name for the instruction
    355 const Twine &Name, ///< The name for the instruction
    357356 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    358357 );
    359358
    361360 static CastInst *CreatePointerCast(
    362361 Value *S, ///< The pointer value to be casted (operand 0)
    363362 const Type *Ty, ///< The type to which operand is casted
    364 const std::string &Name, ///< The name for the instruction
    363 const Twine &Name, ///< The name for the instruction
    365364 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    366365 );
    367366
    369368 static CastInst *CreatePointerCast(
    370369 Value *S, ///< The pointer value to be casted (operand 0)
    371370 const Type *Ty, ///< The type to which cast should be made
    372 const std::string &Name = "", ///< Name for the instruction
    371 const Twine &Name = "", ///< Name for the instruction
    373372 Instruction *InsertBefore = 0 ///< Place to insert the instruction
    374373 );
    375374
    378377 Value *S, ///< The pointer value to be casted (operand 0)
    379378 const Type *Ty, ///< The type to which cast should be made
    380379 bool isSigned, ///< Whether to regard S as signed or not
    381 const std::string &Name = "", ///< Name for the instruction
    380 const Twine &Name = "", ///< Name for the instruction
    382381 Instruction *InsertBefore = 0 ///< Place to insert the instruction
    383382 );
    384383
    387386 Value *S, ///< The integer value to be casted (operand 0)
    388387 const Type *Ty, ///< The integer type to which operand is casted
    389388 bool isSigned, ///< Whether to regard S as signed or not
    390 const std::string &Name, ///< The name for the instruction
    389 const Twine &Name, ///< The name for the instruction
    391390 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    392391 );
    393392
    395394 static CastInst *CreateFPCast(
    396395 Value *S, ///< The floating point value to be casted
    397396 const Type *Ty, ///< The floating point type to cast to
    398 const std::string &Name = "", ///< Name for the instruction
    397 const Twine &Name = "", ///< Name for the instruction
    399398 Instruction *InsertBefore = 0 ///< Place to insert the instruction
    400399 );
    401400
    403402 static CastInst *CreateFPCast(
    404403 Value *S, ///< The floating point value to be casted
    405404 const Type *Ty, ///< The floating point type to cast to
    406 const std::string &Name, ///< The name for the instruction
    405 const Twine &Name, ///< The name for the instruction
    407406 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    408407 );
    409408
    411410 static CastInst *CreateTruncOrBitCast(
    412411 Value *S, ///< The value to be casted (operand 0)
    413412 const Type *Ty, ///< The type to which cast should be made
    414 const std::string &Name = "", ///< Name for the instruction
    413 const Twine &Name = "", ///< Name for the instruction
    415414 Instruction *InsertBefore = 0 ///< Place to insert the instruction
    416415 );
    417416
    419418 static CastInst *CreateTruncOrBitCast(
    420419 Value *S, ///< The value to be casted (operand 0)
    421420 const Type *Ty, ///< The type to which operand is casted
    422 const std::string &Name, ///< The name for the instruction
    421 const Twine &Name, ///< The name for the instruction
    423422 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    424423 );
    425424
    519518 CmpInst(); // do not implement
    520519 protected:
    521520 CmpInst(const Type *ty, Instruction::OtherOps op, unsigned short pred,
    522 Value *LHS, Value *RHS, const std::string &Name = "",
    521 Value *LHS, Value *RHS, const Twine &Name = "",
    523522 Instruction *InsertBefore = 0);
    524523
    525524 CmpInst(const Type *ty, Instruction::OtherOps op, unsigned short pred,
    526 Value *LHS, Value *RHS, const std::string &Name,
    525 Value *LHS, Value *RHS, const Twine &Name,
    527526 BasicBlock *InsertAtEnd);
    528527
    529528 public:
    578577 /// @brief Create a CmpInst
    579578 static CmpInst *Create(LLVMContext &Context, OtherOps Op,
    580579 unsigned short predicate, Value *S1,
    581 Value *S2, const std::string &Name = "",
    580 Value *S2, const Twine &Name = "",
    582581 Instruction *InsertBefore = 0);
    583582
    584583 /// Construct a compare instruction, given the opcode, the predicate and the
    586585 /// the BasicBlock specified.
    587586 /// @brief Create a CmpInst
    588587 static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1,
    589 Value *S2, const std::string &Name,
    590 BasicBlock *InsertAtEnd);
    588 Value *S2, const Twine &Name, BasicBlock *InsertAtEnd);
    591589
    592590 /// @brief Get the opcode casted to the right type
    593591 OtherOps getOpcode() const {
    4040 class AllocationInst : public UnaryInstruction {
    4141 protected:
    4242 AllocationInst(const Type *Ty, Value *ArraySize,
    43 unsigned iTy, unsigned Align, const std::string &Name = "",
    43 unsigned iTy, unsigned Align, const Twine &Name = "",
    4444 Instruction *InsertBefore = 0);
    4545 AllocationInst(const Type *Ty, Value *ArraySize,
    46 unsigned iTy, unsigned Align, const std::string &Name,
    46 unsigned iTy, unsigned Align, const Twine &Name,
    4747 BasicBlock *InsertAtEnd);
    4848 public:
    4949 // Out of line virtual method, so the vtable, etc. has a home.
    101101 MallocInst(const MallocInst &MI);
    102102 public:
    103103 explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
    104 const std::string &NameStr = "",
    104 const Twine &NameStr = "",
    105105 Instruction *InsertBefore = 0)
    106106 : AllocationInst(Ty, ArraySize, Malloc,
    107107 0, NameStr, InsertBefore) {}
    108108 MallocInst(const Type *Ty, Value *ArraySize,
    109 const std::string &NameStr, BasicBlock *InsertAtEnd)
    109 const Twine &NameStr, BasicBlock *InsertAtEnd)
    110110 : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {}
    111111
    112 MallocInst(const Type *Ty, const std::string &NameStr,
    112 MallocInst(const Type *Ty, const Twine &NameStr,
    113113 Instruction *InsertBefore = 0)
    114114 : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {}
    115 MallocInst(const Type *Ty, const std::string &NameStr,
    115 MallocInst(const Type *Ty, const Twine &NameStr,
    116116 BasicBlock *InsertAtEnd)
    117117 : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {}
    118118
    119119 MallocInst(const Type *Ty, Value *ArraySize,
    120 unsigned Align, const std::string &NameStr,
    120 unsigned Align, const Twine &NameStr,
    121121 BasicBlock *InsertAtEnd)
    122122 : AllocationInst(Ty, ArraySize, Malloc,
    123123 Align, NameStr, InsertAtEnd) {}
    124124 MallocInst(const Type *Ty, Value *ArraySize,
    125 unsigned Align, const std::string &NameStr = "",
    125 unsigned Align, const Twine &NameStr = "",
    126126 Instruction *InsertBefore = 0)
    127127 : AllocationInst(Ty, ArraySize,
    128128 Malloc, Align, NameStr, InsertBefore) {}
    151151 public:
    152152 explicit AllocaInst(const Type *Ty,
    153153 Value *ArraySize = 0,
    154 const std::string &NameStr = "",
    154 const Twine &NameStr = "",
    155155 Instruction *InsertBefore = 0)
    156156 : AllocationInst(Ty, ArraySize, Alloca,
    157157 0, NameStr, InsertBefore) {}
    158158 AllocaInst(const Type *Ty,
    159 Value *ArraySize, const std::string &NameStr,
    159 Value *ArraySize, const Twine &NameStr,
    160160 BasicBlock *InsertAtEnd)
    161161 : AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {}
    162162
    163 AllocaInst(const Type *Ty, const std::string &NameStr,
    163 AllocaInst(const Type *Ty, const Twine &NameStr,
    164164 Instruction *InsertBefore = 0)
    165165 : AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertBefore) {}
    166 AllocaInst(const Type *Ty, const std::string &NameStr,
    166 AllocaInst(const Type *Ty, const Twine &NameStr,
    167167 BasicBlock *InsertAtEnd)
    168168 : AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {}
    169169
    170170 AllocaInst(const Type *Ty, Value *ArraySize,
    171 unsigned Align, const std::string &NameStr = "",
    171 unsigned Align, const Twine &NameStr = "",
    172172 Instruction *InsertBefore = 0)
    173173 : AllocationInst(Ty, ArraySize, Alloca,
    174174 Align, NameStr, InsertBefore) {}
    175175 AllocaInst(const Type *Ty, Value *ArraySize,
    176 unsigned Align, const std::string &NameStr,
    176 unsigned Align, const Twine &NameStr,
    177177 BasicBlock *InsertAtEnd)
    178178 : AllocationInst(Ty, ArraySize, Alloca,
    179179 Align, NameStr, InsertAtEnd) {}
    245245 }
    246246 void AssertOK();
    247247 public:
    248 LoadInst(Value *Ptr, const std::string &NameStr, Instruction *InsertBefore);
    249 LoadInst(Value *Ptr, const std::string &NameStr, BasicBlock *InsertAtEnd);
    250 LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile = false,
    248 LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore);
    249 LoadInst(Value *Ptr, const Twine &NameStr, BasicBlock *InsertAtEnd);
    250 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile = false,
    251251 Instruction *InsertBefore = 0);
    252 LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
    252 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
    253253 unsigned Align, Instruction *InsertBefore = 0);
    254 LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
    254 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
    255255 BasicBlock *InsertAtEnd);
    256 LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
    256 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
    257257 unsigned Align, BasicBlock *InsertAtEnd);
    258258
    259259 LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore);
    398398 class GetElementPtrInst : public Instruction {
    399399 GetElementPtrInst(const GetElementPtrInst &GEPI);
    400400 void init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
    401 const std::string &NameStr);
    402 void init(Value *Ptr, Value *Idx, const std::string &NameStr);
    401 const Twine &NameStr);
    402 void init(Value *Ptr, Value *Idx, const Twine &NameStr);
    403403
    404404 template
    405405 void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
    406 const std::string &NameStr,
    406 const Twine &NameStr,
    407407 // This argument ensures that we have an iterator we can
    408408 // do arithmetic on in constant time
    409409 std::random_access_iterator_tag) {
    450450 inline GetElementPtrInst(Value *Ptr, InputIterator IdxBegin,
    451451 InputIterator IdxEnd,
    452452 unsigned Values,
    453 const std::string &NameStr,
    453 const Twine &NameStr,
    454454 Instruction *InsertBefore);
    455455 template
    456456 inline GetElementPtrInst(Value *Ptr,
    457457 InputIterator IdxBegin, InputIterator IdxEnd,
    458458 unsigned Values,
    459 const std::string &NameStr, BasicBlock *InsertAtEnd);
    459 const Twine &NameStr, BasicBlock *InsertAtEnd);
    460460
    461461 /// Constructors - These two constructors are convenience methods because one
    462462 /// and two index getelementptr instructions are so common.
    463 GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &NameStr = "",
    463 GetElementPtrInst(Value *Ptr, Value *Idx, const Twine &NameStr = "",
    464464 Instruction *InsertBefore = 0);
    465465 GetElementPtrInst(Value *Ptr, Value *Idx,
    466 const std::string &NameStr, BasicBlock *InsertAtEnd);
    466 const Twine &NameStr, BasicBlock *InsertAtEnd);
    467467 public:
    468468 template
    469469 static GetElementPtrInst *Create(Value *Ptr, InputIterator IdxBegin,
    470470 InputIterator IdxEnd,
    471 const std::string &NameStr = "",
    471 const Twine &NameStr = "",
    472472 Instruction *InsertBefore = 0) {
    473473 typename std::iterator_traits::difference_type Values =
    474474 1 + std::distance(IdxBegin, IdxEnd);
    478478 template
    479479 static GetElementPtrInst *Create(Value *Ptr,
    480480 InputIterator IdxBegin, InputIterator IdxEnd,
    481 const std::string &NameStr,
    481 const Twine &NameStr,
    482482 BasicBlock *InsertAtEnd) {
    483483 typename std::iterator_traits::difference_type Values =
    484484 1 + std::distance(IdxBegin, IdxEnd);
    489489 /// Constructors - These two creators are convenience methods because one
    490490 /// index getelementptr instructions are so common.
    491491 static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
    492 const std::string &NameStr = "",
    492 const Twine &NameStr = "",
    493493 Instruction *InsertBefore = 0) {
    494494 return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertBefore);
    495495 }
    496496 static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
    497 const std::string &NameStr,
    497 const Twine &NameStr,
    498498 BasicBlock *InsertAtEnd) {
    499499 return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
    500500 }
    591591 InputIterator IdxBegin,
    592592 InputIterator IdxEnd,
    593593 unsigned Values,
    594 const std::string &NameStr,
    594 const Twine &NameStr,
    595595 Instruction *InsertBefore)
    596596 : Instruction(PointerType::get(checkType(
    597597 getIndexedType(Ptr->getType(),
    609609 InputIterator IdxBegin,
    610610 InputIterator IdxEnd,
    611611 unsigned Values,
    612 const std::string &NameStr,
    612 const Twine &NameStr,
    613613 BasicBlock *InsertAtEnd)
    614614 : Instruction(PointerType::get(checkType(
    615615 getIndexedType(Ptr->getType(),
    643643 Predicate pred, ///< The predicate to use for the comparison
    644644 Value *LHS, ///< The left-hand-side of the expression
    645645 Value *RHS, ///< The right-hand-side of the expression
    646 const std::string &NameStr = "" ///< Name of the instruction
    646 const Twine &NameStr = "" ///< Name of the instruction
    647647 ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()),
    648648 Instruction::ICmp, pred, LHS, RHS, NameStr,
    649649 InsertBefore) {
    664664 Predicate pred, ///< The predicate to use for the comparison
    665665 Value *LHS, ///< The left-hand-side of the expression
    666666 Value *RHS, ///< The right-hand-side of the expression
    667 const std::string &NameStr = "" ///< Name of the instruction
    667 const Twine &NameStr = "" ///< Name of the instruction
    668668 ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()),
    669669 Instruction::ICmp, pred, LHS, RHS, NameStr,
    670670 &InsertAtEnd) {
    685685 Predicate pred, ///< The predicate to use for the comparison
    686686 Value *LHS, ///< The left-hand-side of the expression
    687687 Value *RHS, ///< The right-hand-side of the expression
    688 const std::string &NameStr = "" ///< Name of the instruction
    688 const Twine &NameStr = "" ///< Name of the instruction
    689689 ) : CmpInst(Context.makeCmpResultType(LHS->getType()),
    690690 Instruction::ICmp, pred, LHS, RHS, NameStr) {
    691691 assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
    818818 Predicate pred, ///< The predicate to use for the comparison
    819819 Value *LHS, ///< The left-hand-side of the expression
    820820 Value *RHS, ///< The right-hand-side of the expression
    821 const std::string &NameStr = "" ///< Name of the instruction
    821 const Twine &NameStr = "" ///< Name of the instruction
    822822 ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()),
    823823 Instruction::FCmp, pred, LHS, RHS, NameStr,
    824824 InsertBefore) {
    837837 Predicate pred, ///< The predicate to use for the comparison
    838838 Value *LHS, ///< The left-hand-side of the expression
    839839 Value *RHS, ///< The right-hand-side of the expression
    840 const std::string &NameStr = "" ///< Name of the instruction
    840 const Twine &NameStr = "" ///< Name of the instruction
    841841 ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()),
    842842 Instruction::FCmp, pred, LHS, RHS, NameStr,
    843843 &InsertAtEnd) {
    856856 Predicate pred, ///< The predicate to use for the comparison
    857857 Value *LHS, ///< The left-hand-side of the expression
    858858 Value *RHS, ///< The right-hand-side of the expression
    859 const std::string &NameStr = "" ///< Name of the instruction
    859 const Twine &NameStr = "" ///< Name of the instruction
    860860 ) : CmpInst(Context.makeCmpResultType(LHS->getType()),
    861861 Instruction::FCmp, pred, LHS, RHS, NameStr) {
    862862 assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
    931931
    932932 template
    933933 void init(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
    934 const std::string &NameStr,
    934 const Twine &NameStr,
    935935 // This argument ensures that we have an iterator we can
    936936 // do arithmetic on in constant time
    937937 std::random_access_iterator_tag) {
    950950 /// @brief Construct a CallInst from a range of arguments
    951951 template
    952952 CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
    953 const std::string &NameStr, Instruction *InsertBefore);
    953 const Twine &NameStr, Instruction *InsertBefore);
    954954
    955955 /// Construct a CallInst given a range of arguments. InputIterator
    956956 /// must be a random-access iterator pointing to contiguous storage
    960960 /// @brief Construct a CallInst from a range of arguments
    961961 template
    962962 inline CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
    963 const std::string &NameStr, BasicBlock *InsertAtEnd);
    964
    965 CallInst(Value *F, Value *Actual, const std::string& NameStr,
    963 const Twine &NameStr, BasicBlock *InsertAtEnd);
    964
    965 CallInst(Value *F, Value *Actual, const Twine &NameStr,
    966966 Instruction *InsertBefore);
    967 CallInst(Value *F, Value *Actual, const std::string& NameStr,
    967 CallInst(Value *F, Value *Actual, const Twine &NameStr,
    968968 BasicBlock *InsertAtEnd);
    969 explicit CallInst(Value *F, const std::string &NameStr,
    969 explicit CallInst(Value *F, const Twine &NameStr,
    970970 Instruction *InsertBefore);
    971 CallInst(Value *F, const std::string &NameStr, BasicBlock *InsertAtEnd);
    971 CallInst(Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd);
    972972 public:
    973973 template
    974974 static CallInst *Create(Value *Func,
    975975 InputIterator ArgBegin, InputIterator ArgEnd,
    976 const std::string &NameStr = "",
    976 const Twine &NameStr = "",
    977977 Instruction *InsertBefore = 0) {
    978978 return new((unsigned)(ArgEnd - ArgBegin + 1))
    979979 CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertBefore);
    981981 template
    982982 static CallInst *Create(Value *Func,
    983983 InputIterator ArgBegin, InputIterator ArgEnd,
    984 const std::string &NameStr, BasicBlock *InsertAtEnd) {
    984 const Twine &NameStr, BasicBlock *InsertAtEnd) {
    985985 return new((unsigned)(ArgEnd - ArgBegin + 1))
    986986 CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertAtEnd);
    987987 }
    988988 static CallInst *Create(Value *F, Value *Actual,
    989 const std::string& NameStr = "",
    989 const Twine &NameStr = "",
    990990 Instruction *InsertBefore = 0) {
    991991 return new(2) CallInst(F, Actual, NameStr, InsertBefore);
    992992 }
    993 static CallInst *Create(Value *F, Value *Actual, const std::string& NameStr,
    993 static CallInst *Create(Value *F, Value *Actual, const Twine &NameStr,
    994994 BasicBlock *InsertAtEnd) {
    995995 return new(2) CallInst(F, Actual, NameStr, InsertAtEnd);
    996996 }
    997 static CallInst *Create(Value *F, const std::string &NameStr = "",
    997 static CallInst *Create(Value *F, const Twine &NameStr = "",
    998998 Instruction *InsertBefore = 0) {
    999999 return new(1) CallInst(F, NameStr, InsertBefore);
    10001000 }
    1001 static CallInst *Create(Value *F, const std::string &NameStr,
    1001 static CallInst *Create(Value *F, const Twine &NameStr,
    10021002 BasicBlock *InsertAtEnd) {
    10031003 return new(1) CallInst(F, NameStr, InsertAtEnd);
    10041004 }
    11201120
    11211121 template
    11221122 CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
    1123 const std::string &NameStr, BasicBlock *InsertAtEnd)
    1123 const Twine &NameStr, BasicBlock *InsertAtEnd)
    11241124 : Instruction(cast(cast(Func->getType())
    11251125 ->getElementType())->getReturnType(),
    11261126 Instruction::Call,
    11321132
    11331133 template
    11341134 CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
    1135 const std::string &NameStr, Instruction *InsertBefore)
    1135 const Twine &NameStr, Instruction *InsertBefore)
    11361136 : Instruction(cast(cast(Func->getType())
    11371137 ->getElementType())->getReturnType(),
    11381138 Instruction::Call,
    11621162 : Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) {
    11631163 init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>());
    11641164 }
    1165 SelectInst(Value *C, Value *S1, Value *S2, const std::string &NameStr,
    1165 SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
    11661166 Instruction *InsertBefore)
    11671167 : Instruction(S1->getType(), Instruction::Select,
    11681168 &Op<0>(), 3, InsertBefore) {
    11691169 init(C, S1, S2);
    11701170 setName(NameStr);
    11711171 }
    1172 SelectInst(Value *C, Value *S1, Value *S2, const std::string &NameStr,
    1172 SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
    11731173 BasicBlock *InsertAtEnd)
    11741174 : Instruction(S1->getType(), Instruction::Select,
    11751175 &Op<0>(), 3, InsertAtEnd) {
    11781178 }
    11791179 public:
    11801180 static SelectInst *Create(Value *C, Value *S1, Value *S2,
    1181 const std::string &NameStr = "",
    1181 const Twine &NameStr = "",
    11821182 Instruction *InsertBefore = 0) {
    11831183 return new(3) SelectInst(C, S1, S2, NameStr, InsertBefore);
    11841184 }
    11851185 static SelectInst *Create(Value *C, Value *S1, Value *S2,
    1186 const std::string &NameStr,
    1186 const Twine &NameStr,
    11871187 BasicBlock *InsertAtEnd) {
    11881188 return new(3) SelectInst(C, S1, S2, NameStr, InsertAtEnd);
    11891189 }
    12321232 VAArgInst(const VAArgInst &VAA)
    12331233 : UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
    12341234 public:
    1235 VAArgInst(Value *List, const Type *Ty, const std::string &NameStr = "",
    1235 VAArgInst(Value *List, const Type *Ty, const Twine &NameStr = "",
    12361236 Instruction *InsertBefore = 0)
    12371237 : UnaryInstruction(Ty, VAArg, List, InsertBefore) {
    12381238 setName(NameStr);
    12391239 }
    1240 VAArgInst(Value *List, const Type *Ty, const std::string &NameStr,
    1240 VAArgInst(Value *List, const Type *Ty, const Twine &NameStr,
    12411241 BasicBlock *InsertAtEnd)
    12421242 : UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
    12431243 setName(NameStr);
    12691269 Op<1>() = EE.Op<1>();
    12701270 }
    12711271
    1272 ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr = "",
    1272 ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "",
    12731273 Instruction *InsertBefore = 0);
    1274 ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr,
    1274 ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr,
    12751275 BasicBlock *InsertAtEnd);
    12761276 public:
    12771277 static ExtractElementInst *Create(const ExtractElementInst &EE) {
    12791279 }
    12801280
    12811281 static ExtractElementInst *Create(Value *Vec, Value *Idx,
    1282 const std::string &NameStr = "",
    1282 const Twine &NameStr = "",
    12831283 Instruction *InsertBefore = 0) {
    12841284 return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertBefore);
    12851285 }
    12861286 static ExtractElementInst *Create(Value *Vec, Value *Idx,
    1287 const std::string &NameStr,
    1287 const Twine &NameStr,
    12881288 BasicBlock *InsertAtEnd) {
    12891289 return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertAtEnd);
    12901290 }
    13241324 class InsertElementInst : public Instruction {
    13251325 InsertElementInst(const InsertElementInst &IE);
    13261326 InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
    1327 const std::string &NameStr = "",
    1327 const Twine &NameStr = "",
    13281328 Instruction *InsertBefore = 0);
    13291329 InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
    1330 const std::string &NameStr, BasicBlock *InsertAtEnd);
    1330 const Twine &NameStr, BasicBlock *InsertAtEnd);
    13311331 public:
    13321332 static InsertElementInst *Create(const InsertElementInst &IE) {
    13331333 return new(IE.getNumOperands()) InsertElementInst(IE);
    13341334 }
    13351335 static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
    1336 const std::string &NameStr = "",
    1336 const Twine &NameStr = "",
    13371337 Instruction *InsertBefore = 0) {
    13381338 return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
    13391339 }
    13401340 static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
    1341 const std::string &NameStr,
    1341 const Twine &NameStr,
    13421342 BasicBlock *InsertAtEnd) {
    13431343 return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
    13441344 }
    13901390 return User::operator new(s, 3);
    13911391 }
    13921392 ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
    1393 const std::string &NameStr = "",
    1393 const Twine &NameStr = "",
    13941394 Instruction *InsertBefor = 0);
    13951395 ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
    1396 const std::string &NameStr, BasicBlock *InsertAtEnd);
    1396 const Twine &NameStr, BasicBlock *InsertAtEnd);
    13971397
    13981398 /// isValidOperands - Return true if a shufflevector instruction can be
    13991399 /// formed with the specified operands.
    14441444
    14451445 ExtractValueInst(const ExtractValueInst &EVI);
    14461446 void init(const unsigned *Idx, unsigned NumIdx,
    1447 const std::string &NameStr);
    1448 void init(unsigned Idx, const std::string &NameStr);
    1447 const Twine &NameStr);
    1448 void init(unsigned Idx, const Twine &NameStr);
    14491449
    14501450 template
    14511451 void init(InputIterator IdxBegin, InputIterator IdxEnd,
    1452 const std::string &NameStr,
    1452 const Twine &NameStr,
    14531453 // This argument ensures that we have an iterator we can
    14541454 // do arithmetic on in constant time
    14551455 std::random_access_iterator_tag) {
    14991499 template
    15001500 inline ExtractValueInst(Value *Agg, InputIterator IdxBegin,
    15011501 InputIterator IdxEnd,
    1502 const std::string &NameStr,
    1502 const Twine &NameStr,
    15031503 Instruction *InsertBefore);
    15041504 template
    15051505 inline ExtractValueInst(Value *Agg,
    15061506 InputIterator IdxBegin, InputIterator IdxEnd,
    1507 const std::string &NameStr, BasicBlock *InsertAtEnd);
    1507 const Twine &NameStr, BasicBlock *InsertAtEnd);
    15081508
    15091509 // allocate space for exactly one operand
    15101510 void *operator new(size_t s) {
    15151515 template
    15161516 static ExtractValueInst *Create(Value *Agg, InputIterator IdxBegin,
    15171517 InputIterator IdxEnd,
    1518 const std::string &NameStr = "",
    1518 const Twine &NameStr = "",
    15191519 Instruction *InsertBefore = 0) {
    15201520 return new
    15211521 ExtractValueInst(Agg, IdxBegin, IdxEnd, NameStr, InsertBefore);
    15231523 template
    15241524 static ExtractValueInst *Create(Value *Agg,
    15251525 InputIterator IdxBegin, InputIterator IdxEnd,
    1526 const std::string &NameStr,
    1526 const Twine &NameStr,
    15271527 BasicBlock *InsertAtEnd) {
    15281528 return new ExtractValueInst(Agg, IdxBegin, IdxEnd, NameStr, InsertAtEnd);
    15291529 }
    15321532 /// index extractvalue instructions are much more common than those with
    15331533 /// more than one.
    15341534 static ExtractValueInst *Create(Value *Agg, unsigned Idx,
    1535 const std::string &NameStr = "",
    1535 const Twine &NameStr = "",
    15361536 Instruction *InsertBefore = 0) {
    15371537 unsigned Idxs[1] = { Idx };
    15381538 return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertBefore);
    15391539 }
    15401540 static ExtractValueInst *Create(Value *Agg, unsigned Idx,
    1541 const std::string &NameStr,
    1541 const Twine &NameStr,
    15421542 BasicBlock *InsertAtEnd) {
    15431543 unsigned Idxs[1] = { Idx };
    15441544 return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertAtEnd);
    15981598 ExtractValueInst::ExtractValueInst(Value *Agg,
    15991599 InputIterator IdxBegin,
    16001600 InputIterator IdxEnd,
    1601 const std::string &NameStr,
    1601 const Twine &NameStr,
    16021602 Instruction *InsertBefore)
    16031603 : UnaryInstruction(checkType(getIndexedType(Agg->getType(),
    16041604 IdxBegin, IdxEnd)),
    16101610 ExtractValueInst::ExtractValueInst(Value *Agg,
    16111611 InputIterator IdxBegin,
    16121612 InputIterator IdxEnd,
    1613 const std::string &NameStr,
    1613 const Twine &NameStr,
    16141614 BasicBlock *InsertAtEnd)
    16151615 : UnaryInstruction(checkType(getIndexedType(Agg->getType(),
    16161616 IdxBegin, IdxEnd)),
    16331633 void *operator new(size_t, unsigned); // Do not implement
    16341634 InsertValueInst(const InsertValueInst &IVI);
    16351635 void init(Value *Agg, Value *Val, const unsigned *Idx, unsigned NumIdx,
    1636 const std::string &NameStr);
    1637 void init(Value *Agg, Value *Val, unsigned Idx, const std::string &NameStr);
    1636 const Twine &NameStr);
    1637 void init(Value *Agg, Value *Val, unsigned Idx, const Twine &NameStr);
    16381638
    16391639 template
    16401640 void init(Value *Agg, Value *Val,
    16411641 InputIterator IdxBegin, InputIterator IdxEnd,
    1642 const std::string &NameStr,
    1642 const Twine &NameStr,
    16431643 // This argument ensures that we have an iterator we can
    16441644 // do arithmetic on in constant time
    16451645 std::random_access_iterator_tag) {
    16631663 template
    16641664 inline InsertValueInst(Value *Agg, Value *Val, InputIterator IdxBegin,
    16651665 InputIterator IdxEnd,
    1666 const std::string &NameStr,
    1666 const Twine &NameStr,
    16671667 Instruction *InsertBefore);
    16681668 template
    16691669 inline InsertValueInst(Value *Agg, Value *Val,
    16701670 InputIterator IdxBegin, InputIterator IdxEnd,
    1671 const std::string &NameStr, BasicBlock *InsertAtEnd);
    1671 const Twine &NameStr, BasicBlock *InsertAtEnd);
    16721672
    16731673 /// Constructors - These two constructors are convenience methods because one
    16741674 /// and two index insertvalue instructions are so common.
    16751675 InsertValueInst(Value *Agg, Value *Val,
    1676 unsigned Idx, const std::string &NameStr = "",
    1676 unsigned Idx, const Twine &NameStr = "",
    16771677 Instruction *InsertBefore = 0);
    16781678 InsertValueInst(Value *Agg, Value *Val, unsigned Idx,
    1679 const std::string &NameStr, BasicBlock *InsertAtEnd);
    1679 const Twine &NameStr, BasicBlock *InsertAtEnd);
    16801680 public:
    16811681 // allocate space for exactly two operands
    16821682 void *operator new(size_t s) {
    16861686 template
    16871687 static InsertValueInst *Create(Value *Agg, Value *Val, InputIterator IdxBegin,
    16881688 InputIterator IdxEnd,
    1689 const std::string &NameStr = "",
    1689 const Twine &NameStr = "",
    16901690 Instruction *InsertBefore = 0) {
    16911691 return new InsertValueInst(Agg, Val, IdxBegin, IdxEnd,
    16921692 NameStr, InsertBefore);
    16941694 template
    16951695 static InsertValueInst *Create(Value *Agg, Value *Val,
    16961696 InputIterator IdxBegin, InputIterator IdxEnd,
    1697 const std::string &NameStr,
    1697 const Twine &NameStr,
    16981698 BasicBlock *InsertAtEnd) {
    16991699 return new InsertValueInst(Agg, Val, IdxBegin, IdxEnd,
    17001700 NameStr, InsertAtEnd);
    17041704 /// index insertvalue instructions are much more common than those with
    17051705 /// more than one.
    17061706 static InsertValueInst *Create(Value *Agg, Value *Val, unsigned Idx,
    1707 const std::string &NameStr = "",
    1707 const Twine &NameStr = "",
    17081708 Instruction *InsertBefore = 0) {
    17091709 return new InsertValueInst(Agg, Val, Idx, NameStr, InsertBefore);
    17101710 }
    17111711 static InsertValueInst *Create(Value *Agg, Value *Val, unsigned Idx,
    1712 const std::string &NameStr,
    1712 const Twine &NameStr,
    17131713 BasicBlock *InsertAtEnd) {
    17141714 return new InsertValueInst(Agg, Val, Idx, NameStr, InsertAtEnd);
    17151715 }
    17701770 Value *Val,
    17711771 InputIterator IdxBegin,
    17721772 InputIterator IdxEnd,
    1773 const std::string &NameStr,
    1773 const Twine &NameStr,
    17741774 Instruction *InsertBefore)
    17751775 : Instruction(Agg->getType(), InsertValue,
    17761776 OperandTraits::op_begin(this),
    17831783 Value *Val,
    17841784 InputIterator IdxBegin,
    17851785 InputIterator IdxEnd,
    1786 const std::string &NameStr,
    1786 const Twine &NameStr,
    17871787 BasicBlock *InsertAtEnd)
    17881788 : Instruction(Agg->getType(), InsertValue,
    17891789 OperandTraits::op_begin(this),
    18121812 void *operator new(size_t s) {
    18131813 return User::operator new(s, 0);
    18141814 }
    1815 explicit PHINode(const Type *Ty, const std::string &NameStr = "",
    1815 explicit PHINode(const Type *Ty, const Twine &NameStr = "",
    18161816 Instruction *InsertBefore = 0)
    18171817 : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
    18181818 ReservedSpace(0) {
    18191819 setName(NameStr);
    18201820 }
    18211821
    1822 PHINode(const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd)
    1822 PHINode(const Type *Ty, const Twine &NameStr, BasicBlock *InsertAtEnd)
    18231823 : Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd),
    18241824 ReservedSpace(0) {
    18251825 setName(NameStr);
    18261826 }
    18271827 public:
    1828 static PHINode *Create(const Type *Ty, const std::string &NameStr = "",
    1828 static PHINode *Create(const Type *Ty, const Twine &NameStr = "",
    18291829 Instruction *InsertBefore = 0) {
    18301830 return new PHINode(Ty, NameStr, InsertBefore);
    18311831 }
    1832 static PHINode *Create(const Type *Ty, const std::string &NameStr,
    1832 static PHINode *Create(const Type *Ty, const Twine &NameStr,
    18331833 BasicBlock *InsertAtEnd) {
    18341834 return new PHINode(Ty, NameStr, InsertAtEnd);
    18351835 }
    23102310 template
    23112311 void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
    23122312 InputIterator ArgBegin, InputIterator ArgEnd,
    2313 const std::string &NameStr,
    2313 const Twine &NameStr,
    23142314 // This argument ensures that we have an iterator we can
    23152315 // do arithmetic on in constant time
    23162316 std::random_access_iterator_tag) {
    23322332 inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
    23332333 InputIterator ArgBegin, InputIterator ArgEnd,
    23342334 unsigned Values,
    2335 const std::string &NameStr, Instruction *InsertBefore);
    2335 const Twine &NameStr, Instruction *InsertBefore);
    23362336
    23372337 /// Construct an InvokeInst given a range of arguments.
    23382338 /// InputIterator must be a random-access iterator pointing to
    23452345 inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
    23462346 InputIterator ArgBegin, InputIterator ArgEnd,
    23472347 unsigned Values,
    2348 const std::string &NameStr, BasicBlock *InsertAtEnd);
    2348 const Twine &NameStr, BasicBlock *InsertAtEnd);
    23492349 public:
    23502350 template
    23512351 static InvokeInst *Create(Value *Func,
    23522352 BasicBlock *IfNormal, BasicBlock *IfException,
    23532353 InputIterator ArgBegin, InputIterator ArgEnd,
    2354 const std::string &NameStr = "",
    2354 const Twine &NameStr = "",
    23552355 Instruction *InsertBefore = 0) {
    23562356 unsigned Values(ArgEnd - ArgBegin + 3);
    23572357 return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
    23612361 static InvokeInst *Create(Value *Func,
    23622362 BasicBlock *IfNormal, BasicBlock *IfException,
    23632363 InputIterator ArgBegin, InputIterator ArgEnd,
    2364 const std::string &NameStr,
    2364 const Twine &NameStr,
    23652365 BasicBlock *InsertAtEnd) {
    23662366 unsigned Values(ArgEnd - ArgBegin + 3);
    23672367 return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
    25122512 BasicBlock *IfNormal, BasicBlock *IfException,
    25132513 InputIterator ArgBegin, InputIterator ArgEnd,
    25142514 unsigned Values,
    2515 const std::string &NameStr, Instruction *InsertBefore)
    2515 const Twine &NameStr, Instruction *InsertBefore)
    25162516 : TerminatorInst(cast(cast(Func->getType())
    25172517 ->getElementType())->getReturnType(),
    25182518 Instruction::Invoke,
    25262526 BasicBlock *IfNormal, BasicBlock *IfException,
    25272527 InputIterator ArgBegin, InputIterator ArgEnd,
    25282528 unsigned Values,
    2529 const std::string &NameStr, BasicBlock *InsertAtEnd)
    2529 const Twine &NameStr, BasicBlock *InsertAtEnd)
    25302530 : TerminatorInst(cast(cast(Func->getType())
    25312531 ->getElementType())->getReturnType(),
    25322532 Instruction::Invoke,
    26262626 TruncInst(
    26272627 Value *S, ///< The value to be truncated
    26282628 const Type *Ty, ///< The (smaller) type to truncate to
    2629 const std::string &NameStr = "", ///< A name for the new instruction
    2629 const Twine &NameStr = "", ///< A name for the new instruction
    26302630 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    26312631 );
    26322632
    26342634 TruncInst(
    26352635 Value *S, ///< The value to be truncated
    26362636 const Type *Ty, ///< The (smaller) type to truncate to
    2637 const std::string &NameStr, ///< A name for the new instruction
    2637 const Twine &NameStr, ///< A name for the new instruction
    26382638 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    26392639 );
    26402640
    26662666 ZExtInst(
    26672667 Value *S, ///< The value to be zero extended
    26682668 const Type *Ty, ///< The type to zero extend to
    2669 const std::string &NameStr = "", ///< A name for the new instruction
    2669 const Twine &NameStr = "", ///< A name for the new instruction
    26702670 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    26712671 );
    26722672
    26742674 ZExtInst(
    26752675 Value *S, ///< The value to be zero extended
    26762676 const Type *Ty, ///< The type to zero extend to
    2677 const std::string &NameStr, ///< A name for the new instruction
    2677 const Twine &NameStr, ///< A name for the new instruction
    26782678 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    26792679 );
    26802680
    27062706 SExtInst(
    27072707 Value *S, ///< The value to be sign extended
    27082708 const Type *Ty, ///< The type to sign extend to
    2709 const std::string &NameStr = "", ///< A name for the new instruction
    2709 const Twine &NameStr = "", ///< A name for the new instruction
    27102710 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    27112711 );
    27122712
    27142714 SExtInst(
    27152715 Value *S, ///< The value to be sign extended
    27162716 const Type *Ty, ///< The type to sign extend to
    2717 const std::string &NameStr, ///< A name for the new instruction
    2717 const Twine &NameStr, ///< A name for the new instruction
    27182718 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    27192719 );
    27202720
    27452745 FPTruncInst(
    27462746 Value *S, ///< The value to be truncated
    27472747 const Type *Ty, ///< The type to truncate to
    2748 const std::string &NameStr = "", ///< A name for the new instruction
    2748 const Twine &NameStr = "", ///< A name for the new instruction
    27492749 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    27502750 );
    27512751
    27532753 FPTruncInst(
    27542754 Value *S, ///< The value to be truncated
    27552755 const Type *Ty, ///< The type to truncate to
    2756 const std::string &NameStr, ///< A name for the new instruction
    2756 const Twine &NameStr, ///< A name for the new instruction
    27572757 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    27582758 );
    27592759
    27842784 FPExtInst(
    27852785 Value *S, ///< The value to be extended
    27862786 const Type *Ty, ///< The type to extend to
    2787 const std::string &NameStr = "", ///< A name for the new instruction
    2787 const Twine &NameStr = "", ///< A name for the new instruction
    27882788 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    27892789 );
    27902790
    27922792 FPExtInst(
    27932793 Value *S, ///< The value to be extended
    27942794 const Type *Ty, ///< The type to extend to
    2795 const std::string &NameStr, ///< A name for the new instruction
    2795 const Twine &NameStr, ///< A name for the new instruction
    27962796 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    27972797 );
    27982798
    28232823 UIToFPInst(
    28242824 Value *S, ///< The value to be converted
    28252825 const Type *Ty, ///< The type to convert to
    2826 const std::string &NameStr = "", ///< A name for the new instruction
    2826 const Twine &NameStr = "", ///< A name for the new instruction
    28272827 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    28282828 );
    28292829
    28312831 UIToFPInst(
    28322832 Value *S, ///< The value to be converted
    28332833 const Type *Ty, ///< The type to convert to
    2834 const std::string &NameStr, ///< A name for the new instruction
    2834 const Twine &NameStr, ///< A name for the new instruction
    28352835 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    28362836 );
    28372837
    28622862 SIToFPInst(
    28632863 Value *S, ///< The value to be converted
    28642864 const Type *Ty, ///< The type to convert to
    2865 const std::string &NameStr = "", ///< A name for the new instruction
    2865 const Twine &NameStr = "", ///< A name for the new instruction
    28662866 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    28672867 );
    28682868
    28702870 SIToFPInst(
    28712871 Value *S, ///< The value to be converted
    28722872 const Type *Ty, ///< The type to convert to
    2873 const std::string &NameStr, ///< A name for the new instruction
    2873 const Twine &NameStr, ///< A name for the new instruction
    28742874 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    28752875 );
    28762876
    29012901 FPToUIInst(
    29022902 Value *S, ///< The value to be converted
    29032903 const Type *Ty, ///< The type to convert to
    2904 const std::string &NameStr = "", ///< A name for the new instruction
    2904 const Twine &NameStr = "", ///< A name for the new instruction
    29052905 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    29062906 );
    29072907
    29092909 FPToUIInst(
    29102910 Value *S, ///< The value to be converted
    29112911 const Type *Ty, ///< The type to convert to
    2912 const std::string &NameStr, ///< A name for the new instruction
    2912 const Twine &NameStr, ///< A name for the new instruction
    29132913 BasicBlock *InsertAtEnd ///< Where to insert the new instruction
    29142914 );
    29152915
    29402940 FPToSIInst(
    29412941 Value *S, ///< The value to be converted
    29422942 const Type *Ty, ///< The type to convert to
    2943 const std::string &NameStr = "", ///< A name for the new instruction
    2943 const Twine &NameStr = "", ///< A name for the new instruction
    29442944 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    29452945 );
    29462946
    29482948 FPToSIInst(
    29492949 Value *S, ///< The value to be converted
    29502950 const Type *Ty, ///< The type to convert to
    2951 const std::string &NameStr, ///< A name for the new instruction
    2951 const Twine &NameStr, ///< A name for the new instruction
    29522952 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    29532953 );
    29542954
    29792979 IntToPtrInst(
    29802980 Value *S, ///< The value to be converted
    29812981 const Type *Ty, ///< The type to convert to
    2982 const std::string &NameStr = "", ///< A name for the new instruction
    2982 const Twine &NameStr = "", ///< A name for the new instruction
    29832983 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    29842984 );
    29852985
    29872987 IntToPtrInst(
    29882988 Value *S, ///< The value to be converted
    29892989 const Type *Ty, ///< The type to convert to
    2990 const std::string &NameStr, ///< A name for the new instruction
    2990 const Twine &NameStr, ///< A name for the new instruction
    29912991 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    29922992 );
    29932993
    30183018 PtrToIntInst(
    30193019 Value *S, ///< The value to be converted
    30203020 const Type *Ty, ///< The type to convert to
    3021 const std::string &NameStr = "", ///< A name for the new instruction
    3021 const Twine &NameStr = "", ///< A name for the new instruction
    30223022 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    30233023 );
    30243024
    30263026 PtrToIntInst(
    30273027 Value *S, ///< The value to be converted
    30283028 const Type *Ty, ///< The type to convert to
    3029 const std::string &NameStr, ///< A name for the new instruction
    3029 const Twine &NameStr, ///< A name for the new instruction
    30303030 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    30313031 );
    30323032
    30573057 BitCastInst(
    30583058 Value *S, ///< The value to be casted
    30593059 const Type *Ty, ///< The type to casted to
    3060 const std::string &NameStr = "", ///< A name for the new instruction
    3060 const Twine &NameStr = "", ///< A name for the new instruction
    30613061 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
    30623062 );
    30633063
    30653065 BitCastInst(
    30663066 Value *S, ///< The value to be casted
    30673067 const Type *Ty, ///< The type to casted to
    3068 const std::string &NameStr, ///< A name for the new instruction
    3068 const Twine &NameStr, ///< A name for the new instruction
    30693069 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
    30703070 );
    30713071
    1616 #include "llvm/AbstractTypeUser.h"
    1717 #include "llvm/Use.h"
    1818 #include "llvm/ADT/StringRef.h"
    19 #include "llvm/ADT/Twine.h"
    1920 #include "llvm/Support/Casting.h"
    2021 #include
    2122 #include
    127128 /// getName()/getNameStr() - Return the name of the specified value,
    128129 /// *constructing a string* to hold it. Because these are guaranteed to
    129130 /// construct a string, they are very expensive and should be avoided.
    130 std::string getName() const { return getNameStr(); }
    131 StringRef getName() const { return StringRef(getNameStart(), getNameLen()); }
    131132 std::string getNameStr() const;
    132133 StringRef getNameRef() const;
    133134
    134 void setName(const std::string &name);
    135 void setName(const Twine &Name);
    135136 void setName(const char *Name, unsigned NameLen);
    136137 void setName(const char *Name); // Takes a null-terminated string.
    137138
    3333
    3434 // Error - Simple wrapper function to conditionally assign to E and return true.
    3535 // This just makes error return conditions a little bit simpler...
    36 static inline bool Error(std::string *E, const std::string &Message) {
    37 if (E) *E = Message;
    36 static inline bool Error(std::string *E, const Twine &Message) {
    37 if (E) *E = Message.str();
    3838 return true;
    3939 }
    4040
    868868 newOp1, newOp2,
    869869 C->getName()+".expr");
    870870 else if (ExtractElementInst* E = dyn_cast(U))
    871 newVal = ExtractElementInst::Create(newOp1, newOp2, E->getName()+".expr");
    871 newVal = ExtractElementInst::Create(newOp1, newOp2,
    872 E->getName()+".expr");
    872873
    873874 uint32_t v = VN.lookup_or_add(newVal);
    874875
    14421442
    14431443 if (StoreInst *SI = dyn_cast(User)) {
    14441444 assert(SI->getOperand(0) != Ptr && "Consistency error!");
    1445 Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str());
    1445 // FIXME: Remove once builder has Twine API.
    1446 Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str());
    14461447 Value *New = ConvertScalar_InsertValue(SI->getOperand(0), Old, Offset,
    14471448 Builder);
    14481449 Builder.CreateStore(New, NewAI);
    14661467 for (unsigned i = 1; i != NumBytes; ++i)
    14671468 APVal |= APVal << 8;
    14681469
    1469 Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str());
    1470 // FIXME: Remove once builder has Twine API.
    1471 Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str());
    14701472 Value *New = ConvertScalar_InsertValue(
    14711473 ConstantInt::get(User->getContext(), APVal),
    14721474 Old, Offset, Builder);
    3838 template class SymbolTableListTraits;
    3939
    4040
    41 BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
    41 BasicBlock::BasicBlock(const Twine &Name, Function *NewParent,
    4242 BasicBlock *InsertBefore)
    4343 : Value(Type::LabelTy, Value::BasicBlockVal), Parent(0) {
    4444
    239239 /// cause a degenerate basic block to be formed, having a terminator inside of
    240240 /// the basic block).
    241241 ///
    242 BasicBlock *BasicBlock::splitBasicBlock(iterator I, const std::string &BBName) {
    242 BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
    243243 assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
    244244 assert(I != InstList.end() &&
    245245 "Trying to get me to create degenerate basic block!");
    3535 // Argument Implementation
    3636 //===----------------------------------------------------------------------===//
    3737
    38 Argument::Argument(const Type *Ty, const std::string &Name, Function *Par)
    38 Argument::Argument(const Type *Ty, const Twine &Name, Function *Par)
    3939 : Value(Ty, Value::ArgumentVal) {
    4040 Parent = 0;
    4141
    143143 //===----------------------------------------------------------------------===//
    144144
    145145 Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
    146 const std::string &name, Module *ParentModule)
    146 const Twine &name, Module *ParentModule)
    147147 : GlobalValue(PointerType::getUnqual(Ty),
    148148 Value::FunctionVal, 0, 0, Linkage, name) {
    149149 assert(FunctionType::isValidReturnType(getReturnType()) &&
    9595
    9696 GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,
    9797 bool constant, LinkageTypes Link,
    98 Constant *InitVal, const std::string &Name,
    98 Constant *InitVal, const Twine &Name,
    9999 bool ThreadLocal, unsigned AddressSpace)
    100100 : GlobalValue(Context.getPointerType(Ty, AddressSpace),
    101101 Value::GlobalVariableVal,
    113113
    114114 GlobalVariable::GlobalVariable(Module &M, const Type *Ty, bool constant,
    115115 LinkageTypes Link, Constant *InitVal,
    116 const std::string &Name,
    116 const Twine &Name,
    117117 GlobalVariable *Before, bool ThreadLocal,
    118118 unsigned AddressSpace)
    119119 : GlobalValue(M.getContext().getPointerType(Ty, AddressSpace),
    350350 assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
    351351 }
    352352
    353 CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
    353 CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,
    354354 Instruction *InsertBefore)
    355355 : Instruction(cast(cast(Func->getType())
    356356 ->getElementType())->getReturnType(),
    361361 setName(Name);
    362362 }
    363363
    364 CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
    364 CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,
    365365 BasicBlock *InsertAtEnd)
    366366 : Instruction(cast(cast(Func->getType())
    367367 ->getElementType())->getReturnType(),
    371371 init(Func, Actual);
    372372 setName(Name);
    373373 }
    374 CallInst::CallInst(Value *Func, const std::string &Name,
    374 CallInst::CallInst(Value *Func, const Twine &Name,
    375375 Instruction *InsertBefore)
    376376 : Instruction(cast(cast(Func->getType())
    377377 ->getElementType())->getReturnType(),
    382382 setName(Name);
    383383 }
    384384
    385 CallInst::CallInst(Value *Func, const std::string &Name,
    385 CallInst::CallInst(Value *Func, const Twine &Name,
    386386 BasicBlock *InsertAtEnd)
    387387 : Instruction(cast(cast(Func->getType())
    388388 ->getElementType())->getReturnType(),
    713713 }
    714714
    715715 AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
    716 unsigned Align, const std::string &Name,
    716 unsigned Align, const Twine &Name,
    717717 Instruction *InsertBefore)
    718718 : UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,
    719719 getAISize(Ty->getContext(), ArraySize), InsertBefore) {
    723723 }
    724724
    725725 AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
    726 unsigned Align, const std::string &Name,
    726 unsigned Align, const Twine &Name,
    727727 BasicBlock *InsertAtEnd)
    728728 : UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,
    729729 getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
    805805 "Ptr must have pointer type.");
    806806 }
    807807
    808 LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
    808 LoadInst::LoadInst(Value *Ptr, const Twine &Name, Instruction *InsertBef)
    809809 : UnaryInstruction(cast(Ptr->getType())->getElementType(),
    810810 Load, Ptr, InsertBef) {
    811811 setVolatile(false);
    814814 setName(Name);
    815815 }
    816816
    817 LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
    817 LoadInst::LoadInst(Value *Ptr, const Twine &Name, BasicBlock *InsertAE)
    818818 : UnaryInstruction(cast(Ptr->getType())->getElementType(),
    819819 Load, Ptr, InsertAE) {
    820820 setVolatile(false);
    823823 setName(Name);
    824824 }
    825825
    826 LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
    826 LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
    827827 Instruction *InsertBef)
    828828 : UnaryInstruction(cast(Ptr->getType())->getElementType(),
    829829 Load, Ptr, InsertBef) {
    833833 setName(Name);
    834834 }
    835835
    836 LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
    836 LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
    837837 unsigned Align, Instruction *InsertBef)
    838838 : UnaryInstruction(cast(Ptr->getType())->getElementType(),
    839839 Load, Ptr, InsertBef) {
    843843 setName(Name);
    844844 }
    845845
    846 LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
    846 LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
    847847 unsigned Align, BasicBlock *InsertAE)
    848848 : UnaryInstruction(cast(Ptr->getType())->getElementType(),
    849849 Load, Ptr, InsertAE) {
    853853 setName(Name);
    854854 }
    855855
    856 LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
    856 LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
    857857 BasicBlock *InsertAE)
    858858 : UnaryInstruction(cast(Ptr->getType())->getElementType(),
    859859 Load, Ptr, InsertAE) {
    10121012 }
    10131013
    10141014 void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
    1015 const std::string &Name) {
    1015 const Twine &Name) {
    10161016 assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
    10171017 Use *OL = OperandList;
    10181018 OL[0] = Ptr;
    10231023 setName(Name);
    10241024 }
    10251025
    1026 void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) {
    1026 void GetElementPtrInst::init(Value *Ptr, Value *Idx, const Twine &Name) {
    10271027 assert(NumOperands == 2 && "NumOperands not initialized?");
    10281028 Use *OL = OperandList;
    10291029 OL[0] = Ptr;
    10441044 }
    10451045
    10461046 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
    1047 const std::string &Name, Instruction *InBe)
    1047 const Twine &Name, Instruction *InBe)
    10481048 : Instruction(Ptr->getType()->getContext().getPointerType(
    10491049 checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)),
    10501050 GetElementPtr,
    10541054 }
    10551055
    10561056 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
    1057 const std::string &Name, BasicBlock *IAE)
    1057 const Twine &Name, BasicBlock *IAE)
    10581058 : Instruction(Ptr->getType()->getContext().getPointerType(
    10591059 checkType(getIndexedType(Ptr->getType(),Idx)),
    10601060 retrieveAddrSpace(Ptr)),
    11631163 //===----------------------------------------------------------------------===//
    11641164
    11651165 ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
    1166 const std::string &Name,
    1166 const Twine &Name,
    11671167 Instruction *InsertBef)
    11681168 : Instruction(cast(Val->getType())->getElementType(),
    11691169 ExtractElement,
    11771177 }
    11781178
    11791179 ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
    1180 const std::string &Name,
    1180 const Twine &Name,
    11811181 BasicBlock *InsertAE)
    11821182 : Instruction(cast(Val->getType())->getElementType(),
    11831183 ExtractElement,
    12111211 Op<2>() = IE.Op<2>();
    12121212 }
    12131213 InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
    1214 const std::string &Name,
    1214 const Twine &Name,
    12151215 Instruction *InsertBef)
    12161216 : Instruction(Vec->getType(), InsertElement,
    12171217 OperandTraits::op_begin(this),
    12251225 }
    12261226
    12271227 InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
    1228 const std::string &Name,
    1228 const Twine &Name,
    12291229 BasicBlock *InsertAE)
    12301230 : Instruction(Vec->getType(), InsertElement,
    12311231 OperandTraits::op_begin(this),
    12671267 }
    12681268
    12691269 ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
    1270 const std::string &Name,
    1270 const Twine &Name,
    12711271 Instruction *InsertBefore)
    12721272 : Instruction(V1->getType()->getContext().getVectorType(
    12731273 cast(V1->getType())->getElementType(),
    12851285 }
    12861286
    12871287 ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
    1288 const std::string &Name,
    1288 const Twine &Name,
    12891289 BasicBlock *InsertAtEnd)
    12901290 : Instruction(V1->getType(), ShuffleVector,
    12911291 OperandTraits::op_begin(this),
    13321332 //===----------------------------------------------------------------------===//
    13331333
    13341334 void InsertValueInst::init(Value *Agg, Value *Val, const unsigned *Idx,
    1335 unsigned NumIdx, const std::string &Name) {
    1335 unsigned NumIdx, const Twine &Name) {
    13361336 assert(NumOperands == 2 && "NumOperands not initialized?");
    13371337 Op<0>() = Agg;
    13381338 Op<1>() = Val;
    13421342 }
    13431343
    13441344 void InsertValueInst::init(Value *Agg, Value *Val, unsigned Idx,
    1345 const std::string &Name) {
    1345 const Twine &Name) {
    13461346 assert(NumOperands == 2 && "NumOperands not initialized?");
    13471347 Op<0>() = Agg;
    13481348 Op<1>() = Val;
    13621362 InsertValueInst::InsertValueInst(Value *Agg,
    13631363 Value *Val,
    13641364 unsigned Idx,
    1365 const std::string &Name,
    1365 const Twine &Name,
    13661366 Instruction *InsertBefore)
    13671367 : Instruction(Agg->getType(), InsertValue,
    13681368 OperandTraits::op_begin(this),
    13731373 InsertValueInst::InsertValueInst(Value *Agg,
    13741374 Value *Val,
    13751375 unsigned Idx,
    1376 const std::string &Name,
    1376 const Twine &Name,
    13771377 BasicBlock *InsertAtEnd)
    13781378 : Instruction(Agg->getType(), InsertValue,
    13791379 OperandTraits::op_begin(this),
    13861386 //===----------------------------------------------------------------------===//
    13871387
    13881388 void ExtractValueInst::init(const unsigned *Idx, unsigned NumIdx,
    1389 const std::string &Name) {
    1389 const Twine &Name) {
    13901390 assert(NumOperands == 1 && "NumOperands not initialized?");
    13911391
    13921392 Indices.insert(Indices.end(), Idx, Idx + NumIdx);
    13931393 setName(Name);
    13941394 }
    13951395
    1396 void ExtractValueInst::init(unsigned Idx, const std::string &Name) {
    1396 void ExtractValueInst::init(unsigned Idx, const Twine &Name) {
    13971397 assert(NumOperands == 1 && "NumOperands not initialized?");
    13981398
    13991399 Indices.push_back(Idx);
    14561456 }
    14571457
    14581458 BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
    1459 const Type *Ty, const std::string &Name,
    1459 const Type *Ty, const Twine &Name,
    14601460 Instruction *InsertBefore)
    14611461 : Instruction(Ty, AdjustIType(iType, Ty),
    14621462 OperandTraits::op_begin(this),
    14691469 }
    14701470
    14711471 BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
    1472 const Type *Ty, const std::string &Name,
    1472 const Type *Ty, const Twine &Name,
    14731473 BasicBlock *InsertAtEnd)
    14741474 : Instruction(Ty, AdjustIType(iType, Ty),
    14751475 OperandTraits::op_begin(this),
    15581558 }
    15591559
    15601560 BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
    1561 const std::string &Name,
    1561 const Twine &Name,
    15621562 Instruction *InsertBefore) {
    15631563 assert(S1->getType() == S2->getType() &&
    15641564 "Cannot create binary operator with two operands of differing type!");
    15661566 }
    15671567
    15681568 BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
    1569 const std::string &Name,
    1569 const Twine &Name,
    15701570 BasicBlock *InsertAtEnd) {
    15711571 BinaryOperator *Res = Create(Op, S1, S2, Name);
    15721572 InsertAtEnd->getInstList().push_back(Res);
    15741574 }
    15751575
    15761576 BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
    1577 Value *Op, const std::string &Name,
    1577 Value *Op, const Twine &Name,
    15781578 Instruction *InsertBefore) {
    15791579 Value *zero = Context.getZeroValueForNegation(Op->getType());
    15801580 return new BinaryOperator(Instruction::Sub,
    15831583 }
    15841584
    15851585 BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
    1586 Value *Op, const std::string &Name,
    1586 Value *Op, const Twine &Name,
    15871587 BasicBlock *InsertAtEnd) {
    15881588 Value *zero = Context.getZeroValueForNegation(Op->getType());
    15891589 return new BinaryOperator(Instruction::Sub,
    15921592 }
    15931593
    15941594 BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
    1595 Value *Op, const std::string &Name,
    1595 Value *Op, const Twine &Name,
    15961596 Instruction *InsertBefore) {
    15971597 Value *zero = Context.getZeroValueForNegation(Op->getType());
    15981598 return new BinaryOperator(Instruction::FSub,
    16011601 }
    16021602
    16031603 BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
    1604 Value *Op, const std::string &Name,
    1604 Value *Op, const Twine &Name,
    16051605 BasicBlock *InsertAtEnd) {
    16061606 Value *zero = Context.getZeroValueForNegation(Op->getType());
    16071607 return new BinaryOperator(Instruction::FSub,
    16101610 }
    16111611
    16121612 BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
    1613 Value *Op, const std::string &Name,
    1613 Value *Op, const Twine &Name,
    16141614 Instruction *InsertBefore) {
    16151615 Constant *C;
    16161616 if (const VectorType *PTy = dyn_cast(Op->getType())) {
    16261626 }
    16271627
    16281628 BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
    1629 Value *Op, const std::string &Name,
    1629 Value *Op, const Twine &Name,
    16301630 BasicBlock *InsertAtEnd) {
    16311631 Constant *AllOnes;
    16321632 if (const VectorType *PTy = dyn_cast(Op->getType())) {
    19511951 }
    19521952
    19531953 CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
    1954 const std::string &Name, Instruction *InsertBefore) {
    1954 const Twine &Name, Instruction *InsertBefore) {
    19551955 // Construct and return the appropriate CastInst subclass
    19561956 switch (op) {
    19571957 case Trunc: return new TruncInst (S, Ty, Name, InsertBefore);
    19731973 }
    19741974
    19751975 CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
    1976 const std::string &Name, BasicBlock *InsertAtEnd) {
    1976 const Twine &Name, BasicBlock *InsertAtEnd) {
    19771977 // Construct and return the appropriate CastInst subclass
    19781978 switch (op) {
    19791979 case Trunc: return new TruncInst (S, Ty, Name, InsertAtEnd);
    19951995 }
    19961996
    19971997 CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,
    1998 const std::string &Name,
    1998 const Twine &Name,
    19991999 Instruction *InsertBefore) {
    20002000 if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
    20012001 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
    20032003 }
    20042004
    20052005 CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,
    2006 const std::string &Name,
    2006 const Twine &Name,
    20072007 BasicBlock *InsertAtEnd) {
    20082008 if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
    20092009 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
    20112011 }
    20122012
    20132013 CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,
    2014 const std::string &Name,
    2014 const Twine &Name,
    20152015 Instruction *InsertBefore) {
    20162016 if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
    20172017 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
    20192019 }
    20202020
    20212021 CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,
    2022 const std::string &Name,
    2022 const Twine &Name,
    20232023 BasicBlock *InsertAtEnd) {
    20242024 if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
    20252025 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
    20272027 }
    20282028
    20292029 CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
    2030 const std::string &Name,
    2030 const Twine &Name,
    20312031 Instruction *InsertBefore) {
    20322032 if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
    20332033 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
    20352035 }
    20362036
    20372037 CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
    2038 const std::string &Name,
    2038 const Twine &Name,
    20392039 BasicBlock *InsertAtEnd) {
    20402040 if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
    20412041 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
    20432043 }
    20442044
    20452045 CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
    2046 const std::string &Name,
    2046 const Twine &Name,
    20472047 BasicBlock *InsertAtEnd) {
    20482048 assert(isa(S->getType()) && "Invalid cast");
    20492049 assert((Ty->isInteger() || isa(Ty)) &&
    20562056
    20572057 /// @brief Create a BitCast or a PtrToInt cast instruction
    20582058 CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
    2059 const std::string &Name,
    2059 const Twine &Name,
    20602060 Instruction *InsertBefore) {
    20612061 assert(isa(S->getType()) && "Invalid cast");
    20622062 assert((Ty->isInteger() || isa(Ty)) &&
    20682068 }
    20692069
    20702070 CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
    2071 bool isSigned, const std::string &Name,
    2071 bool isSigned, const Twine &Name,
    20722072 Instruction *InsertBefore) {
    20732073 assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
    20742074 unsigned SrcBits = C->getType()->getScalarSizeInBits();
    20812081 }
    20822082
    20832083 CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
    2084 bool isSigned, const std::string &Name,
    2084 bool isSigned, const Twine &Name,
    20852085 BasicBlock *InsertAtEnd) {
    20862086 assert(C->getType()->isIntOrIntVector() && Ty->isIntOrIntVector() &&
    20872087 "Invalid cast");
    20952095 }
    20962096
    20972097 CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
    2098 const std::string &Name,
    2098 const Twine &Name,
    20992099 Instruction *InsertBefore) {
    21002100 assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&
    21012101 "Invalid cast");
    21082108 }
    21092109
    21102110 CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
    2111 const std::string &Name,
    2111 const Twine &Name,
    21122112 BasicBlock *InsertAtEnd) {
    21132113 assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&
    21142114 "Invalid cast");
    23522352 }
    23532353
    23542354 TruncInst::TruncInst(
    2355 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2355 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    23562356 ) : CastInst(Ty, Trunc, S, Name, InsertBefore) {
    23572357 assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");
    23582358 }
    23592359
    23602360 TruncInst::TruncInst(
    2361 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2361 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    23622362 ) : CastInst(Ty, Trunc, S, Name, InsertAtEnd) {
    23632363 assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");
    23642364 }
    23652365
    23662366 ZExtInst::ZExtInst(
    2367 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2367 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    23682368 ) : CastInst(Ty, ZExt, S, Name, InsertBefore) {
    23692369 assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");
    23702370 }
    23712371
    23722372 ZExtInst::ZExtInst(
    2373 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2373 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    23742374 ) : CastInst(Ty, ZExt, S, Name, InsertAtEnd) {
    23752375 assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");
    23762376 }
    23772377 SExtInst::SExtInst(
    2378 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2378 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    23792379 ) : CastInst(Ty, SExt, S, Name, InsertBefore) {
    23802380 assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");
    23812381 }
    23822382
    23832383 SExtInst::SExtInst(
    2384 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2384 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    23852385 ) : CastInst(Ty, SExt, S, Name, InsertAtEnd) {
    23862386 assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");
    23872387 }
    23882388
    23892389 FPTruncInst::FPTruncInst(
    2390 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2390 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    23912391 ) : CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
    23922392 assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");
    23932393 }
    23942394
    23952395 FPTruncInst::FPTruncInst(
    2396 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2396 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    23972397 ) : CastInst(Ty, FPTrunc, S, Name, InsertAtEnd) {
    23982398 assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");
    23992399 }
    24002400
    24012401 FPExtInst::FPExtInst(
    2402 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2402 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    24032403 ) : CastInst(Ty, FPExt, S, Name, InsertBefore) {
    24042404 assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");
    24052405 }
    24062406
    24072407 FPExtInst::FPExtInst(
    2408 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2408 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    24092409 ) : CastInst(Ty, FPExt, S, Name, InsertAtEnd) {
    24102410 assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");
    24112411 }
    24122412
    24132413 UIToFPInst::UIToFPInst(
    2414 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2414 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    24152415 ) : CastInst(Ty, UIToFP, S, Name, InsertBefore) {
    24162416 assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");
    24172417 }
    24182418
    24192419 UIToFPInst::UIToFPInst(
    2420 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2420 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    24212421 ) : CastInst(Ty, UIToFP, S, Name, InsertAtEnd) {
    24222422 assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");
    24232423 }
    24242424
    24252425 SIToFPInst::SIToFPInst(
    2426 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2426 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    24272427 ) : CastInst(Ty, SIToFP, S, Name, InsertBefore) {
    24282428 assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");
    24292429 }
    24302430
    24312431 SIToFPInst::SIToFPInst(
    2432 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2432 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    24332433 ) : CastInst(Ty, SIToFP, S, Name, InsertAtEnd) {
    24342434 assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");
    24352435 }
    24362436
    24372437 FPToUIInst::FPToUIInst(
    2438 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2438 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    24392439 ) : CastInst(Ty, FPToUI, S, Name, InsertBefore) {
    24402440 assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");
    24412441 }
    24422442
    24432443 FPToUIInst::FPToUIInst(
    2444 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2444 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    24452445 ) : CastInst(Ty, FPToUI, S, Name, InsertAtEnd) {
    24462446 assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");
    24472447 }
    24482448
    24492449 FPToSIInst::FPToSIInst(
    2450 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2450 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    24512451 ) : CastInst(Ty, FPToSI, S, Name, InsertBefore) {
    24522452 assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");
    24532453 }
    24542454
    24552455 FPToSIInst::FPToSIInst(
    2456 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2456 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    24572457 ) : CastInst(Ty, FPToSI, S, Name, InsertAtEnd) {
    24582458 assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");
    24592459 }
    24602460
    24612461 PtrToIntInst::PtrToIntInst(
    2462 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2462 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    24632463 ) : CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
    24642464 assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");
    24652465 }
    24662466
    24672467 PtrToIntInst::PtrToIntInst(
    2468 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2468 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    24692469 ) : CastInst(Ty, PtrToInt, S, Name, InsertAtEnd) {
    24702470 assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");
    24712471 }
    24722472
    24732473 IntToPtrInst::IntToPtrInst(
    2474 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2474 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    24752475 ) : CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
    24762476 assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");
    24772477 }
    24782478
    24792479 IntToPtrInst::IntToPtrInst(
    2480 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2480 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    24812481 ) : CastInst(Ty, IntToPtr, S, Name, InsertAtEnd) {
    24822482 assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");
    24832483 }
    24842484
    24852485 BitCastInst::BitCastInst(
    2486 Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
    2486 Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
    24872487 ) : CastInst(Ty, BitCast, S, Name, InsertBefore) {
    24882488 assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");
    24892489 }
    24902490
    24912491 BitCastInst::BitCastInst(
    2492 Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
    2492 Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
    24932493 ) : CastInst(Ty, BitCast, S, Name, InsertAtEnd) {
    24942494 assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");
    24952495 }
    24992499 //===----------------------------------------------------------------------===//
    25002500
    25012501 CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
    2502 Value *LHS, Value *RHS, const std::string &Name,
    2502 Value *LHS, Value *RHS, const Twine &Name,
    25032503 Instruction *InsertBefore)
    25042504 : Instruction(ty, op,
    25052505 OperandTraits::op_begin(this),
    25122512 }
    25132513
    25142514 CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
    2515 Value *LHS, Value *RHS, const std::string &Name,
    2515 Value *LHS, Value *RHS, const Twine &Name,
    25162516 BasicBlock *InsertAtEnd)
    25172517 : Instruction(ty, op,
    25182518 OperandTraits::op_begin(this),
    25272527 CmpInst *
    25282528 CmpInst::Create(LLVMContext &Context, OtherOps Op, unsigned short predicate,
    25292529 Value *S1, Value *S2,
    2530 const std::string &Name, Instruction *InsertBefore) {
    2530 const Twine &Name, Instruction *InsertBefore) {
    25312531 if (Op == Instruction::ICmp) {
    25322532 if (InsertBefore)
    25332533 return new ICmpInst(InsertBefore, CmpInst::Predicate(predicate),
    25472547
    25482548 CmpInst *
    25492549 CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2,
    2550 const std::string &Name, BasicBlock *InsertAtEnd) {
    2550 const Twine &Name, BasicBlock *InsertAtEnd) {
    25512551 if (Op == Instruction::ICmp) {
    25522552 return new ICmpInst(*InsertAtEnd, CmpInst::Predicate(predicate),
    25532553 S1, S2, Name);
    1919 #include "llvm/Module.h"
    2020 #include "llvm/MDNode.h"
    2121 #include "llvm/ValueSymbolTable.h"
    22 #include "llvm/ADT/SmallString.h"
    2223 #include "llvm/Support/Debug.h"
    2324 #include "llvm/Support/ErrorHandling.h"
    2425 #include "llvm/Support/LeakDetector.h"
    182183 return StringRef(Name->getKeyData(), Name->getKeyLength());
    183184 }
    184185
    185 void Value::setName(const std::string &name) {
    186 setName(&name[0], name.size());
    186 void Value::setName(const Twine &Name) {
    187 SmallString<32> NameData;
    188 Name.toVector(NameData);
    189 setName(NameData.begin(), NameData.size());
    187190 }
    188191
    189192 void Value::setName(const char *Name) {
    303303 // CheckFailed - A check failed, so print out the condition and the message
    304304 // that failed. This provides a nice place to put a breakpoint if you want
    305305 // to see why something is not correct.
    306 void CheckFailed(const std::string &Message,
    306 void CheckFailed(const Twine &Message,
    307307 const Value *V1 = 0, const Value *V2 = 0,
    308308 const Value *V3 = 0, const Value *V4 = 0) {
    309 msgs << Message << "\n";
    309 msgs << Message.str() << "\n";
    310310 WriteValue(V1);
    311311 WriteValue(V2);
    312312 WriteValue(V3);
    314314 Broken = true;
    315315 }
    316316
    317 void CheckFailed( const std::string& Message, const Value* V1,
    318 const Type* T2, const Value* V3 = 0 ) {
    319 msgs << Message << "\n";
    317 void CheckFailed(const Twine &Message, const Value* V1,
    318 const Type* T2, const Value* V3 = 0) {
    319 msgs << Message.str() << "\n";
    320320 WriteValue(V1);
    321321 WriteType(T2);
    322322 WriteValue(V3);