aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/ProgrammersManual.html106
-rw-r--r--docs/ReleaseNotes-2.6.html8
-rw-r--r--include/llvm/Argument.h3
-rw-r--r--include/llvm/BasicBlock.h6
-rw-r--r--include/llvm/Function.h4
-rw-r--r--include/llvm/GlobalValue.h4
-rw-r--r--include/llvm/GlobalVariable.h4
-rw-r--r--include/llvm/InstrTypes.h68
-rw-r--r--include/llvm/Instructions.h258
-rw-r--r--include/llvm/Value.h5
-rw-r--r--lib/Linker/LinkModules.cpp4
-rw-r--r--lib/Transforms/Scalar/GVNPRE.cpp3
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp6
-rw-r--r--lib/VMCore/BasicBlock.cpp4
-rw-r--r--lib/VMCore/Function.cpp4
-rw-r--r--lib/VMCore/Globals.cpp4
-rw-r--r--lib/VMCore/Instructions.cpp160
-rw-r--r--lib/VMCore/Value.cpp7
-rw-r--r--lib/VMCore/Verifier.cpp10
19 files changed, 392 insertions, 276 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html
index dba7213..1931a68 100644
--- a/docs/ProgrammersManual.html
+++ b/docs/ProgrammersManual.html
@@ -29,6 +29,12 @@
<ul>
<li><a href="#isa">The <tt>isa&lt;&gt;</tt>, <tt>cast&lt;&gt;</tt>
and <tt>dyn_cast&lt;&gt;</tt> templates</a> </li>
+ <li><a href="#string_apis">Passing strings (the <tt>StringRef</tt>
+and <tt>Twine</tt> classes)</li>
+ <ul>
+ <li><a href="#StringRef">The <tt>StringRef</tt> class</a> </li>
+ <li><a href="#Twine">The <tt>Twine</tt> class</a> </li>
+ </ul>
<li><a href="#DEBUG">The <tt>DEBUG()</tt> macro and <tt>-debug</tt>
option</a>
<ul>
@@ -424,6 +430,106 @@ are lots of examples in the LLVM source base.</p>
</div>
+
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+ <a name="string_apis">Passing strings (the <tt>StringRef</tt>
+and <tt>Twine</tt> classes)</a>
+</div>
+
+<div class="doc_text">
+
+<p>Although LLVM generally does not do much string manipulation, we do have
+several important APIs which take string. Several important examples are the
+Value class -- which has names for instructions, functions, etc. -- and the
+StringMap class which is used extensively in LLVM and Clang.</p>
+
+<p>These are generic classes, and they need to be able to accept strings which
+may have embedded null characters. Therefore, they cannot simply take
+a <tt>const char *</tt>, and taking a <tt>const std::string&</tt> requires
+clients to perform a heap allocation which is usually unnecessary. Instead,
+many LLVM APIs use a <tt>const StringRef&</tt> or a <tt>const Twine&</tt> for
+passing strings efficiently.</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+ <a name="StringRef">The <tt>StringRef</tt> class</a>
+</div>
+
+<div class="doc_text">
+
+<p>The <tt>StringRef</tt> data type represents a reference to a constant string
+(a character array and a length) and supports the common operations available
+on <tt>std:string</tt>, but does not require heap allocation.</p>
+
+It can be implicitly constructed using either a C style null-terminated string
+or an <tt>std::string</tt>, or explicitly with a character pointer and length.
+For example, the <tt>StringRef</tt> find function is declared as:</p>
+<div class="doc_code">
+ iterator find(const StringRef &Key);
+</div>
+
+<p>and clients can call it using any one of:</p>
+
+<div class="doc_code">
+<pre>
+ Map.find("foo"); <i>// Lookup "foo"</i>
+ Map.find(std::string("bar")); <i>// Lookup "bar"</i>
+ Map.find(StringRef("\0baz", 4)); <i>// Lookup "\0baz"</i>
+</pre>
+</div>
+
+<p>Similarly, APIs which need to return a string may return a <tt>StringRef</tt>
+instance, which can be used directly or converted to an <tt>std::string</tt>
+using the <tt>str</tt> member function. See
+"<tt><a href="/doxygen/classllvm_1_1StringRef_8h-source.html">llvm/ADT/StringRef.h</a></tt>"
+for more information.</p>
+
+<p>You should rarely use the <tt>StringRef</tt> class directly, because it contains
+pointers to external memory it is not generally safe to store an instance of the
+class (since the external storage may be freed).</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+ <a name="Twine">The <tt>Twine</tt> class</a>
+</div>
+
+<div class="doc_text">
+
+<p>The <tt>Twine</tt> class is an efficient way for APIs to accept concatenated
+strings. For example, a common LLVM paradigm is to name one instruction based on
+the name of another instruction with a suffix, for example:</p>
+
+<div class="doc_code">
+<pre>
+ New = CmpInst::Create(<i>...</i>, SO->getName() + ".cmp");
+</pre>
+</div>
+
+<p>The <tt>Twine</tt> class is effectively a
+lightweight <a href="http://en.wikipedia.org/wiki/Rope_(computer_science)">rope</a>
+which points to temporary (stack allocated) objects. Twines can be implicitly
+constructed as the result of the plus operator applied to strings (i.e., a C
+strings, an <tt>std::string</tt>, or a <tt>StringRef</tt>). The twine delays the
+actual concatentation of strings until it is actually required, at which point
+it can be efficiently rendered directly into a character array. This avoids
+unnecessary heap allocation involved in constructing the temporary results of
+string concatenation. See
+"<tt><a href="/doxygen/classllvm_1_1Twine_8h-source.html">llvm/ADT/Twine.h</a></tt>"
+for more information.</p></tt>
+
+<p>As with a <tt>StringRef</tt>, <tt>Twine</tt> objects point to external memory
+and should almost never be stored or mentioned directly. They are intended
+solely for use when defining a function which should be able to efficiently
+accept concatenated strings.</p>
+
+</div>
+
+
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="DEBUG">The <tt>DEBUG()</tt> macro and <tt>-debug</tt> option</a>
diff --git a/docs/ReleaseNotes-2.6.html b/docs/ReleaseNotes-2.6.html
index f1b8852..b6b6724 100644
--- a/docs/ReleaseNotes-2.6.html
+++ b/docs/ReleaseNotes-2.6.html
@@ -460,8 +460,14 @@ API changes are:</p>
<li><tt>SCEVHandle</tt> no longer exists, because reference counting is no
longer done for <tt>SCEV*</tt> objects, instead <tt>const SCEV*</tt> should be
used.</li>
+<li>Many APIs, notably <tt>llvm::Value</tt>, now use the <tt>StringRef</tt>
+and <tt>Twine</tt> classes instead of passing <tt>const char*</tt>
+or <tt>std::string</tt>, as described in
+the <a href="ProgrammersManual.html#string_apis">Programmer's Manual</a>. Most
+clients should be uneffected by this transition.</li>
<li>llvm-dis now fails if output file exists, instead of dumping to stdout.
-FIXME: describe any other tool changes due to the raw_fd_ostream change</li>
+FIXME: describe any other tool changes due to the raw_fd_ostream change. FIXME:
+This is not an API change, maybe there should be a tool changes section?</li>
<li>temporarely due to Context API change passes should call doInitialization()
method of the pass they inherit from, otherwise Context is NULL.
FIXME: remove this entry when this is no longer needed.<li>
diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h
index 9c06367..3a846c2 100644
--- a/include/llvm/Argument.h
+++ b/include/llvm/Argument.h
@@ -38,8 +38,7 @@ public:
/// Argument ctor - If Function argument is specified, this argument is
/// inserted at the end of the argument list for the function.
///
- explicit Argument(const Type *Ty, const std::string &Name = "",
- Function *F = 0);
+ explicit Argument(const Type *Ty, const Twine &Name = "", Function *F = 0);
inline const Function *getParent() const { return Parent; }
inline Function *getParent() { return Parent; }
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h
index a20309f..eabc1a0 100644
--- a/include/llvm/BasicBlock.h
+++ b/include/llvm/BasicBlock.h
@@ -83,7 +83,7 @@ private:
/// is automatically inserted at either the end of the function (if
/// InsertBefore is null), or before the specified basic block.
///
- explicit BasicBlock(const std::string &Name = "", Function *Parent = 0,
+ explicit BasicBlock(const Twine &Name = "", Function *Parent = 0,
BasicBlock *InsertBefore = 0);
public:
/// getContext - Get the context in which this basic block lives,
@@ -97,7 +97,7 @@ public:
/// Create - Creates a new BasicBlock. If the Parent parameter is specified,
/// the basic block is automatically inserted at either the end of the
/// function (if InsertBefore is 0), or before the specified basic block.
- static BasicBlock *Create(const std::string &Name = "", Function *Parent = 0,
+ static BasicBlock *Create(const Twine &Name = "", Function *Parent = 0,
BasicBlock *InsertBefore = 0) {
return new BasicBlock(Name, Parent, InsertBefore);
}
@@ -232,7 +232,7 @@ public:
/// cause a degenerate basic block to be formed, having a terminator inside of
/// the basic block).
///
- BasicBlock *splitBasicBlock(iterator I, const std::string &BBName = "");
+ BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "");
};
} // End llvm namespace
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index 3bf65ff..57ebfb1 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -114,11 +114,11 @@ private:
/// the module.
///
Function(const FunctionType *Ty, LinkageTypes Linkage,
- const std::string &N = "", Module *M = 0);
+ const Twine &N = "", Module *M = 0);
public:
static Function *Create(const FunctionType *Ty, LinkageTypes Linkage,
- const std::string &N = "", Module *M = 0) {
+ const Twine &N = "", Module *M = 0) {
return new(0) Function(Ty, Linkage, N, M);
}
diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h
index b897f9f..d53d49b 100644
--- a/include/llvm/GlobalValue.h
+++ b/include/llvm/GlobalValue.h
@@ -56,10 +56,10 @@ public:
protected:
GlobalValue(const Type *ty, ValueTy vty, Use *Ops, unsigned NumOps,
- LinkageTypes linkage, const std::string &name = "")
+ LinkageTypes linkage, const Twine &Name = "")
: Constant(ty, vty, Ops, NumOps), Parent(0),
Linkage(linkage), Visibility(DefaultVisibility), Alignment(0) {
- if (!name.empty()) setName(name);
+ setName(Name);
}
Module *Parent;
diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h
index 28eaa62..f18554d 100644
--- a/include/llvm/GlobalVariable.h
+++ b/include/llvm/GlobalVariable.h
@@ -52,13 +52,13 @@ public:
/// automatically inserted into the end of the specified modules global list.
GlobalVariable(LLVMContext &Context, const Type *Ty, bool isConstant,
LinkageTypes Linkage,
- Constant *Initializer = 0, const std::string &Name = "",
+ Constant *Initializer = 0, const Twine &Name = "",
bool ThreadLocal = false, unsigned AddressSpace = 0);
/// GlobalVariable ctor - This creates a global and inserts it before the
/// specified other global.
GlobalVariable(Module &M, const Type *Ty, bool isConstant,
LinkageTypes Linkage, Constant *Initializer,
- const std::string &Name,
+ const Twine &Name,
GlobalVariable *InsertBefore = 0, bool ThreadLocal = false,
unsigned AddressSpace = 0);
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index c3c48af..43fe664 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -144,9 +144,9 @@ class BinaryOperator : public Instruction {
protected:
void init(BinaryOps iType);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
- const std::string &Name, Instruction *InsertBefore);
+ const Twine &Name, Instruction *InsertBefore);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
- const std::string &Name, BasicBlock *InsertAtEnd);
+ const Twine &Name, BasicBlock *InsertAtEnd);
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
@@ -162,7 +162,7 @@ public:
/// Instruction is allowed to be a dereferenced end iterator.
///
static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name = "",
+ const Twine &Name = "",
Instruction *InsertBefore = 0);
/// Create() - Construct a binary instruction, given the opcode and the two
@@ -170,27 +170,26 @@ public:
/// BasicBlock specified.
///
static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name,
- BasicBlock *InsertAtEnd);
+ const Twine &Name, BasicBlock *InsertAtEnd);
/// Create* - These methods just forward to Create, and are useful when you
/// statically know what type of instruction you're going to create. These
/// helpers just save some typing.
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name = "") {\
+ const Twine &Name = "") {\
return Create(Instruction::OPC, V1, V2, Name);\
}
#include "llvm/Instruction.def"
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name, BasicBlock *BB) {\
+ const Twine &Name, BasicBlock *BB) {\
return Create(Instruction::OPC, V1, V2, Name, BB);\
}
#include "llvm/Instruction.def"
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
- const std::string &Name, Instruction *I) {\
+ const Twine &Name, Instruction *I) {\
return Create(Instruction::OPC, V1, V2, Name, I);\
}
#include "llvm/Instruction.def"
@@ -203,22 +202,22 @@ public:
/// instructions out of SUB and XOR instructions.
///
static BinaryOperator *CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
static BinaryOperator *CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name = "",
+ Value *Op, const Twine &Name = "",
Instruction *InsertBefore = 0);
static BinaryOperator *CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
/// isNeg, isFNeg, isNot - Check if the given Value is a
@@ -288,13 +287,13 @@ class CastInst : public UnaryInstruction {
protected:
/// @brief Constructor with insert-before-instruction semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
- const std::string &NameStr = "", Instruction *InsertBefore = 0)
+ const Twine &NameStr = "", Instruction *InsertBefore = 0)
: UnaryInstruction(Ty, iType, S, InsertBefore) {
setName(NameStr);
}
/// @brief Constructor with insert-at-end-of-block semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty, iType, S, InsertAtEnd) {
setName(NameStr);
}
@@ -309,7 +308,7 @@ public:
Instruction::CastOps, ///< The opcode of the cast instruction
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
/// Provides a way to construct any of the CastInst subclasses using an
@@ -322,7 +321,7 @@ public:
Instruction::CastOps, ///< The opcode for the cast instruction
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -330,7 +329,7 @@ public:
static CastInst *CreateZExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -338,7 +337,7 @@ public:
static CastInst *CreateZExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -346,7 +345,7 @@ public:
static CastInst *CreateSExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -354,7 +353,7 @@ public:
static CastInst *CreateSExtOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -362,7 +361,7 @@ public:
static CastInst *CreatePointerCast(
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -370,7 +369,7 @@ public:
static CastInst *CreatePointerCast(
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -379,7 +378,7 @@ public:
Value *S, ///< The pointer value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
bool isSigned, ///< Whether to regard S as signed or not
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -388,7 +387,7 @@ public:
Value *S, ///< The integer value to be casted (operand 0)
const Type *Ty, ///< The integer type to which operand is casted
bool isSigned, ///< Whether to regard S as signed or not
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -396,7 +395,7 @@ public:
static CastInst *CreateFPCast(
Value *S, ///< The floating point value to be casted
const Type *Ty, ///< The floating point type to cast to
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -404,7 +403,7 @@ public:
static CastInst *CreateFPCast(
Value *S, ///< The floating point value to be casted
const Type *Ty, ///< The floating point type to cast to
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -412,7 +411,7 @@ public:
static CastInst *CreateTruncOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which cast should be made
- const std::string &Name = "", ///< Name for the instruction
+ const Twine &Name = "", ///< Name for the instruction
Instruction *InsertBefore = 0 ///< Place to insert the instruction
);
@@ -420,7 +419,7 @@ public:
static CastInst *CreateTruncOrBitCast(
Value *S, ///< The value to be casted (operand 0)
const Type *Ty, ///< The type to which operand is casted
- const std::string &Name, ///< The name for the instruction
+ const Twine &Name, ///< The name for the instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -520,11 +519,11 @@ class CmpInst: public Instruction {
CmpInst(); // do not implement
protected:
CmpInst(const Type *ty, Instruction::OtherOps op, unsigned short pred,
- Value *LHS, Value *RHS, const std::string &Name = "",
+ Value *LHS, Value *RHS, const Twine &Name = "",
Instruction *InsertBefore = 0);
CmpInst(const Type *ty, Instruction::OtherOps op, unsigned short pred,
- Value *LHS, Value *RHS, const std::string &Name,
+ Value *LHS, Value *RHS, const Twine &Name,
BasicBlock *InsertAtEnd);
public:
@@ -579,7 +578,7 @@ public:
/// @brief Create a CmpInst
static CmpInst *Create(LLVMContext &Context, OtherOps Op,
unsigned short predicate, Value *S1,
- Value *S2, const std::string &Name = "",
+ Value *S2, const Twine &Name = "",
Instruction *InsertBefore = 0);
/// Construct a compare instruction, given the opcode, the predicate and the
@@ -587,8 +586,7 @@ public:
/// the BasicBlock specified.
/// @brief Create a CmpInst
static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1,
- Value *S2, const std::string &Name,
- BasicBlock *InsertAtEnd);
+ Value *S2, const Twine &Name, BasicBlock *InsertAtEnd);
/// @brief Get the opcode casted to the right type
OtherOps getOpcode() const {
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 1afcc5f..2b53fac 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -41,10 +41,10 @@ class LLVMContext;
class AllocationInst : public UnaryInstruction {
protected:
AllocationInst(const Type *Ty, Value *ArraySize,
- unsigned iTy, unsigned Align, const std::string &Name = "",
+ unsigned iTy, unsigned Align, const Twine &Name = "",
Instruction *InsertBefore = 0);
AllocationInst(const Type *Ty, Value *ArraySize,
- unsigned iTy, unsigned Align, const std::string &Name,
+ unsigned iTy, unsigned Align, const Twine &Name,
BasicBlock *InsertAtEnd);
public:
// Out of line virtual method, so the vtable, etc. has a home.
@@ -102,28 +102,28 @@ class MallocInst : public AllocationInst {
MallocInst(const MallocInst &MI);
public:
explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Malloc,
0, NameStr, InsertBefore) {}
MallocInst(const Type *Ty, Value *ArraySize,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {}
- MallocInst(const Type *Ty, const std::string &NameStr,
+ MallocInst(const Type *Ty, const Twine &NameStr,
Instruction *InsertBefore = 0)
: AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {}
- MallocInst(const Type *Ty, const std::string &NameStr,
+ MallocInst(const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr,
+ unsigned Align, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Malloc,
Align, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr = "",
+ unsigned Align, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize,
Malloc, Align, NameStr, InsertBefore) {}
@@ -152,29 +152,29 @@ class AllocaInst : public AllocationInst {
public:
explicit AllocaInst(const Type *Ty,
Value *ArraySize = 0,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Alloca,
0, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty,
- Value *ArraySize, const std::string &NameStr,
+ Value *ArraySize, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {}
- AllocaInst(const Type *Ty, const std::string &NameStr,
+ AllocaInst(const Type *Ty, const Twine &NameStr,
Instruction *InsertBefore = 0)
: AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertBefore) {}
- AllocaInst(const Type *Ty, const std::string &NameStr,
+ AllocaInst(const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {}
AllocaInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr = "",
+ unsigned Align, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Alloca,
Align, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty, Value *ArraySize,
- unsigned Align, const std::string &NameStr,
+ unsigned Align, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Alloca,
Align, NameStr, InsertAtEnd) {}
@@ -246,15 +246,15 @@ class LoadInst : public UnaryInstruction {
}
void AssertOK();
public:
- LoadInst(Value *Ptr, const std::string &NameStr, Instruction *InsertBefore);
- LoadInst(Value *Ptr, const std::string &NameStr, BasicBlock *InsertAtEnd);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile = false,
+ LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore);
+ LoadInst(Value *Ptr, const Twine &NameStr, BasicBlock *InsertAtEnd);
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile = false,
Instruction *InsertBefore = 0);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
unsigned Align, Instruction *InsertBefore = 0);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
BasicBlock *InsertAtEnd);
- LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
+ LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
unsigned Align, BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore);
@@ -399,12 +399,12 @@ static inline const Type *checkType(const Type *Ty) {
class GetElementPtrInst : public Instruction {
GetElementPtrInst(const GetElementPtrInst &GEPI);
void init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
- const std::string &NameStr);
- void init(Value *Ptr, Value *Idx, const std::string &NameStr);
+ const Twine &NameStr);
+ void init(Value *Ptr, Value *Idx, const Twine &NameStr);
template<typename InputIterator>
void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
@@ -451,25 +451,25 @@ class GetElementPtrInst : public Instruction {
inline GetElementPtrInst(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline GetElementPtrInst(Value *Ptr,
InputIterator IdxBegin, InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
/// Constructors - These two constructors are convenience methods because one
/// and two index getelementptr instructions are so common.
- GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &NameStr = "",
+ GetElementPtrInst(Value *Ptr, Value *Idx, const Twine &NameStr = "",
Instruction *InsertBefore = 0);
GetElementPtrInst(Value *Ptr, Value *Idx,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static GetElementPtrInst *Create(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
typename std::iterator_traits<InputIterator>::difference_type Values =
1 + std::distance(IdxBegin, IdxEnd);
@@ -479,7 +479,7 @@ public:
template<typename InputIterator>
static GetElementPtrInst *Create(Value *Ptr,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
typename std::iterator_traits<InputIterator>::difference_type Values =
1 + std::distance(IdxBegin, IdxEnd);
@@ -490,12 +490,12 @@ public:
/// Constructors - These two creators are convenience methods because one
/// index getelementptr instructions are so common.
static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertBefore);
}
static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
}
@@ -592,7 +592,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore)
: Instruction(PointerType::get(checkType(
getIndexedType(Ptr->getType(),
@@ -610,7 +610,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(PointerType::get(checkType(
getIndexedType(Ptr->getType(),
@@ -644,7 +644,7 @@ public:
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr,
InsertBefore) {
@@ -665,7 +665,7 @@ public:
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) {
@@ -686,7 +686,7 @@ public:
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(Context.makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
@@ -819,7 +819,7 @@ public:
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
InsertBefore) {
@@ -838,7 +838,7 @@ public:
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) {
@@ -857,7 +857,7 @@ public:
Predicate pred, ///< The predicate to use for the comparison
Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression
- const std::string &NameStr = "" ///< Name of the instruction
+ const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(Context.makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
@@ -932,7 +932,7 @@ class CallInst : public Instruction {
template<typename InputIterator>
void init(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
@@ -951,7 +951,7 @@ class CallInst : public Instruction {
/// @brief Construct a CallInst from a range of arguments
template<typename InputIterator>
CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, Instruction *InsertBefore);
+ const Twine &NameStr, Instruction *InsertBefore);
/// Construct a CallInst given a range of arguments. InputIterator
/// must be a random-access iterator pointing to contiguous storage
@@ -961,20 +961,20 @@ class CallInst : public Instruction {
/// @brief Construct a CallInst from a range of arguments
template<typename InputIterator>
inline CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
- CallInst(Value *F, Value *Actual, const std::string& NameStr,
+ CallInst(Value *F, Value *Actual, const Twine &NameStr,
Instruction *InsertBefore);
- CallInst(Value *F, Value *Actual, const std::string& NameStr,
+ CallInst(Value *F, Value *Actual, const Twine &NameStr,
BasicBlock *InsertAtEnd);
- explicit CallInst(Value *F, const std::string &NameStr,
+ explicit CallInst(Value *F, const Twine &NameStr,
Instruction *InsertBefore);
- CallInst(Value *F, const std::string &NameStr, BasicBlock *InsertAtEnd);
+ CallInst(Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static CallInst *Create(Value *Func,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new((unsigned)(ArgEnd - ArgBegin + 1))
CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertBefore);
@@ -982,24 +982,24 @@ public:
template<typename InputIterator>
static CallInst *Create(Value *Func,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd) {
+ const Twine &NameStr, BasicBlock *InsertAtEnd) {
return new((unsigned)(ArgEnd - ArgBegin + 1))
CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertAtEnd);
}
static CallInst *Create(Value *F, Value *Actual,
- const std::string& NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(2) CallInst(F, Actual, NameStr, InsertBefore);
}
- static CallInst *Create(Value *F, Value *Actual, const std::string& NameStr,
+ static CallInst *Create(Value *F, Value *Actual, const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(2) CallInst(F, Actual, NameStr, InsertAtEnd);
}
- static CallInst *Create(Value *F, const std::string &NameStr = "",
+ static CallInst *Create(Value *F, const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(1) CallInst(F, NameStr, InsertBefore);
}
- static CallInst *Create(Value *F, const std::string &NameStr,
+ static CallInst *Create(Value *F, const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(1) CallInst(F, NameStr, InsertAtEnd);
}
@@ -1121,7 +1121,7 @@ struct OperandTraits<CallInst> : VariadicOperandTraits<1> {
template<typename InputIterator>
CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Call,
@@ -1133,7 +1133,7 @@ CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
template<typename InputIterator>
CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr, Instruction *InsertBefore)
+ const Twine &NameStr, Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Call,
@@ -1163,14 +1163,14 @@ class SelectInst : public Instruction {
: Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) {
init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>());
}
- SelectInst(Value *C, Value *S1, Value *S2, const std::string &NameStr,
+ SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
Instruction *InsertBefore)
: Instruction(S1->getType(), Instruction::Select,
&Op<0>(), 3, InsertBefore) {
init(C, S1, S2);
setName(NameStr);
}
- SelectInst(Value *C, Value *S1, Value *S2, const std::string &NameStr,
+ SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(S1->getType(), Instruction::Select,
&Op<0>(), 3, InsertAtEnd) {
@@ -1179,12 +1179,12 @@ class SelectInst : public Instruction {
}
public:
static SelectInst *Create(Value *C, Value *S1, Value *S2,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(3) SelectInst(C, S1, S2, NameStr, InsertBefore);
}
static SelectInst *Create(Value *C, Value *S1, Value *S2,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(3) SelectInst(C, S1, S2, NameStr, InsertAtEnd);
}
@@ -1233,12 +1233,12 @@ class VAArgInst : public UnaryInstruction {
VAArgInst(const VAArgInst &VAA)
: UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
public:
- VAArgInst(Value *List, const Type *Ty, const std::string &NameStr = "",
+ VAArgInst(Value *List, const Type *Ty, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: UnaryInstruction(Ty, VAArg, List, InsertBefore) {
setName(NameStr);
}
- VAArgInst(Value *List, const Type *Ty, const std::string &NameStr,
+ VAArgInst(Value *List, const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
setName(NameStr);
@@ -1270,9 +1270,9 @@ class ExtractElementInst : public Instruction {
Op<1>() = EE.Op<1>();
}
- ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr = "",
+ ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "",
Instruction *InsertBefore = 0);
- ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr,
+ ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr,
BasicBlock *InsertAtEnd);
public:
static ExtractElementInst *Create(const ExtractElementInst &EE) {
@@ -1280,12 +1280,12 @@ public:
}
static ExtractElementInst *Create(Value *Vec, Value *Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertBefore);
}
static ExtractElementInst *Create(Value *Vec, Value *Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertAtEnd);
}
@@ -1325,21 +1325,21 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementInst, Value)
class InsertElementInst : public Instruction {
InsertElementInst(const InsertElementInst &IE);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
static InsertElementInst *Create(const InsertElementInst &IE) {
return new(IE.getNumOperands()) InsertElementInst(IE);
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
}
@@ -1391,10 +1391,10 @@ public:
return User::operator new(s, 3);
}
ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefor = 0);
ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
/// isValidOperands - Return true if a shufflevector instruction can be
/// formed with the specified operands.
@@ -1445,12 +1445,12 @@ class ExtractValueInst : public UnaryInstruction {
ExtractValueInst(const ExtractValueInst &EVI);
void init(const unsigned *Idx, unsigned NumIdx,
- const std::string &NameStr);
- void init(unsigned Idx, const std::string &NameStr);
+ const Twine &NameStr);
+ void init(unsigned Idx, const Twine &NameStr);
template<typename InputIterator>
void init(InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
@@ -1500,12 +1500,12 @@ class ExtractValueInst : public UnaryInstruction {
template<typename InputIterator>
inline ExtractValueInst(Value *Agg, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline ExtractValueInst(Value *Agg,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
// allocate space for exactly one operand
void *operator new(size_t s) {
@@ -1516,7 +1516,7 @@ public:
template<typename InputIterator>
static ExtractValueInst *Create(Value *Agg, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new
ExtractValueInst(Agg, IdxBegin, IdxEnd, NameStr, InsertBefore);
@@ -1524,7 +1524,7 @@ public:
template<typename InputIterator>
static ExtractValueInst *Create(Value *Agg,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new ExtractValueInst(Agg, IdxBegin, IdxEnd, NameStr, InsertAtEnd);
}
@@ -1533,13 +1533,13 @@ public:
/// index extractvalue instructions are much more common than those with
/// more than one.
static ExtractValueInst *Create(Value *Agg, unsigned Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
unsigned Idxs[1] = { Idx };
return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertBefore);
}
static ExtractValueInst *Create(Value *Agg, unsigned Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
unsigned Idxs[1] = { Idx };
return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertAtEnd);
@@ -1599,7 +1599,7 @@ template<typename InputIterator>
ExtractValueInst::ExtractValueInst(Value *Agg,
InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore)
: UnaryInstruction(checkType(getIndexedType(Agg->getType(),
IdxBegin, IdxEnd)),
@@ -1611,7 +1611,7 @@ template<typename InputIterator>
ExtractValueInst::ExtractValueInst(Value *Agg,
InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd)
: UnaryInstruction(checkType(getIndexedType(Agg->getType(),
IdxBegin, IdxEnd)),
@@ -1634,13 +1634,13 @@ class InsertValueInst : public Instruction {
void *operator new(size_t, unsigned); // Do not implement
InsertValueInst(const InsertValueInst &IVI);
void init(Value *Agg, Value *Val, const unsigned *Idx, unsigned NumIdx,
- const std::string &NameStr);
- void init(Value *Agg, Value *Val, unsigned Idx, const std::string &NameStr);
+ const Twine &NameStr);
+ void init(Value *Agg, Value *Val, unsigned Idx, const Twine &NameStr);
template<typename InputIterator>
void init(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
@@ -1664,20 +1664,20 @@ class InsertValueInst : public Instruction {
template<typename InputIterator>
inline InsertValueInst(Value *Agg, Value *Val, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline InsertValueInst(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
/// Constructors - These two constructors are convenience methods because one
/// and two index insertvalue instructions are so common.
InsertValueInst(Value *Agg, Value *Val,
- unsigned Idx, const std::string &NameStr = "",
+ unsigned Idx, const Twine &NameStr = "",
Instruction *InsertBefore = 0);
InsertValueInst(Value *Agg, Value *Val, unsigned Idx,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
@@ -1687,7 +1687,7 @@ public:
template<typename InputIterator>
static InsertValueInst *Create(Value *Agg, Value *Val, InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new InsertValueInst(Agg, Val, IdxBegin, IdxEnd,
NameStr, InsertBefore);
@@ -1695,7 +1695,7 @@ public:
template<typename InputIterator>
static InsertValueInst *Create(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new InsertValueInst(Agg, Val, IdxBegin, IdxEnd,
NameStr, InsertAtEnd);
@@ -1705,12 +1705,12 @@ public:
/// index insertvalue instructions are much more common than those with
/// more than one.
static InsertValueInst *Create(Value *Agg, Value *Val, unsigned Idx,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new InsertValueInst(Agg, Val, Idx, NameStr, InsertBefore);
}
static InsertValueInst *Create(Value *Agg, Value *Val, unsigned Idx,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new InsertValueInst(Agg, Val, Idx, NameStr, InsertAtEnd);
}
@@ -1771,7 +1771,7 @@ InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
Instruction *InsertBefore)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
@@ -1784,7 +1784,7 @@ InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
InputIterator IdxBegin,
InputIterator IdxEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
@@ -1813,24 +1813,24 @@ class PHINode : public Instruction {
void *operator new(size_t s) {
return User::operator new(s, 0);
}
- explicit PHINode(const Type *Ty, const std::string &NameStr = "",
+ explicit PHINode(const Type *Ty, const Twine &NameStr = "",
Instruction *InsertBefore = 0)
: Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
ReservedSpace(0) {
setName(NameStr);
}
- PHINode(const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd)
+ PHINode(const Type *Ty, const Twine &NameStr, BasicBlock *InsertAtEnd)
: Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd),
ReservedSpace(0) {
setName(NameStr);
}
public:
- static PHINode *Create(const Type *Ty, const std::string &NameStr = "",
+ static PHINode *Create(const Type *Ty, const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
return new PHINode(Ty, NameStr, InsertBefore);
}
- static PHINode *Create(const Type *Ty, const std::string &NameStr,
+ static PHINode *Create(const Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd) {
return new PHINode(Ty, NameStr, InsertAtEnd);
}
@@ -2311,7 +2311,7 @@ class InvokeInst : public TerminatorInst {
template<typename InputIterator>
void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
// This argument ensures that we have an iterator we can
// do arithmetic on in constant time
std::random_access_iterator_tag) {
@@ -2333,7 +2333,7 @@ class InvokeInst : public TerminatorInst {
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
- const std::string &NameStr, Instruction *InsertBefore);
+ const Twine &NameStr, Instruction *InsertBefore);
/// Construct an InvokeInst given a range of arguments.
/// InputIterator must be a random-access iterator pointing to
@@ -2346,13 +2346,13 @@ class InvokeInst : public TerminatorInst {
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
- const std::string &NameStr, BasicBlock *InsertAtEnd);
+ const Twine &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static InvokeInst *Create(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr = "",
+ const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
unsigned Values(ArgEnd - ArgBegin + 3);
return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
@@ -2362,7 +2362,7 @@ public:
static InvokeInst *Create(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &NameStr,
+ const Twine &NameStr,
BasicBlock *InsertAtEnd) {
unsigned Values(ArgEnd - ArgBegin + 3);
return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
@@ -2513,7 +2513,7 @@ InvokeInst::InvokeInst(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
- const std::string &NameStr, Instruction *InsertBefore)
+ const Twine &NameStr, Instruction *InsertBefore)
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Invoke,
@@ -2527,7 +2527,7 @@ InvokeInst::InvokeInst(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
- const std::string &NameStr, BasicBlock *InsertAtEnd)
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Invoke,
@@ -2627,7 +2627,7 @@ public:
TruncInst(
Value *S, ///< The value to be truncated
const Type *Ty, ///< The (smaller) type to truncate to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2635,7 +2635,7 @@ public:
TruncInst(
Value *S, ///< The value to be truncated
const Type *Ty, ///< The (smaller) type to truncate to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -2667,7 +2667,7 @@ public:
ZExtInst(
Value *S, ///< The value to be zero extended
const Type *Ty, ///< The type to zero extend to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2675,7 +2675,7 @@ public:
ZExtInst(
Value *S, ///< The value to be zero extended
const Type *Ty, ///< The type to zero extend to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -2707,7 +2707,7 @@ public:
SExtInst(
Value *S, ///< The value to be sign extended
const Type *Ty, ///< The type to sign extend to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2715,7 +2715,7 @@ public:
SExtInst(
Value *S, ///< The value to be sign extended
const Type *Ty, ///< The type to sign extend to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -2746,7 +2746,7 @@ public:
FPTruncInst(
Value *S, ///< The value to be truncated
const Type *Ty, ///< The type to truncate to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2754,7 +2754,7 @@ public:
FPTruncInst(
Value *S, ///< The value to be truncated
const Type *Ty, ///< The type to truncate to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -2785,7 +2785,7 @@ public:
FPExtInst(
Value *S, ///< The value to be extended
const Type *Ty, ///< The type to extend to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2793,7 +2793,7 @@ public:
FPExtInst(
Value *S, ///< The value to be extended
const Type *Ty, ///< The type to extend to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -2824,7 +2824,7 @@ public:
UIToFPInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2832,7 +2832,7 @@ public:
UIToFPInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -2863,7 +2863,7 @@ public:
SIToFPInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2871,7 +2871,7 @@ public:
SIToFPInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -2902,7 +2902,7 @@ public:
FPToUIInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2910,7 +2910,7 @@ public:
FPToUIInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< Where to insert the new instruction
);
@@ -2941,7 +2941,7 @@ public:
FPToSIInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2949,7 +2949,7 @@ public:
FPToSIInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -2980,7 +2980,7 @@ public:
IntToPtrInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -2988,7 +2988,7 @@ public:
IntToPtrInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -3019,7 +3019,7 @@ public:
PtrToIntInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -3027,7 +3027,7 @@ public:
PtrToIntInst(
Value *S, ///< The value to be converted
const Type *Ty, ///< The type to convert to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
@@ -3058,7 +3058,7 @@ public:
BitCastInst(
Value *S, ///< The value to be casted
const Type *Ty, ///< The type to casted to
- const std::string &NameStr = "", ///< A name for the new instruction
+ const Twine &NameStr = "", ///< A name for the new instruction
Instruction *InsertBefore = 0 ///< Where to insert the new instruction
);
@@ -3066,7 +3066,7 @@ public:
BitCastInst(
Value *S, ///< The value to be casted
const Type *Ty, ///< The type to casted to
- const std::string &NameStr, ///< A name for the new instruction
+ const Twine &NameStr, ///< A name for the new instruction
BasicBlock *InsertAtEnd ///< The block to insert the instruction into
);
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index 720cc19..1f5bd7f 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -17,6 +17,7 @@
#include "llvm/AbstractTypeUser.h"
#include "llvm/Use.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
#include "llvm/Support/Casting.h"
#include <iosfwd>
#include <string>
@@ -128,11 +129,11 @@ public:
/// getName()/getNameStr() - Return the name of the specified value,
/// *constructing a string* to hold it. Because these are guaranteed to
/// construct a string, they are very expensive and should be avoided.
- std::string getName() const { return getNameStr(); }
+ StringRef getName() const { return StringRef(getNameStart(), getNameLen()); }
std::string getNameStr() const;
StringRef getNameRef() const;
- void setName(const std::string &name);
+ void setName(const Twine &Name);
void setName(const char *Name, unsigned NameLen);
void setName(const char *Name); // Takes a null-terminated string.
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 95f0ece..8831d35 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -34,8 +34,8 @@ using namespace llvm;
// Error - Simple wrapper function to conditionally assign to E and return true.
// This just makes error return conditions a little bit simpler...
-static inline bool Error(std::string *E, const std::string &Message) {
- if (E) *E = Message;
+static inline bool Error(std::string *E, const Twine &Message) {
+ if (E) *E = Message.str();
return true;
}
diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp
index 4588a7f..4596361 100644
--- a/lib/Transforms/Scalar/GVNPRE.cpp
+++ b/lib/Transforms/Scalar/GVNPRE.cpp
@@ -869,7 +869,8 @@ Value* GVNPRE::phi_translate(Value* V, BasicBlock* pred, BasicBlock* succ) {
newOp1, newOp2,
C->getName()+".expr");
else if (ExtractElementInst* E = dyn_cast<ExtractElementInst>(U))
- newVal = ExtractElementInst::Create(newOp1, newOp2, E->getName()+".expr");
+ newVal = ExtractElementInst::Create(newOp1, newOp2,
+ E->getName()+".expr");
uint32_t v = VN.lookup_or_add(newVal);
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 3376e86..a182943 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -1443,7 +1443,8 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, uint64_t Offset) {
if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
assert(SI->getOperand(0) != Ptr && "Consistency error!");
- Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str());
+ // FIXME: Remove once builder has Twine API.
+ Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str());
Value *New = ConvertScalar_InsertValue(SI->getOperand(0), Old, Offset,
Builder);
Builder.CreateStore(New, NewAI);
@@ -1467,7 +1468,8 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, uint64_t Offset) {
for (unsigned i = 1; i != NumBytes; ++i)
APVal |= APVal << 8;
- Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str());
+ // FIXME: Remove once builder has Twine API.
+ Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str());
Value *New = ConvertScalar_InsertValue(
ConstantInt::get(User->getContext(), APVal),
Old, Offset, Builder);
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index df27811..d0fa02c 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -39,7 +39,7 @@ LLVMContext &BasicBlock::getContext() const {
template class SymbolTableListTraits<Instruction, BasicBlock>;
-BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
+BasicBlock::BasicBlock(const Twine &Name, Function *NewParent,
BasicBlock *InsertBefore)
: Value(Type::LabelTy, Value::BasicBlockVal), Parent(0) {
@@ -240,7 +240,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
/// cause a degenerate basic block to be formed, having a terminator inside of
/// the basic block).
///
-BasicBlock *BasicBlock::splitBasicBlock(iterator I, const std::string &BBName) {
+BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
assert(I != InstList.end() &&
"Trying to get me to create degenerate basic block!");
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 4923842..cdf2dd0 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -36,7 +36,7 @@ template class SymbolTableListTraits<BasicBlock, Function>;
// Argument Implementation
//===----------------------------------------------------------------------===//
-Argument::Argument(const Type *Ty, const std::string &Name, Function *Par)
+Argument::Argument(const Type *Ty, const Twine &Name, Function *Par)
: Value(Ty, Value::ArgumentVal) {
Parent = 0;
@@ -144,7 +144,7 @@ void Function::eraseFromParent() {
//===----------------------------------------------------------------------===//
Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
- const std::string &name, Module *ParentModule)
+ const Twine &name, Module *ParentModule)
: GlobalValue(PointerType::getUnqual(Ty),
Value::FunctionVal, 0, 0, Linkage, name) {
assert(FunctionType::isValidReturnType(getReturnType()) &&
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index bb750be..aa4c30a 100644
--- a/lib/VMCore/Globals.cpp
+++ b/lib/VMCore/Globals.cpp
@@ -96,7 +96,7 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,
bool constant, LinkageTypes Link,
- Constant *InitVal, const std::string &Name,
+ Constant *InitVal, const Twine &Name,
bool ThreadLocal, unsigned AddressSpace)
: GlobalValue(Context.getPointerType(Ty, AddressSpace),
Value::GlobalVariableVal,
@@ -114,7 +114,7 @@ GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,
GlobalVariable::GlobalVariable(Module &M, const Type *Ty, bool constant,
LinkageTypes Link, Constant *InitVal,
- const std::string &Name,
+ const Twine &Name,
GlobalVariable *Before, bool ThreadLocal,
unsigned AddressSpace)
: GlobalValue(M.getContext().getPointerType(Ty, AddressSpace),
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index e1583c9..20de3fe 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -351,7 +351,7 @@ void CallInst::init(Value *Func) {
assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
}
-CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
+CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,
Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
@@ -362,7 +362,7 @@ CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
setName(Name);
}
-CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
+CallInst::CallInst(Value *Func, Value* Actual, const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
@@ -372,7 +372,7 @@ CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
init(Func, Actual);
setName(Name);
}
-CallInst::CallInst(Value *Func, const std::string &Name,
+CallInst::CallInst(Value *Func, const Twine &Name,
Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
@@ -383,7 +383,7 @@ CallInst::CallInst(Value *Func, const std::string &Name,
setName(Name);
}
-CallInst::CallInst(Value *Func, const std::string &Name,
+CallInst::CallInst(Value *Func, const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
@@ -714,7 +714,7 @@ static Value *getAISize(LLVMContext &Context, Value *Amt) {
}
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
- unsigned Align, const std::string &Name,
+ unsigned Align, const Twine &Name,
Instruction *InsertBefore)
: UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,
getAISize(Ty->getContext(), ArraySize), InsertBefore) {
@@ -724,7 +724,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
}
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
- unsigned Align, const std::string &Name,
+ unsigned Align, const Twine &Name,
BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy,
getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
@@ -806,7 +806,7 @@ void LoadInst::AssertOK() {
"Ptr must have pointer type.");
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
setVolatile(false);
@@ -815,7 +815,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, BasicBlock *InsertAE)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
setVolatile(false);
@@ -824,7 +824,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
@@ -834,7 +834,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
unsigned Align, Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
@@ -844,7 +844,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
unsigned Align, BasicBlock *InsertAE)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
@@ -854,7 +854,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
+LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
BasicBlock *InsertAE)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
@@ -1013,7 +1013,7 @@ static unsigned retrieveAddrSpace(const Value *Val) {
}
void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
- const std::string &Name) {
+ const Twine &Name) {
assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
Use *OL = OperandList;
OL[0] = Ptr;
@@ -1024,7 +1024,7 @@ void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
setName(Name);
}
-void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) {
+void GetElementPtrInst::init(Value *Ptr, Value *Idx, const Twine &Name) {
assert(NumOperands == 2 && "NumOperands not initialized?");
Use *OL = OperandList;
OL[0] = Ptr;
@@ -1045,7 +1045,7 @@ GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)
}
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
- const std::string &Name, Instruction *InBe)
+ const Twine &Name, Instruction *InBe)
: Instruction(Ptr->getType()->getContext().getPointerType(
checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)),
GetElementPtr,
@@ -1055,7 +1055,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
}
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
- const std::string &Name, BasicBlock *IAE)
+ const Twine &Name, BasicBlock *IAE)
: Instruction(Ptr->getType()->getContext().getPointerType(
checkType(getIndexedType(Ptr->getType(),Idx)),
retrieveAddrSpace(Ptr)),
@@ -1164,7 +1164,7 @@ bool GetElementPtrInst::hasAllConstantIndices() const {
//===----------------------------------------------------------------------===//
ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBef)
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
ExtractElement,
@@ -1178,7 +1178,7 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
}
ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAE)
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
ExtractElement,
@@ -1212,7 +1212,7 @@ InsertElementInst::InsertElementInst(const InsertElementInst &IE)
Op<2>() = IE.Op<2>();
}
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBef)
: Instruction(Vec->getType(), InsertElement,
OperandTraits<InsertElementInst>::op_begin(this),
@@ -1226,7 +1226,7 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
}
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAE)
: Instruction(Vec->getType(), InsertElement,
OperandTraits<InsertElementInst>::op_begin(this),
@@ -1268,7 +1268,7 @@ ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV)
}
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore)
: Instruction(V1->getType()->getContext().getVectorType(
cast<VectorType>(V1->getType())->getElementType(),
@@ -1286,7 +1286,7 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
}
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(V1->getType(), ShuffleVector,
OperandTraits<ShuffleVectorInst>::op_begin(this),
@@ -1333,7 +1333,7 @@ int ShuffleVectorInst::getMaskValue(unsigned i) const {
//===----------------------------------------------------------------------===//
void InsertValueInst::init(Value *Agg, Value *Val, const unsigned *Idx,
- unsigned NumIdx, const std::string &Name) {
+ unsigned NumIdx, const Twine &Name) {
assert(NumOperands == 2 && "NumOperands not initialized?");
Op<0>() = Agg;
Op<1>() = Val;
@@ -1343,7 +1343,7 @@ void InsertValueInst::init(Value *Agg, Value *Val, const unsigned *Idx,
}
void InsertValueInst::init(Value *Agg, Value *Val, unsigned Idx,
- const std::string &Name) {
+ const Twine &Name) {
assert(NumOperands == 2 && "NumOperands not initialized?");
Op<0>() = Agg;
Op<1>() = Val;
@@ -1363,7 +1363,7 @@ InsertValueInst::InsertValueInst(const InsertValueInst &IVI)
InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
unsigned Idx,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
@@ -1374,7 +1374,7 @@ InsertValueInst::InsertValueInst(Value *Agg,
InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
unsigned Idx,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
@@ -1387,14 +1387,14 @@ InsertValueInst::InsertValueInst(Value *Agg,
//===----------------------------------------------------------------------===//
void ExtractValueInst::init(const unsigned *Idx, unsigned NumIdx,
- const std::string &Name) {
+ const Twine &Name) {
assert(NumOperands == 1 && "NumOperands not initialized?");
Indices.insert(Indices.end(), Idx, Idx + NumIdx);
setName(Name);
}
-void ExtractValueInst::init(unsigned Idx, const std::string &Name) {
+void ExtractValueInst::init(unsigned Idx, const Twine &Name) {
assert(NumOperands == 1 && "NumOperands not initialized?");
Indices.push_back(Idx);
@@ -1457,7 +1457,7 @@ static BinaryOperator::BinaryOps AdjustIType(BinaryOperator::BinaryOps iType,
}
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
- const Type *Ty, const std::string &Name,
+ const Type *Ty, const Twine &Name,
Instruction *InsertBefore)
: Instruction(Ty, AdjustIType(iType, Ty),
OperandTraits<BinaryOperator>::op_begin(this),
@@ -1470,7 +1470,7 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
}
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
- const Type *Ty, const std::string &Name,
+ const Type *Ty, const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(Ty, AdjustIType(iType, Ty),
OperandTraits<BinaryOperator>::op_begin(this),
@@ -1559,7 +1559,7 @@ void BinaryOperator::init(BinaryOps iType) {
}
BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
assert(S1->getType() == S2->getType() &&
"Cannot create binary operator with two operands of differing type!");
@@ -1567,7 +1567,7 @@ BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
}
BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
BinaryOperator *Res = Create(Op, S1, S2, Name);
InsertAtEnd->getInstList().push_back(Res);
@@ -1575,7 +1575,7 @@ BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
}
BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
Instruction *InsertBefore) {
Value *zero = Context.getZeroValueForNegation(Op->getType());
return new BinaryOperator(Instruction::Sub,
@@ -1584,7 +1584,7 @@ BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
}
BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd) {
Value *zero = Context.getZeroValueForNegation(Op->getType());
return new BinaryOperator(Instruction::Sub,
@@ -1593,7 +1593,7 @@ BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
}
BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
Instruction *InsertBefore) {
Value *zero = Context.getZeroValueForNegation(Op->getType());
return new BinaryOperator(Instruction::FSub,
@@ -1602,7 +1602,7 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
}
BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd) {
Value *zero = Context.getZeroValueForNegation(Op->getType());
return new BinaryOperator(Instruction::FSub,
@@ -1611,7 +1611,7 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
}
BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
Instruction *InsertBefore) {
Constant *C;
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
@@ -1627,7 +1627,7 @@ BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
}
BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
- Value *Op, const std::string &Name,
+ Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd) {
Constant *AllOnes;
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
@@ -1952,7 +1952,7 @@ unsigned CastInst::isEliminableCastPair(
}
CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
- const std::string &Name, Instruction *InsertBefore) {
+ const Twine &Name, Instruction *InsertBefore) {
// Construct and return the appropriate CastInst subclass
switch (op) {
case Trunc: return new TruncInst (S, Ty, Name, InsertBefore);
@@ -1974,7 +1974,7 @@ CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
}
CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
- const std::string &Name, BasicBlock *InsertAtEnd) {
+ const Twine &Name, BasicBlock *InsertAtEnd) {
// Construct and return the appropriate CastInst subclass
switch (op) {
case Trunc: return new TruncInst (S, Ty, Name, InsertAtEnd);
@@ -1996,7 +1996,7 @@ CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
}
CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
@@ -2004,7 +2004,7 @@ CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,
}
CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
@@ -2012,7 +2012,7 @@ CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty,
}
CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
@@ -2020,7 +2020,7 @@ CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,
}
CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
@@ -2028,7 +2028,7 @@ CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty,
}
CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
@@ -2036,7 +2036,7 @@ CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
}
CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
@@ -2044,7 +2044,7 @@ CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
}
CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
assert(isa<PointerType>(S->getType()) && "Invalid cast");
assert((Ty->isInteger() || isa<PointerType>(Ty)) &&
@@ -2057,7 +2057,7 @@ CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
/// @brief Create a BitCast or a PtrToInt cast instruction
CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
assert(isa<PointerType>(S->getType()) && "Invalid cast");
assert((Ty->isInteger() || isa<PointerType>(Ty)) &&
@@ -2069,7 +2069,7 @@ CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
}
CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
- bool isSigned, const std::string &Name,
+ bool isSigned, const Twine &Name,
Instruction *InsertBefore) {
assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
unsigned SrcBits = C->getType()->getScalarSizeInBits();
@@ -2082,7 +2082,7 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
}
CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
- bool isSigned, const std::string &Name,
+ bool isSigned, const Twine &Name,
BasicBlock *InsertAtEnd) {
assert(C->getType()->isIntOrIntVector() && Ty->isIntOrIntVector() &&
"Invalid cast");
@@ -2096,7 +2096,7 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
}
CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
Instruction *InsertBefore) {
assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&
"Invalid cast");
@@ -2109,7 +2109,7 @@ CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
}
CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
- const std::string &Name,
+ const Twine &Name,
BasicBlock *InsertAtEnd) {
assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&
"Invalid cast");
@@ -2353,144 +2353,144 @@ CastInst::castIsValid(Instruction::CastOps op, Value *S, const Type *DstTy) {
}
TruncInst::TruncInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, Trunc, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");
}
TruncInst::TruncInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, Trunc, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal Trunc");
}
ZExtInst::ZExtInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, ZExt, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");
}
ZExtInst::ZExtInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, ZExt, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal ZExt");
}
SExtInst::SExtInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, SExt, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");
}
SExtInst::SExtInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, SExt, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SExt");
}
FPTruncInst::FPTruncInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");
}
FPTruncInst::FPTruncInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, FPTrunc, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPTrunc");
}
FPExtInst::FPExtInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, FPExt, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");
}
FPExtInst::FPExtInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, FPExt, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPExt");
}
UIToFPInst::UIToFPInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, UIToFP, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");
}
UIToFPInst::UIToFPInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, UIToFP, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal UIToFP");
}
SIToFPInst::SIToFPInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, SIToFP, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");
}
SIToFPInst::SIToFPInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, SIToFP, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal SIToFP");
}
FPToUIInst::FPToUIInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, FPToUI, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");
}
FPToUIInst::FPToUIInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, FPToUI, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToUI");
}
FPToSIInst::FPToSIInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, FPToSI, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");
}
FPToSIInst::FPToSIInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, FPToSI, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal FPToSI");
}
PtrToIntInst::PtrToIntInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");
}
PtrToIntInst::PtrToIntInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, PtrToInt, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal PtrToInt");
}
IntToPtrInst::IntToPtrInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");
}
IntToPtrInst::IntToPtrInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, IntToPtr, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal IntToPtr");
}
BitCastInst::BitCastInst(
- Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore
+ Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore
) : CastInst(Ty, BitCast, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");
}
BitCastInst::BitCastInst(
- Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd
+ Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd
) : CastInst(Ty, BitCast, S, Name, InsertAtEnd) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal BitCast");
}
@@ -2500,7 +2500,7 @@ BitCastInst::BitCastInst(
//===----------------------------------------------------------------------===//
CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
- Value *LHS, Value *RHS, const std::string &Name,
+ Value *LHS, Value *RHS, const Twine &Name,
Instruction *InsertBefore)
: Instruction(ty, op,
OperandTraits<CmpInst>::op_begin(this),
@@ -2513,7 +2513,7 @@ CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
}
CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
- Value *LHS, Value *RHS, const std::string &Name,
+ Value *LHS, Value *RHS, const Twine &Name,
BasicBlock *InsertAtEnd)
: Instruction(ty, op,
OperandTraits<CmpInst>::op_begin(this),
@@ -2528,7 +2528,7 @@ CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
CmpInst *
CmpInst::Create(LLVMContext &Context, OtherOps Op, unsigned short predicate,
Value *S1, Value *S2,
- const std::string &Name, Instruction *InsertBefore) {
+ const Twine &Name, Instruction *InsertBefore) {
if (Op == Instruction::ICmp) {
if (InsertBefore)
return new ICmpInst(InsertBefore, CmpInst::Predicate(predicate),
@@ -2548,7 +2548,7 @@ CmpInst::Create(LLVMContext &Context, OtherOps Op, unsigned short predicate,
CmpInst *
CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2,
- const std::string &Name, BasicBlock *InsertAtEnd) {
+ const Twine &Name, BasicBlock *InsertAtEnd) {
if (Op == Instruction::ICmp) {
return new ICmpInst(*InsertAtEnd, CmpInst::Predicate(predicate),
S1, S2, Name);
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp
index 71dec84..d020c39 100644
--- a/lib/VMCore/Value.cpp
+++ b/lib/VMCore/Value.cpp
@@ -20,6 +20,7 @@
#include "llvm/Module.h"
#include "llvm/MDNode.h"
#include "llvm/ValueSymbolTable.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LeakDetector.h"
@@ -183,8 +184,10 @@ StringRef Value::getNameRef() const {
return StringRef(Name->getKeyData(), Name->getKeyLength());
}
-void Value::setName(const std::string &name) {
- setName(&name[0], name.size());
+void Value::setName(const Twine &Name) {
+ SmallString<32> NameData;
+ Name.toVector(NameData);
+ setName(NameData.begin(), NameData.size());
}
void Value::setName(const char *Name) {
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 4b15e3a..f900dca 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -304,10 +304,10 @@ namespace {
// CheckFailed - A check failed, so print out the condition and the message
// that failed. This provides a nice place to put a breakpoint if you want
// to see why something is not correct.
- void CheckFailed(const std::string &Message,
+ void CheckFailed(const Twine &Message,
const Value *V1 = 0, const Value *V2 = 0,
const Value *V3 = 0, const Value *V4 = 0) {
- msgs << Message << "\n";
+ msgs << Message.str() << "\n";
WriteValue(V1);
WriteValue(V2);
WriteValue(V3);
@@ -315,9 +315,9 @@ namespace {
Broken = true;
}
- void CheckFailed( const std::string& Message, const Value* V1,
- const Type* T2, const Value* V3 = 0 ) {
- msgs << Message << "\n";
+ void CheckFailed(const Twine &Message, const Value* V1,
+ const Type* T2, const Value* V3 = 0) {
+ msgs << Message.str() << "\n";
WriteValue(V1);
WriteType(T2);
WriteValue(V3);