s/AttrListPtr/AttributeSet/g to better label what this class is going to be in the near future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169651 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2012-12-07 23:16:57 +00:00
parent 550f0ade45
commit 99faa3b4ec
38 changed files with 214 additions and 214 deletions

View File

@ -298,14 +298,14 @@ struct AttributeWithIndex {
}; };
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// AttrListPtr Smart Pointer // AttributeSet Smart Pointer
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
class AttributeListImpl; class AttributeListImpl;
/// AttrListPtr - This class manages the ref count for the opaque /// AttributeSet - This class manages the ref count for the opaque
/// AttributeListImpl object and provides accessors for it. /// AttributeListImpl object and provides accessors for it.
class AttrListPtr { class AttributeSet {
public: public:
enum AttrIndex { enum AttrIndex {
ReturnIndex = 0U, ReturnIndex = 0U,
@ -320,28 +320,28 @@ private:
/// for the result are denoted with Idx = 0. /// for the result are denoted with Idx = 0.
Attributes getAttributes(unsigned Idx) const; Attributes getAttributes(unsigned Idx) const;
explicit AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {} explicit AttributeSet(AttributeListImpl *LI) : AttrList(LI) {}
public: public:
AttrListPtr() : AttrList(0) {} AttributeSet() : AttrList(0) {}
AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {} AttributeSet(const AttributeSet &P) : AttrList(P.AttrList) {}
const AttrListPtr &operator=(const AttrListPtr &RHS); const AttributeSet &operator=(const AttributeSet &RHS);
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Attribute List Construction and Mutation // Attribute List Construction and Mutation
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
/// get - Return a Attributes list with the specified parameters in it. /// get - Return a Attributes list with the specified parameters in it.
static AttrListPtr get(LLVMContext &C, ArrayRef<AttributeWithIndex> Attrs); static AttributeSet get(LLVMContext &C, ArrayRef<AttributeWithIndex> Attrs);
/// addAttr - Add the specified attribute at the specified index to this /// addAttr - Add the specified attribute at the specified index to this
/// attribute list. Since attribute lists are immutable, this /// attribute list. Since attribute lists are immutable, this
/// returns the new list. /// returns the new list.
AttrListPtr addAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const; AttributeSet addAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const;
/// removeAttr - Remove the specified attribute at the specified index from /// removeAttr - Remove the specified attribute at the specified index from
/// this attribute list. Since attribute lists are immutable, this /// this attribute list. Since attribute lists are immutable, this
/// returns the new list. /// returns the new list.
AttrListPtr removeAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const; AttributeSet removeAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const;
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Attribute List Accessors // Attribute List Accessors
@ -383,9 +383,9 @@ public:
Attributes &getAttributesAtIndex(unsigned i) const; Attributes &getAttributesAtIndex(unsigned i) const;
/// operator==/!= - Provide equality predicates. /// operator==/!= - Provide equality predicates.
bool operator==(const AttrListPtr &RHS) const bool operator==(const AttributeSet &RHS) const
{ return AttrList == RHS.AttrList; } { return AttrList == RHS.AttrList; }
bool operator!=(const AttrListPtr &RHS) const bool operator!=(const AttributeSet &RHS) const
{ return AttrList != RHS.AttrList; } { return AttrList != RHS.AttrList; }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//

View File

@ -85,7 +85,7 @@ private:
BasicBlockListType BasicBlocks; ///< The basic blocks BasicBlockListType BasicBlocks; ///< The basic blocks
mutable ArgumentListType ArgumentList; ///< The formal arguments mutable ArgumentListType ArgumentList; ///< The formal arguments
ValueSymbolTable *SymTab; ///< Symbol table of args/instructions ValueSymbolTable *SymTab; ///< Symbol table of args/instructions
AttrListPtr AttributeList; ///< Parameter attributes AttributeSet AttributeList; ///< Parameter attributes
// HasLazyArguments is stored in Value::SubclassData. // HasLazyArguments is stored in Value::SubclassData.
/*bool HasLazyArguments;*/ /*bool HasLazyArguments;*/
@ -162,11 +162,11 @@ public:
/// getAttributes - Return the attribute list for this Function. /// getAttributes - Return the attribute list for this Function.
/// ///
const AttrListPtr &getAttributes() const { return AttributeList; } const AttributeSet &getAttributes() const { return AttributeList; }
/// setAttributes - Set the attribute list for this Function. /// setAttributes - Set the attribute list for this Function.
/// ///
void setAttributes(const AttrListPtr &attrs) { AttributeList = attrs; } void setAttributes(const AttributeSet &attrs) { AttributeList = attrs; }
/// getFnAttributes - Return the function attributes for querying. /// getFnAttributes - Return the function attributes for querying.
/// ///
@ -178,7 +178,7 @@ public:
/// ///
void addFnAttr(Attributes::AttrVal N) { void addFnAttr(Attributes::AttrVal N) {
// Function Attributes are stored at ~0 index // Function Attributes are stored at ~0 index
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), N)); addAttribute(AttributeSet::FunctionIndex, Attributes::get(getContext(), N));
} }
/// removeFnAttr - Remove function attributes from this function. /// removeFnAttr - Remove function attributes from this function.

View File

@ -1156,7 +1156,7 @@ public:
/// hold the calling convention of the call. /// hold the calling convention of the call.
/// ///
class CallInst : public Instruction { class CallInst : public Instruction {
AttrListPtr AttributeList; ///< parameter attributes for call AttributeSet AttributeList; ///< parameter attributes for call
CallInst(const CallInst &CI); CallInst(const CallInst &CI);
void init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr); void init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr);
void init(Value *Func, const Twine &NameStr); void init(Value *Func, const Twine &NameStr);
@ -1254,11 +1254,11 @@ public:
/// getAttributes - Return the parameter attributes for this call. /// getAttributes - Return the parameter attributes for this call.
/// ///
const AttrListPtr &getAttributes() const { return AttributeList; } const AttributeSet &getAttributes() const { return AttributeList; }
/// setAttributes - Set the parameter attributes for this call. /// setAttributes - Set the parameter attributes for this call.
/// ///
void setAttributes(const AttrListPtr &Attrs) { AttributeList = Attrs; } void setAttributes(const AttributeSet &Attrs) { AttributeList = Attrs; }
/// addAttribute - adds the attribute to the list of attributes. /// addAttribute - adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attributes attr); void addAttribute(unsigned i, Attributes attr);
@ -1280,7 +1280,7 @@ public:
/// \brief Return true if the call should not be inlined. /// \brief Return true if the call should not be inlined.
bool isNoInline() const { return hasFnAttr(Attributes::NoInline); } bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
void setIsNoInline() { void setIsNoInline() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::NoInline)); Attributes::get(getContext(), Attributes::NoInline));
} }
@ -1289,7 +1289,7 @@ public:
return hasFnAttr(Attributes::ReturnsTwice); return hasFnAttr(Attributes::ReturnsTwice);
} }
void setCanReturnTwice() { void setCanReturnTwice() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::ReturnsTwice)); Attributes::get(getContext(), Attributes::ReturnsTwice));
} }
@ -1298,7 +1298,7 @@ public:
return hasFnAttr(Attributes::ReadNone); return hasFnAttr(Attributes::ReadNone);
} }
void setDoesNotAccessMemory() { void setDoesNotAccessMemory() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::ReadNone)); Attributes::get(getContext(), Attributes::ReadNone));
} }
@ -1307,21 +1307,21 @@ public:
return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly); return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
} }
void setOnlyReadsMemory() { void setOnlyReadsMemory() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::ReadOnly)); Attributes::get(getContext(), Attributes::ReadOnly));
} }
/// \brief Determine if the call cannot return. /// \brief Determine if the call cannot return.
bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); } bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
void setDoesNotReturn() { void setDoesNotReturn() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::NoReturn)); Attributes::get(getContext(), Attributes::NoReturn));
} }
/// \brief Determine if the call cannot unwind. /// \brief Determine if the call cannot unwind.
bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); } bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
void setDoesNotThrow() { void setDoesNotThrow() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::NoUnwind)); Attributes::get(getContext(), Attributes::NoUnwind));
} }
@ -2942,7 +2942,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(IndirectBrInst, Value)
/// calling convention of the call. /// calling convention of the call.
/// ///
class InvokeInst : public TerminatorInst { class InvokeInst : public TerminatorInst {
AttrListPtr AttributeList; AttributeSet AttributeList;
InvokeInst(const InvokeInst &BI); InvokeInst(const InvokeInst &BI);
void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
ArrayRef<Value *> Args, const Twine &NameStr); ArrayRef<Value *> Args, const Twine &NameStr);
@ -3003,11 +3003,11 @@ public:
/// getAttributes - Return the parameter attributes for this invoke. /// getAttributes - Return the parameter attributes for this invoke.
/// ///
const AttrListPtr &getAttributes() const { return AttributeList; } const AttributeSet &getAttributes() const { return AttributeList; }
/// setAttributes - Set the parameter attributes for this invoke. /// setAttributes - Set the parameter attributes for this invoke.
/// ///
void setAttributes(const AttrListPtr &Attrs) { AttributeList = Attrs; } void setAttributes(const AttributeSet &Attrs) { AttributeList = Attrs; }
/// addAttribute - adds the attribute to the list of attributes. /// addAttribute - adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attributes attr); void addAttribute(unsigned i, Attributes attr);
@ -3029,7 +3029,7 @@ public:
/// \brief Return true if the call should not be inlined. /// \brief Return true if the call should not be inlined.
bool isNoInline() const { return hasFnAttr(Attributes::NoInline); } bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
void setIsNoInline() { void setIsNoInline() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::NoInline)); Attributes::get(getContext(), Attributes::NoInline));
} }
@ -3038,7 +3038,7 @@ public:
return hasFnAttr(Attributes::ReadNone); return hasFnAttr(Attributes::ReadNone);
} }
void setDoesNotAccessMemory() { void setDoesNotAccessMemory() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::ReadNone)); Attributes::get(getContext(), Attributes::ReadNone));
} }
@ -3047,21 +3047,21 @@ public:
return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly); return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
} }
void setOnlyReadsMemory() { void setOnlyReadsMemory() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::ReadOnly)); Attributes::get(getContext(), Attributes::ReadOnly));
} }
/// \brief Determine if the call cannot return. /// \brief Determine if the call cannot return.
bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); } bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
void setDoesNotReturn() { void setDoesNotReturn() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::NoReturn)); Attributes::get(getContext(), Attributes::NoReturn));
} }
/// \brief Determine if the call cannot unwind. /// \brief Determine if the call cannot unwind.
bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); } bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
void setDoesNotThrow() { void setDoesNotThrow() {
addAttribute(AttrListPtr::FunctionIndex, addAttribute(AttributeSet::FunctionIndex,
Attributes::get(getContext(), Attributes::NoUnwind)); Attributes::get(getContext(), Attributes::NoUnwind));
} }

View File

@ -26,7 +26,7 @@ class FunctionType;
class Function; class Function;
class LLVMContext; class LLVMContext;
class Module; class Module;
class AttrListPtr; class AttributeSet;
/// Intrinsic Namespace - This namespace contains an enum with a value for /// Intrinsic Namespace - This namespace contains an enum with a value for
/// every intrinsic/builtin function known by LLVM. These enum values are /// every intrinsic/builtin function known by LLVM. These enum values are
@ -58,7 +58,7 @@ namespace Intrinsic {
/// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic. /// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic.
/// ///
AttrListPtr getAttributes(LLVMContext &C, ID id); AttributeSet getAttributes(LLVMContext &C, ID id);
/// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function /// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function
/// declaration for an intrinsic, and return it. /// declaration for an intrinsic, and return it.

View File

@ -312,7 +312,7 @@ public:
/// 4. Finally, the function exists but has the wrong prototype: return the /// 4. Finally, the function exists but has the wrong prototype: return the
/// function with a constantexpr cast to the right prototype. /// function with a constantexpr cast to the right prototype.
Constant *getOrInsertFunction(StringRef Name, FunctionType *T, Constant *getOrInsertFunction(StringRef Name, FunctionType *T,
AttrListPtr AttributeList); AttributeSet AttributeList);
Constant *getOrInsertFunction(StringRef Name, FunctionType *T); Constant *getOrInsertFunction(StringRef Name, FunctionType *T);
@ -324,7 +324,7 @@ public:
/// null terminated list of function arguments, which makes it easier for /// null terminated list of function arguments, which makes it easier for
/// clients to use. /// clients to use.
Constant *getOrInsertFunction(StringRef Name, Constant *getOrInsertFunction(StringRef Name,
AttrListPtr AttributeList, AttributeSet AttributeList,
Type *RetTy, ...) END_WITH_NULL; Type *RetTy, ...) END_WITH_NULL;
/// getOrInsertFunction - Same as above, but without the attributes. /// getOrInsertFunction - Same as above, but without the attributes.
@ -333,7 +333,7 @@ public:
Constant *getOrInsertTargetIntrinsic(StringRef Name, Constant *getOrInsertTargetIntrinsic(StringRef Name,
FunctionType *Ty, FunctionType *Ty,
AttrListPtr AttributeList); AttributeSet AttributeList);
/// getFunction - Look up the specified function in the module symbol table. /// getFunction - Look up the specified function in the module symbol table.
/// If it does not exist, return null. /// If it does not exist, return null.

View File

@ -177,10 +177,10 @@ public:
/// getAttributes/setAttributes - get or set the parameter attributes of /// getAttributes/setAttributes - get or set the parameter attributes of
/// the call. /// the call.
const AttrListPtr &getAttributes() const { const AttributeSet &getAttributes() const {
CALLSITE_DELEGATE_GETTER(getAttributes()); CALLSITE_DELEGATE_GETTER(getAttributes());
} }
void setAttributes(const AttrListPtr &PAL) { void setAttributes(const AttributeSet &PAL) {
CALLSITE_DELEGATE_SETTER(setAttributes(PAL)); CALLSITE_DELEGATE_SETTER(setAttributes(PAL));
} }

View File

@ -81,7 +81,7 @@ namespace llvm {
/// 'l' is added as the suffix of name, if 'Op' is a float, we add a 'f' /// 'l' is added as the suffix of name, if 'Op' is a float, we add a 'f'
/// suffix. /// suffix.
Value *EmitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B, Value *EmitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B,
const AttrListPtr &Attrs); const AttributeSet &Attrs);
/// EmitPutChar - Emit a call to the putchar function. This assumes that Char /// EmitPutChar - Emit a call to the putchar function. This assumes that Char
/// is an integer. /// is an integer.

View File

@ -2813,7 +2813,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
if (RetAttrs.hasAttributes()) if (RetAttrs.hasAttributes())
Attrs.push_back( Attrs.push_back(
AttributeWithIndex::get(AttrListPtr::ReturnIndex, AttributeWithIndex::get(AttributeSet::ReturnIndex,
Attributes::get(RetType->getContext(), Attributes::get(RetType->getContext(),
RetAttrs))); RetAttrs)));
@ -2825,11 +2825,11 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
if (FuncAttrs.hasAttributes()) if (FuncAttrs.hasAttributes())
Attrs.push_back( Attrs.push_back(
AttributeWithIndex::get(AttrListPtr::FunctionIndex, AttributeWithIndex::get(AttributeSet::FunctionIndex,
Attributes::get(RetType->getContext(), Attributes::get(RetType->getContext(),
FuncAttrs))); FuncAttrs)));
AttrListPtr PAL = AttrListPtr::get(Context, Attrs); AttributeSet PAL = AttributeSet::get(Context, Attrs);
if (PAL.getParamAttributes(1).hasAttribute(Attributes::StructRet) && if (PAL.getParamAttributes(1).hasAttribute(Attributes::StructRet) &&
!RetType->isVoidTy()) !RetType->isVoidTy())
@ -3358,7 +3358,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
SmallVector<AttributeWithIndex, 8> Attrs; SmallVector<AttributeWithIndex, 8> Attrs;
if (RetAttrs.hasAttributes()) if (RetAttrs.hasAttributes())
Attrs.push_back( Attrs.push_back(
AttributeWithIndex::get(AttrListPtr::ReturnIndex, AttributeWithIndex::get(AttributeSet::ReturnIndex,
Attributes::get(Callee->getContext(), Attributes::get(Callee->getContext(),
RetAttrs))); RetAttrs)));
@ -3389,12 +3389,12 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
if (FnAttrs.hasAttributes()) if (FnAttrs.hasAttributes())
Attrs.push_back( Attrs.push_back(
AttributeWithIndex::get(AttrListPtr::FunctionIndex, AttributeWithIndex::get(AttributeSet::FunctionIndex,
Attributes::get(Callee->getContext(), Attributes::get(Callee->getContext(),
FnAttrs))); FnAttrs)));
// Finish off the Attributes and check them // Finish off the Attributes and check them
AttrListPtr PAL = AttrListPtr::get(Context, Attrs); AttributeSet PAL = AttributeSet::get(Context, Attrs);
InvokeInst *II = InvokeInst::Create(Callee, NormalBB, UnwindBB, Args); InvokeInst *II = InvokeInst::Create(Callee, NormalBB, UnwindBB, Args);
II->setCallingConv(CC); II->setCallingConv(CC);
@ -3760,7 +3760,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
SmallVector<AttributeWithIndex, 8> Attrs; SmallVector<AttributeWithIndex, 8> Attrs;
if (RetAttrs.hasAttributes()) if (RetAttrs.hasAttributes())
Attrs.push_back( Attrs.push_back(
AttributeWithIndex::get(AttrListPtr::ReturnIndex, AttributeWithIndex::get(AttributeSet::ReturnIndex,
Attributes::get(Callee->getContext(), Attributes::get(Callee->getContext(),
RetAttrs))); RetAttrs)));
@ -3791,12 +3791,12 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
if (FnAttrs.hasAttributes()) if (FnAttrs.hasAttributes())
Attrs.push_back( Attrs.push_back(
AttributeWithIndex::get(AttrListPtr::FunctionIndex, AttributeWithIndex::get(AttributeSet::FunctionIndex,
Attributes::get(Callee->getContext(), Attributes::get(Callee->getContext(),
FnAttrs))); FnAttrs)));
// Finish off the Attributes and check them // Finish off the Attributes and check them
AttrListPtr PAL = AttrListPtr::get(Context, Attrs); AttributeSet PAL = AttributeSet::get(Context, Attrs);
CallInst *CI = CallInst::Create(Callee, Args); CallInst *CI = CallInst::Create(Callee, Args);
CI->setTailCall(isTail); CI->setTailCall(isTail);

View File

@ -47,7 +47,7 @@ void BitcodeReader::FreeState() {
ValueList.clear(); ValueList.clear();
MDValueList.clear(); MDValueList.clear();
std::vector<AttrListPtr>().swap(MAttributes); std::vector<AttributeSet>().swap(MAttributes);
std::vector<BasicBlock*>().swap(FunctionBBs); std::vector<BasicBlock*>().swap(FunctionBBs);
std::vector<Function*>().swap(FunctionsWithBodies); std::vector<Function*>().swap(FunctionsWithBodies);
DeferredFunctionInfo.clear(); DeferredFunctionInfo.clear();
@ -487,7 +487,7 @@ bool BitcodeReader::ParseAttributeBlock() {
Attributes::get(Context, B))); Attributes::get(Context, B)));
} }
MAttributes.push_back(AttrListPtr::get(Context, Attrs)); MAttributes.push_back(AttributeSet::get(Context, Attrs));
Attrs.clear(); Attrs.clear();
break; break;
} }
@ -2398,7 +2398,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
case bitc::FUNC_CODE_INST_INVOKE: { case bitc::FUNC_CODE_INST_INVOKE: {
// INVOKE: [attrs, cc, normBB, unwindBB, fnty, op0,op1,op2, ...] // INVOKE: [attrs, cc, normBB, unwindBB, fnty, op0,op1,op2, ...]
if (Record.size() < 4) return Error("Invalid INVOKE record"); if (Record.size() < 4) return Error("Invalid INVOKE record");
AttrListPtr PAL = getAttributes(Record[0]); AttributeSet PAL = getAttributes(Record[0]);
unsigned CCInfo = Record[1]; unsigned CCInfo = Record[1];
BasicBlock *NormalBB = getBasicBlock(Record[2]); BasicBlock *NormalBB = getBasicBlock(Record[2]);
BasicBlock *UnwindBB = getBasicBlock(Record[3]); BasicBlock *UnwindBB = getBasicBlock(Record[3]);
@ -2663,7 +2663,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
if (Record.size() < 3) if (Record.size() < 3)
return Error("Invalid CALL record"); return Error("Invalid CALL record");
AttrListPtr PAL = getAttributes(Record[0]); AttributeSet PAL = getAttributes(Record[0]);
unsigned CCInfo = Record[1]; unsigned CCInfo = Record[1];
unsigned OpNum = 2; unsigned OpNum = 2;

View File

@ -146,7 +146,7 @@ class BitcodeReader : public GVMaterializer {
/// MAttributes - The set of attributes by index. Index zero in the /// MAttributes - The set of attributes by index. Index zero in the
/// file is for null, and is thus not represented here. As such all indices /// file is for null, and is thus not represented here. As such all indices
/// are off by one. /// are off by one.
std::vector<AttrListPtr> MAttributes; std::vector<AttributeSet> MAttributes;
/// FunctionBBs - While parsing a function body, this is a list of the basic /// FunctionBBs - While parsing a function body, this is a list of the basic
/// blocks for the function. /// blocks for the function.
@ -246,10 +246,10 @@ private:
if (ID >= FunctionBBs.size()) return 0; // Invalid ID if (ID >= FunctionBBs.size()) return 0; // Invalid ID
return FunctionBBs[ID]; return FunctionBBs[ID];
} }
AttrListPtr getAttributes(unsigned i) const { AttributeSet getAttributes(unsigned i) const {
if (i-1 < MAttributes.size()) if (i-1 < MAttributes.size())
return MAttributes[i-1]; return MAttributes[i-1];
return AttrListPtr(); return AttributeSet();
} }
/// getValueTypePair - Read a value/type pair out of the specified record from /// getValueTypePair - Read a value/type pair out of the specified record from

View File

@ -164,14 +164,14 @@ static void WriteStringRecord(unsigned Code, StringRef Str,
// Emit information about parameter attributes. // Emit information about parameter attributes.
static void WriteAttributeTable(const ValueEnumerator &VE, static void WriteAttributeTable(const ValueEnumerator &VE,
BitstreamWriter &Stream) { BitstreamWriter &Stream) {
const std::vector<AttrListPtr> &Attrs = VE.getAttributes(); const std::vector<AttributeSet> &Attrs = VE.getAttributes();
if (Attrs.empty()) return; if (Attrs.empty()) return;
Stream.EnterSubblock(bitc::PARAMATTR_BLOCK_ID, 3); Stream.EnterSubblock(bitc::PARAMATTR_BLOCK_ID, 3);
SmallVector<uint64_t, 64> Record; SmallVector<uint64_t, 64> Record;
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) { for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
const AttrListPtr &A = Attrs[i]; const AttributeSet &A = Attrs[i];
for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) { for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
const AttributeWithIndex &PAWI = A.getSlot(i); const AttributeWithIndex &PAWI = A.getSlot(i);
Record.push_back(PAWI.Index); Record.push_back(PAWI.Index);

View File

@ -418,7 +418,7 @@ void ValueEnumerator::EnumerateOperandType(const Value *V) {
EnumerateMetadata(V); EnumerateMetadata(V);
} }
void ValueEnumerator::EnumerateAttributes(const AttrListPtr &PAL) { void ValueEnumerator::EnumerateAttributes(const AttributeSet &PAL) {
if (PAL.isEmpty()) return; // null is always 0. if (PAL.isEmpty()) return; // null is always 0.
// Do a lookup. // Do a lookup.
unsigned &Entry = AttributeMap[PAL.getRawPointer()]; unsigned &Entry = AttributeMap[PAL.getRawPointer()];

View File

@ -29,7 +29,7 @@ class Function;
class Module; class Module;
class MDNode; class MDNode;
class NamedMDNode; class NamedMDNode;
class AttrListPtr; class AttributeSet;
class ValueSymbolTable; class ValueSymbolTable;
class MDSymbolTable; class MDSymbolTable;
class raw_ostream; class raw_ostream;
@ -54,7 +54,7 @@ private:
typedef DenseMap<void*, unsigned> AttributeMapType; typedef DenseMap<void*, unsigned> AttributeMapType;
AttributeMapType AttributeMap; AttributeMapType AttributeMap;
std::vector<AttrListPtr> Attributes; std::vector<AttributeSet> Attributes;
/// GlobalBasicBlockIDs - This map memoizes the basic block ID's referenced by /// GlobalBasicBlockIDs - This map memoizes the basic block ID's referenced by
/// the "getGlobalBasicBlockID" method. /// the "getGlobalBasicBlockID" method.
@ -98,7 +98,7 @@ public:
unsigned getInstructionID(const Instruction *I) const; unsigned getInstructionID(const Instruction *I) const;
void setInstructionID(const Instruction *I); void setInstructionID(const Instruction *I);
unsigned getAttributeID(const AttrListPtr &PAL) const { unsigned getAttributeID(const AttributeSet &PAL) const {
if (PAL.isEmpty()) return 0; // Null maps to zero. if (PAL.isEmpty()) return 0; // Null maps to zero.
AttributeMapType::const_iterator I = AttributeMap.find(PAL.getRawPointer()); AttributeMapType::const_iterator I = AttributeMap.find(PAL.getRawPointer());
assert(I != AttributeMap.end() && "Attribute not in ValueEnumerator!"); assert(I != AttributeMap.end() && "Attribute not in ValueEnumerator!");
@ -121,7 +121,7 @@ public:
const std::vector<const BasicBlock*> &getBasicBlocks() const { const std::vector<const BasicBlock*> &getBasicBlocks() const {
return BasicBlocks; return BasicBlocks;
} }
const std::vector<AttrListPtr> &getAttributes() const { const std::vector<AttributeSet> &getAttributes() const {
return Attributes; return Attributes;
} }
@ -146,7 +146,7 @@ private:
void EnumerateValue(const Value *V); void EnumerateValue(const Value *V);
void EnumerateType(Type *T); void EnumerateType(Type *T);
void EnumerateOperandType(const Value *V); void EnumerateOperandType(const Value *V);
void EnumerateAttributes(const AttrListPtr &PAL); void EnumerateAttributes(const AttributeSet &PAL);
void EnumerateValueSymbolTable(const ValueSymbolTable &ST); void EnumerateValueSymbolTable(const ValueSymbolTable &ST);
void EnumerateNamedMetadata(const Module *M); void EnumerateNamedMetadata(const Module *M);

View File

@ -141,7 +141,7 @@ namespace {
std::string getCppName(const Value* val); std::string getCppName(const Value* val);
inline void printCppName(const Value* val); inline void printCppName(const Value* val);
void printAttributes(const AttrListPtr &PAL, const std::string &name); void printAttributes(const AttributeSet &PAL, const std::string &name);
void printType(Type* Ty); void printType(Type* Ty);
void printTypes(const Module* M); void printTypes(const Module* M);
@ -464,9 +464,9 @@ void CppWriter::printCppName(const Value* val) {
printEscapedString(getCppName(val)); printEscapedString(getCppName(val));
} }
void CppWriter::printAttributes(const AttrListPtr &PAL, void CppWriter::printAttributes(const AttributeSet &PAL,
const std::string &name) { const std::string &name) {
Out << "AttrListPtr " << name << "_PAL;"; Out << "AttributeSet " << name << "_PAL;";
nl(Out); nl(Out);
if (!PAL.isEmpty()) { if (!PAL.isEmpty()) {
Out << '{'; in(); nl(Out); Out << '{'; in(); nl(Out);
@ -518,7 +518,7 @@ void CppWriter::printAttributes(const AttrListPtr &PAL,
Out << "Attrs.push_back(PAWI);"; Out << "Attrs.push_back(PAWI);";
nl(Out); nl(Out);
} }
Out << name << "_PAL = AttrListPtr::get(mod->getContext(), Attrs);"; Out << name << "_PAL = AttributeSet::get(mod->getContext(), Attrs);";
nl(Out); nl(Out);
out(); nl(Out); out(); nl(Out);
Out << '}'; nl(Out); Out << '}'; nl(Out);

View File

@ -104,7 +104,7 @@ Function *MBlazeIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID,
Type **Tys, Type **Tys,
unsigned numTy) const { unsigned numTy) const {
assert(!isOverloaded(IntrID) && "MBlaze intrinsics are not overloaded"); assert(!isOverloaded(IntrID) && "MBlaze intrinsics are not overloaded");
AttrListPtr AList = getAttributes(M->getContext(), AttributeSet AList = getAttributes(M->getContext(),
(mblazeIntrinsic::ID) IntrID); (mblazeIntrinsic::ID) IntrID);
return cast<Function>(M->getOrInsertFunction(getName(IntrID), return cast<Function>(M->getOrInsertFunction(getName(IntrID),
getType(M->getContext(), IntrID), getType(M->getContext(), IntrID),

View File

@ -1487,7 +1487,7 @@ void NVPTXAsmPrinter::printParamName(int paramIndex, raw_ostream &O) {
void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, void NVPTXAsmPrinter::emitFunctionParamList(const Function *F,
raw_ostream &O) { raw_ostream &O) {
const DataLayout *TD = TM.getDataLayout(); const DataLayout *TD = TM.getDataLayout();
const AttrListPtr &PAL = F->getAttributes(); const AttributeSet &PAL = F->getAttributes();
const TargetLowering *TLI = TM.getTargetLowering(); const TargetLowering *TLI = TM.getTargetLowering();
Function::const_arg_iterator I, E; Function::const_arg_iterator I, E;
unsigned paramIndex = 0; unsigned paramIndex = 0;

View File

@ -976,7 +976,7 @@ NVPTXTargetLowering::LowerFormalArguments(SDValue Chain,
const DataLayout *TD = getDataLayout(); const DataLayout *TD = getDataLayout();
const Function *F = MF.getFunction(); const Function *F = MF.getFunction();
const AttrListPtr &PAL = F->getAttributes(); const AttributeSet &PAL = F->getAttributes();
SDValue Root = DAG.getRoot(); SDValue Root = DAG.getRoot();
std::vector<SDValue> OutChains; std::vector<SDValue> OutChains;

View File

@ -10711,7 +10711,7 @@ SDValue X86TargetLowering::LowerINIT_TRAMPOLINE(SDValue Op,
// Check that ECX wasn't needed by an 'inreg' parameter. // Check that ECX wasn't needed by an 'inreg' parameter.
FunctionType *FTy = Func->getFunctionType(); FunctionType *FTy = Func->getFunctionType();
const AttrListPtr &Attrs = Func->getAttributes(); const AttributeSet &Attrs = Func->getAttributes();
if (!Attrs.isEmpty() && !Func->isVarArg()) { if (!Attrs.isEmpty() && !Func->isVarArg()) {
unsigned InRegCount = 0; unsigned InRegCount = 0;

View File

@ -98,7 +98,7 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc(); DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
bool FP = hasFP(MF); bool FP = hasFP(MF);
const AttrListPtr &PAL = MF.getFunction()->getAttributes(); const AttributeSet &PAL = MF.getFunction()->getAttributes();
for (unsigned I = 0, E = PAL.getNumAttrs(); I != E; ++I) for (unsigned I = 0, E = PAL.getNumAttrs(); I != E; ++I)
if (PAL.getAttributesAtIndex(I).hasAttribute(Attributes::Nest)) { if (PAL.getAttributesAtIndex(I).hasAttribute(Attributes::Nest)) {

View File

@ -515,12 +515,12 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// that we are *not* promoting. For the ones that we do promote, the parameter // that we are *not* promoting. For the ones that we do promote, the parameter
// attributes are lost // attributes are lost
SmallVector<AttributeWithIndex, 8> AttributesVec; SmallVector<AttributeWithIndex, 8> AttributesVec;
const AttrListPtr &PAL = F->getAttributes(); const AttributeSet &PAL = F->getAttributes();
// Add any return attributes. // Add any return attributes.
Attributes attrs = PAL.getRetAttributes(); Attributes attrs = PAL.getRetAttributes();
if (attrs.hasAttributes()) if (attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
attrs)); attrs));
// First, determine the new argument list // First, determine the new argument list
@ -593,7 +593,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Add any function attributes. // Add any function attributes.
attrs = PAL.getFnAttributes(); attrs = PAL.getFnAttributes();
if (attrs.hasAttributes()) if (attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
attrs)); attrs));
Type *RetTy = FTy->getReturnType(); Type *RetTy = FTy->getReturnType();
@ -611,7 +611,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Recompute the parameter attributes list based on the new arguments for // Recompute the parameter attributes list based on the new arguments for
// the function. // the function.
NF->setAttributes(AttrListPtr::get(F->getContext(), AttributesVec)); NF->setAttributes(AttributeSet::get(F->getContext(), AttributesVec));
AttributesVec.clear(); AttributesVec.clear();
F->getParent()->getFunctionList().insert(F, NF); F->getParent()->getFunctionList().insert(F, NF);
@ -636,12 +636,12 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
CallSite CS(F->use_back()); CallSite CS(F->use_back());
assert(CS.getCalledFunction() == F); assert(CS.getCalledFunction() == F);
Instruction *Call = CS.getInstruction(); Instruction *Call = CS.getInstruction();
const AttrListPtr &CallPAL = CS.getAttributes(); const AttributeSet &CallPAL = CS.getAttributes();
// Add any return attributes. // Add any return attributes.
Attributes attrs = CallPAL.getRetAttributes(); Attributes attrs = CallPAL.getRetAttributes();
if (attrs.hasAttributes()) if (attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
attrs)); attrs));
// Loop over the operands, inserting GEP and loads in the caller as // Loop over the operands, inserting GEP and loads in the caller as
@ -723,7 +723,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Add any function attributes. // Add any function attributes.
attrs = CallPAL.getFnAttributes(); attrs = CallPAL.getFnAttributes();
if (attrs.hasAttributes()) if (attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
attrs)); attrs));
Instruction *New; Instruction *New;
@ -731,12 +731,12 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(), New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
Args, "", Call); Args, "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv()); cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setAttributes(AttrListPtr::get(II->getContext(), cast<InvokeInst>(New)->setAttributes(AttributeSet::get(II->getContext(),
AttributesVec)); AttributesVec));
} else { } else {
New = CallInst::Create(NF, Args, "", Call); New = CallInst::Create(NF, Args, "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv()); cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setAttributes(AttrListPtr::get(New->getContext(), cast<CallInst>(New)->setAttributes(AttributeSet::get(New->getContext(),
AttributesVec)); AttributesVec));
if (cast<CallInst>(Call)->isTailCall()) if (cast<CallInst>(Call)->isTailCall())
cast<CallInst>(New)->setTailCall(); cast<CallInst>(New)->setTailCall();

View File

@ -271,16 +271,16 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
Args.assign(CS.arg_begin(), CS.arg_begin() + NumArgs); Args.assign(CS.arg_begin(), CS.arg_begin() + NumArgs);
// Drop any attributes that were on the vararg arguments. // Drop any attributes that were on the vararg arguments.
AttrListPtr PAL = CS.getAttributes(); AttributeSet PAL = CS.getAttributes();
if (!PAL.isEmpty() && PAL.getSlot(PAL.getNumSlots() - 1).Index > NumArgs) { if (!PAL.isEmpty() && PAL.getSlot(PAL.getNumSlots() - 1).Index > NumArgs) {
SmallVector<AttributeWithIndex, 8> AttributesVec; SmallVector<AttributeWithIndex, 8> AttributesVec;
for (unsigned i = 0; PAL.getSlot(i).Index <= NumArgs; ++i) for (unsigned i = 0; PAL.getSlot(i).Index <= NumArgs; ++i)
AttributesVec.push_back(PAL.getSlot(i)); AttributesVec.push_back(PAL.getSlot(i));
Attributes FnAttrs = PAL.getFnAttributes(); Attributes FnAttrs = PAL.getFnAttributes();
if (FnAttrs.hasAttributes()) if (FnAttrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
FnAttrs)); FnAttrs));
PAL = AttrListPtr::get(Fn.getContext(), AttributesVec); PAL = AttributeSet::get(Fn.getContext(), AttributesVec);
} }
Instruction *New; Instruction *New;
@ -698,7 +698,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Set up to build a new list of parameter attributes. // Set up to build a new list of parameter attributes.
SmallVector<AttributeWithIndex, 8> AttributesVec; SmallVector<AttributeWithIndex, 8> AttributesVec;
const AttrListPtr &PAL = F->getAttributes(); const AttributeSet &PAL = F->getAttributes();
// The existing function return attributes. // The existing function return attributes.
Attributes RAttrs = PAL.getRetAttributes(); Attributes RAttrs = PAL.getRetAttributes();
@ -773,7 +773,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
"Return attributes no longer compatible?"); "Return attributes no longer compatible?");
if (RAttrs.hasAttributes()) if (RAttrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
RAttrs)); RAttrs));
// Remember which arguments are still alive. // Remember which arguments are still alive.
@ -802,11 +802,11 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
} }
if (FnAttrs.hasAttributes()) if (FnAttrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
FnAttrs)); FnAttrs));
// Reconstruct the AttributesList based on the vector we constructed. // Reconstruct the AttributesList based on the vector we constructed.
AttrListPtr NewPAL = AttrListPtr::get(F->getContext(), AttributesVec); AttributeSet NewPAL = AttributeSet::get(F->getContext(), AttributesVec);
// Create the new function type based on the recomputed parameters. // Create the new function type based on the recomputed parameters.
FunctionType *NFTy = FunctionType::get(NRetTy, Params, FTy->isVarArg()); FunctionType *NFTy = FunctionType::get(NRetTy, Params, FTy->isVarArg());
@ -833,7 +833,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
Instruction *Call = CS.getInstruction(); Instruction *Call = CS.getInstruction();
AttributesVec.clear(); AttributesVec.clear();
const AttrListPtr &CallPAL = CS.getAttributes(); const AttributeSet &CallPAL = CS.getAttributes();
// The call return attributes. // The call return attributes.
Attributes RAttrs = CallPAL.getRetAttributes(); Attributes RAttrs = CallPAL.getRetAttributes();
@ -843,7 +843,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
Attributes::get(NF->getContext(), AttrBuilder(RAttrs). Attributes::get(NF->getContext(), AttrBuilder(RAttrs).
removeAttributes(Attributes::typeIncompatible(NF->getReturnType()))); removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
if (RAttrs.hasAttributes()) if (RAttrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
RAttrs)); RAttrs));
// Declare these outside of the loops, so we can reuse them for the second // Declare these outside of the loops, so we can reuse them for the second
@ -870,11 +870,11 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
} }
if (FnAttrs.hasAttributes()) if (FnAttrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex, AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
FnAttrs)); FnAttrs));
// Reconstruct the AttributesList based on the vector we constructed. // Reconstruct the AttributesList based on the vector we constructed.
AttrListPtr NewCallPAL = AttrListPtr::get(F->getContext(), AttributesVec); AttributeSet NewCallPAL = AttributeSet::get(F->getContext(), AttributesVec);
Instruction *New; Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) { if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {

View File

@ -215,13 +215,13 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
AttrBuilder B; AttrBuilder B;
B.addAttribute(Attributes::ReadOnly) B.addAttribute(Attributes::ReadOnly)
.addAttribute(Attributes::ReadNone); .addAttribute(Attributes::ReadNone);
F->removeAttribute(AttrListPtr::FunctionIndex, F->removeAttribute(AttributeSet::FunctionIndex,
Attributes::get(F->getContext(), B)); Attributes::get(F->getContext(), B));
// Add in the new attribute. // Add in the new attribute.
B.clear(); B.clear();
B.addAttribute(ReadsMemory ? Attributes::ReadOnly : Attributes::ReadNone); B.addAttribute(ReadsMemory ? Attributes::ReadOnly : Attributes::ReadNone);
F->addAttribute(AttrListPtr::FunctionIndex, F->addAttribute(AttributeSet::FunctionIndex,
Attributes::get(F->getContext(), B)); Attributes::get(F->getContext(), B));
if (ReadsMemory) if (ReadsMemory)

View File

@ -2065,7 +2065,7 @@ static void ChangeCalleesToFastCall(Function *F) {
} }
} }
static AttrListPtr StripNest(LLVMContext &C, const AttrListPtr &Attrs) { static AttributeSet StripNest(LLVMContext &C, const AttributeSet &Attrs) {
for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) { for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
if (!Attrs.getSlot(i).Attrs.hasAttribute(Attributes::Nest)) if (!Attrs.getSlot(i).Attrs.hasAttribute(Attributes::Nest))
continue; continue;

View File

@ -145,8 +145,8 @@ bool PruneEH::runOnSCC(CallGraphSCC &SCC) {
NewAttributes.addAttribute(Attributes::NoReturn); NewAttributes.addAttribute(Attributes::NoReturn);
Function *F = (*I)->getFunction(); Function *F = (*I)->getFunction();
const AttrListPtr &PAL = F->getAttributes(); const AttributeSet &PAL = F->getAttributes();
const AttrListPtr &NPAL = PAL.addAttr(F->getContext(), ~0, const AttributeSet &NPAL = PAL.addAttr(F->getContext(), ~0,
Attributes::get(F->getContext(), Attributes::get(F->getContext(),
NewAttributes)); NewAttributes));
if (PAL != NPAL) { if (PAL != NPAL) {

View File

@ -982,7 +982,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (Callee == 0) if (Callee == 0)
return false; return false;
Instruction *Caller = CS.getInstruction(); Instruction *Caller = CS.getInstruction();
const AttrListPtr &CallerPAL = CS.getAttributes(); const AttributeSet &CallerPAL = CS.getAttributes();
// Okay, this is a cast from a function to a different type. Unless doing so // Okay, this is a cast from a function to a different type. Unless doing so
// would cause a type conversion of one of our arguments, change this call to // would cause a type conversion of one of our arguments, change this call to
@ -1123,7 +1123,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// Add the new return attributes. // Add the new return attributes.
if (RAttrs.hasAttributes()) if (RAttrs.hasAttributes())
attrVec.push_back( attrVec.push_back(
AttributeWithIndex::get(AttrListPtr::ReturnIndex, AttributeWithIndex::get(AttributeSet::ReturnIndex,
Attributes::get(FT->getContext(), RAttrs))); Attributes::get(FT->getContext(), RAttrs)));
AI = CS.arg_begin(); AI = CS.arg_begin();
@ -1176,13 +1176,13 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
Attributes FnAttrs = CallerPAL.getFnAttributes(); Attributes FnAttrs = CallerPAL.getFnAttributes();
if (FnAttrs.hasAttributes()) if (FnAttrs.hasAttributes())
attrVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex, attrVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
FnAttrs)); FnAttrs));
if (NewRetTy->isVoidTy()) if (NewRetTy->isVoidTy())
Caller->setName(""); // Void type should not have a name. Caller->setName(""); // Void type should not have a name.
const AttrListPtr &NewCallerPAL = AttrListPtr::get(Callee->getContext(), const AttributeSet &NewCallerPAL = AttributeSet::get(Callee->getContext(),
attrVec); attrVec);
Instruction *NC; Instruction *NC;
@ -1243,7 +1243,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
Value *Callee = CS.getCalledValue(); Value *Callee = CS.getCalledValue();
PointerType *PTy = cast<PointerType>(Callee->getType()); PointerType *PTy = cast<PointerType>(Callee->getType());
FunctionType *FTy = cast<FunctionType>(PTy->getElementType()); FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
const AttrListPtr &Attrs = CS.getAttributes(); const AttributeSet &Attrs = CS.getAttributes();
// If the call already has the 'nest' attribute somewhere then give up - // If the call already has the 'nest' attribute somewhere then give up -
// otherwise 'nest' would occur twice after splicing in the chain. // otherwise 'nest' would occur twice after splicing in the chain.
@ -1258,7 +1258,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
PointerType *NestFPTy = cast<PointerType>(NestF->getType()); PointerType *NestFPTy = cast<PointerType>(NestF->getType());
FunctionType *NestFTy = cast<FunctionType>(NestFPTy->getElementType()); FunctionType *NestFTy = cast<FunctionType>(NestFPTy->getElementType());
const AttrListPtr &NestAttrs = NestF->getAttributes(); const AttributeSet &NestAttrs = NestF->getAttributes();
if (!NestAttrs.isEmpty()) { if (!NestAttrs.isEmpty()) {
unsigned NestIdx = 1; unsigned NestIdx = 1;
Type *NestTy = 0; Type *NestTy = 0;
@ -1288,7 +1288,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
// Add any result attributes. // Add any result attributes.
Attributes Attr = Attrs.getRetAttributes(); Attributes Attr = Attrs.getRetAttributes();
if (Attr.hasAttributes()) if (Attr.hasAttributes())
NewAttrs.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex, NewAttrs.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
Attr)); Attr));
{ {
@ -1321,7 +1321,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
// Add any function attributes. // Add any function attributes.
Attr = Attrs.getFnAttributes(); Attr = Attrs.getFnAttributes();
if (Attr.hasAttributes()) if (Attr.hasAttributes())
NewAttrs.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex, NewAttrs.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
Attr)); Attr));
// The trampoline may have been bitcast to a bogus type (FTy). // The trampoline may have been bitcast to a bogus type (FTy).
@ -1361,7 +1361,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
NestF->getType() == PointerType::getUnqual(NewFTy) ? NestF->getType() == PointerType::getUnqual(NewFTy) ?
NestF : ConstantExpr::getBitCast(NestF, NestF : ConstantExpr::getBitCast(NestF,
PointerType::getUnqual(NewFTy)); PointerType::getUnqual(NewFTy));
const AttrListPtr &NewPAL = AttrListPtr::get(FTy->getContext(), NewAttrs); const AttributeSet &NewPAL = AttributeSet::get(FTy->getContext(), NewAttrs);
Instruction *NewCaller; Instruction *NewCaller;
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) { if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {

View File

@ -1192,7 +1192,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
AttrBuilder B; AttrBuilder B;
B.addAttribute(Attributes::ReadOnly) B.addAttribute(Attributes::ReadOnly)
.addAttribute(Attributes::ReadNone); .addAttribute(Attributes::ReadNone);
Func->removeAttribute(AttrListPtr::FunctionIndex, Func->removeAttribute(AttributeSet::FunctionIndex,
Attributes::get(Func->getContext(), B)); Attributes::get(Func->getContext(), B));
} }
} }
@ -1572,7 +1572,7 @@ bool MemorySanitizer::runOnFunction(Function &F) {
AttrBuilder B; AttrBuilder B;
B.addAttribute(Attributes::ReadOnly) B.addAttribute(Attributes::ReadOnly)
.addAttribute(Attributes::ReadNone); .addAttribute(Attributes::ReadNone);
F.removeAttribute(AttrListPtr::FunctionIndex, F.removeAttribute(AttributeSet::FunctionIndex,
Attributes::get(F.getContext(), B)); Attributes::get(F.getContext(), B));
return Visitor.runOnFunction(); return Visitor.runOnFunction();

View File

@ -1788,8 +1788,8 @@ Constant *ObjCARCOpt::getRetainRVCallee(Module *M) {
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X }; Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
AttrListPtr Attributes = AttributeSet Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex, AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
Attributes::get(C, Attributes::NoUnwind)); Attributes::get(C, Attributes::NoUnwind));
RetainRVCallee = RetainRVCallee =
M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy, M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy,
@ -1804,8 +1804,8 @@ Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) {
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X }; Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
AttrListPtr Attributes = AttributeSet Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex, AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
Attributes::get(C, Attributes::NoUnwind)); Attributes::get(C, Attributes::NoUnwind));
AutoreleaseRVCallee = AutoreleaseRVCallee =
M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy, M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy,
@ -1818,8 +1818,8 @@ Constant *ObjCARCOpt::getReleaseCallee(Module *M) {
if (!ReleaseCallee) { if (!ReleaseCallee) {
LLVMContext &C = M->getContext(); LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) }; Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
AttrListPtr Attributes = AttributeSet Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex, AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
Attributes::get(C, Attributes::NoUnwind)); Attributes::get(C, Attributes::NoUnwind));
ReleaseCallee = ReleaseCallee =
M->getOrInsertFunction( M->getOrInsertFunction(
@ -1834,8 +1834,8 @@ Constant *ObjCARCOpt::getRetainCallee(Module *M) {
if (!RetainCallee) { if (!RetainCallee) {
LLVMContext &C = M->getContext(); LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) }; Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
AttrListPtr Attributes = AttributeSet Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex, AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
Attributes::get(C, Attributes::NoUnwind)); Attributes::get(C, Attributes::NoUnwind));
RetainCallee = RetainCallee =
M->getOrInsertFunction( M->getOrInsertFunction(
@ -1856,7 +1856,7 @@ Constant *ObjCARCOpt::getRetainBlockCallee(Module *M) {
M->getOrInsertFunction( M->getOrInsertFunction(
"objc_retainBlock", "objc_retainBlock",
FunctionType::get(Params[0], Params, /*isVarArg=*/false), FunctionType::get(Params[0], Params, /*isVarArg=*/false),
AttrListPtr()); AttributeSet());
} }
return RetainBlockCallee; return RetainBlockCallee;
} }
@ -1865,8 +1865,8 @@ Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) {
if (!AutoreleaseCallee) { if (!AutoreleaseCallee) {
LLVMContext &C = M->getContext(); LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) }; Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
AttrListPtr Attributes = AttributeSet Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex, AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
Attributes::get(C, Attributes::NoUnwind)); Attributes::get(C, Attributes::NoUnwind));
AutoreleaseCallee = AutoreleaseCallee =
M->getOrInsertFunction( M->getOrInsertFunction(
@ -3840,8 +3840,8 @@ Constant *ObjCARCContract::getStoreStrongCallee(Module *M) {
Type *I8XX = PointerType::getUnqual(I8X); Type *I8XX = PointerType::getUnqual(I8X);
Type *Params[] = { I8XX, I8X }; Type *Params[] = { I8XX, I8X };
AttrListPtr Attributes = AttrListPtr() AttributeSet Attributes = AttributeSet()
.addAttr(M->getContext(), AttrListPtr::FunctionIndex, .addAttr(M->getContext(), AttributeSet::FunctionIndex,
Attributes::get(C, Attributes::NoUnwind)) Attributes::get(C, Attributes::NoUnwind))
.addAttr(M->getContext(), 1, Attributes::get(C, Attributes::NoCapture)); .addAttr(M->getContext(), 1, Attributes::get(C, Attributes::NoCapture));
@ -3860,8 +3860,8 @@ Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) {
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X }; Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
AttrListPtr Attributes = AttributeSet Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex, AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
Attributes::get(C, Attributes::NoUnwind)); Attributes::get(C, Attributes::NoUnwind));
RetainAutoreleaseCallee = RetainAutoreleaseCallee =
M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes); M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes);
@ -3875,8 +3875,8 @@ Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) {
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X }; Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
AttrListPtr Attributes = AttributeSet Attributes =
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex, AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
Attributes::get(C, Attributes::NoUnwind)); Attributes::get(C, Attributes::NoUnwind));
RetainAutoreleaseRVCallee = RetainAutoreleaseRVCallee =
M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy, M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy,

View File

@ -43,12 +43,12 @@ Value *llvm::EmitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout *TD,
AttributeWithIndex AWI[2]; AttributeWithIndex AWI[2];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind }; Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attributes::AttrVal>(AVs, 2)); ArrayRef<Attributes::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Constant *StrLen = M->getOrInsertFunction("strlen", Constant *StrLen = M->getOrInsertFunction("strlen",
AttrListPtr::get(M->getContext(), AttributeSet::get(M->getContext(),
AWI), AWI),
TD->getIntPtrType(Context), TD->getIntPtrType(Context),
B.getInt8PtrTy(), B.getInt8PtrTy(),
@ -72,12 +72,12 @@ Value *llvm::EmitStrNLen(Value *Ptr, Value *MaxLen, IRBuilder<> &B,
AttributeWithIndex AWI[2]; AttributeWithIndex AWI[2];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind }; Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attributes::AttrVal>(AVs, 2)); ArrayRef<Attributes::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Constant *StrNLen = M->getOrInsertFunction("strnlen", Constant *StrNLen = M->getOrInsertFunction("strnlen",
AttrListPtr::get(M->getContext(), AttributeSet::get(M->getContext(),
AWI), AWI),
TD->getIntPtrType(Context), TD->getIntPtrType(Context),
B.getInt8PtrTy(), B.getInt8PtrTy(),
@ -101,13 +101,13 @@ Value *llvm::EmitStrChr(Value *Ptr, char C, IRBuilder<> &B,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind }; Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
AttributeWithIndex AWI = AttributeWithIndex AWI =
AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attributes::AttrVal>(AVs, 2)); ArrayRef<Attributes::AttrVal>(AVs, 2));
Type *I8Ptr = B.getInt8PtrTy(); Type *I8Ptr = B.getInt8PtrTy();
Type *I32Ty = B.getInt32Ty(); Type *I32Ty = B.getInt32Ty();
Constant *StrChr = M->getOrInsertFunction("strchr", Constant *StrChr = M->getOrInsertFunction("strchr",
AttrListPtr::get(M->getContext(), AttributeSet::get(M->getContext(),
AWI), AWI),
I8Ptr, I8Ptr, I32Ty, NULL); I8Ptr, I8Ptr, I32Ty, NULL);
CallInst *CI = B.CreateCall2(StrChr, CastToCStr(Ptr, B), CallInst *CI = B.CreateCall2(StrChr, CastToCStr(Ptr, B),
@ -129,12 +129,12 @@ Value *llvm::EmitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len,
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture); AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind }; Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attributes::AttrVal>(AVs, 2)); ArrayRef<Attributes::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *StrNCmp = M->getOrInsertFunction("strncmp", Value *StrNCmp = M->getOrInsertFunction("strncmp",
AttrListPtr::get(M->getContext(), AttributeSet::get(M->getContext(),
AWI), AWI),
B.getInt32Ty(), B.getInt32Ty(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
@ -160,11 +160,11 @@ Value *llvm::EmitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2]; AttributeWithIndex AWI[2];
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
Attributes::NoUnwind); Attributes::NoUnwind);
Type *I8Ptr = B.getInt8PtrTy(); Type *I8Ptr = B.getInt8PtrTy();
Value *StrCpy = M->getOrInsertFunction(Name, Value *StrCpy = M->getOrInsertFunction(Name,
AttrListPtr::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
I8Ptr, I8Ptr, I8Ptr, NULL); I8Ptr, I8Ptr, I8Ptr, NULL);
CallInst *CI = B.CreateCall2(StrCpy, CastToCStr(Dst, B), CastToCStr(Src, B), CallInst *CI = B.CreateCall2(StrCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
Name); Name);
@ -184,11 +184,11 @@ Value *llvm::EmitStrNCpy(Value *Dst, Value *Src, Value *Len,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2]; AttributeWithIndex AWI[2];
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
Attributes::NoUnwind); Attributes::NoUnwind);
Type *I8Ptr = B.getInt8PtrTy(); Type *I8Ptr = B.getInt8PtrTy();
Value *StrNCpy = M->getOrInsertFunction(Name, Value *StrNCpy = M->getOrInsertFunction(Name,
AttrListPtr::get(M->getContext(), AttributeSet::get(M->getContext(),
AWI), AWI),
I8Ptr, I8Ptr, I8Ptr, I8Ptr, I8Ptr, I8Ptr,
Len->getType(), NULL); Len->getType(), NULL);
@ -210,11 +210,11 @@ Value *llvm::EmitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI; AttributeWithIndex AWI;
AWI = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
Attributes::NoUnwind); Attributes::NoUnwind);
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *MemCpy = M->getOrInsertFunction("__memcpy_chk", Value *MemCpy = M->getOrInsertFunction("__memcpy_chk",
AttrListPtr::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
B.getInt8PtrTy(), B.getInt8PtrTy(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
@ -239,11 +239,11 @@ Value *llvm::EmitMemChr(Value *Ptr, Value *Val,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI; AttributeWithIndex AWI;
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind }; Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
AWI = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attributes::AttrVal>(AVs, 2)); ArrayRef<Attributes::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *MemChr = M->getOrInsertFunction("memchr", Value *MemChr = M->getOrInsertFunction("memchr",
AttrListPtr::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
B.getInt8PtrTy(), B.getInt8PtrTy(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
B.getInt32Ty(), B.getInt32Ty(),
@ -269,12 +269,12 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture); AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind }; Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attributes::AttrVal>(AVs, 2)); ArrayRef<Attributes::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *MemCmp = M->getOrInsertFunction("memcmp", Value *MemCmp = M->getOrInsertFunction("memcmp",
AttrListPtr::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
B.getInt32Ty(), B.getInt32Ty(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
@ -293,7 +293,7 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
/// returns one value with the same type. If 'Op' is a long double, 'l' is /// returns one value with the same type. If 'Op' is a long double, 'l' is
/// added as the suffix of name, if 'Op' is a float, we add a 'f' suffix. /// added as the suffix of name, if 'Op' is a float, we add a 'f' suffix.
Value *llvm::EmitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B, Value *llvm::EmitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B,
const AttrListPtr &Attrs) { const AttributeSet &Attrs) {
SmallString<20> NameBuffer; SmallString<20> NameBuffer;
if (!Op->getType()->isDoubleTy()) { if (!Op->getType()->isDoubleTy()) {
// If we need to add a suffix, copy into NameBuffer. // If we need to add a suffix, copy into NameBuffer.
@ -348,11 +348,11 @@ Value *llvm::EmitPutS(Value *Str, IRBuilder<> &B, const DataLayout *TD,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2]; AttributeWithIndex AWI[2];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
Attributes::NoUnwind); Attributes::NoUnwind);
Value *PutS = M->getOrInsertFunction("puts", Value *PutS = M->getOrInsertFunction("puts",
AttrListPtr::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
B.getInt32Ty(), B.getInt32Ty(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
NULL); NULL);
@ -372,12 +372,12 @@ Value *llvm::EmitFPutC(Value *Char, Value *File, IRBuilder<> &B,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2]; AttributeWithIndex AWI[2];
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
Attributes::NoUnwind); Attributes::NoUnwind);
Constant *F; Constant *F;
if (File->getType()->isPointerTy()) if (File->getType()->isPointerTy())
F = M->getOrInsertFunction("fputc", F = M->getOrInsertFunction("fputc",
AttrListPtr::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
B.getInt32Ty(), B.getInt32Ty(),
B.getInt32Ty(), File->getType(), B.getInt32Ty(), File->getType(),
NULL); NULL);
@ -406,13 +406,13 @@ Value *llvm::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B,
AttributeWithIndex AWI[3]; AttributeWithIndex AWI[3];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture); AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
Attributes::NoUnwind); Attributes::NoUnwind);
StringRef FPutsName = TLI->getName(LibFunc::fputs); StringRef FPutsName = TLI->getName(LibFunc::fputs);
Constant *F; Constant *F;
if (File->getType()->isPointerTy()) if (File->getType()->isPointerTy())
F = M->getOrInsertFunction(FPutsName, F = M->getOrInsertFunction(FPutsName,
AttrListPtr::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
B.getInt32Ty(), B.getInt32Ty(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
File->getType(), NULL); File->getType(), NULL);
@ -439,14 +439,14 @@ Value *llvm::EmitFWrite(Value *Ptr, Value *Size, Value *File,
AttributeWithIndex AWI[3]; AttributeWithIndex AWI[3];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attributes::NoCapture); AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attributes::NoCapture);
AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex, AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
Attributes::NoUnwind); Attributes::NoUnwind);
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
StringRef FWriteName = TLI->getName(LibFunc::fwrite); StringRef FWriteName = TLI->getName(LibFunc::fwrite);
Constant *F; Constant *F;
if (File->getType()->isPointerTy()) if (File->getType()->isPointerTy())
F = M->getOrInsertFunction(FWriteName, F = M->getOrInsertFunction(FWriteName,
AttrListPtr::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
TD->getIntPtrType(Context), TD->getIntPtrType(Context),
B.getInt8PtrTy(), B.getInt8PtrTy(),
TD->getIntPtrType(Context), TD->getIntPtrType(Context),

View File

@ -99,12 +99,12 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
.getParamAttributes(I->getArgNo() + 1)); .getParamAttributes(I->getArgNo() + 1));
NewFunc->setAttributes(NewFunc->getAttributes() NewFunc->setAttributes(NewFunc->getAttributes()
.addAttr(NewFunc->getContext(), .addAttr(NewFunc->getContext(),
AttrListPtr::ReturnIndex, AttributeSet::ReturnIndex,
OldFunc->getAttributes() OldFunc->getAttributes()
.getRetAttributes())); .getRetAttributes()));
NewFunc->setAttributes(NewFunc->getAttributes() NewFunc->setAttributes(NewFunc->getAttributes()
.addAttr(NewFunc->getContext(), .addAttr(NewFunc->getContext(),
AttrListPtr::FunctionIndex, AttributeSet::FunctionIndex,
OldFunc->getAttributes() OldFunc->getAttributes()
.getFnAttributes())); .getFnAttributes()));

View File

@ -1556,7 +1556,7 @@ void AssemblyWriter::printFunction(const Function *F) {
} }
FunctionType *FT = F->getFunctionType(); FunctionType *FT = F->getFunctionType();
const AttrListPtr &Attrs = F->getAttributes(); const AttributeSet &Attrs = F->getAttributes();
Attributes RetAttrs = Attrs.getRetAttributes(); Attributes RetAttrs = Attrs.getRetAttributes();
if (RetAttrs.hasAttributes()) if (RetAttrs.hasAttributes())
Out << Attrs.getRetAttributes().getAsString() << ' '; Out << Attrs.getRetAttributes().getAsString() << ' ';
@ -1849,7 +1849,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
PointerType *PTy = cast<PointerType>(Operand->getType()); PointerType *PTy = cast<PointerType>(Operand->getType());
FunctionType *FTy = cast<FunctionType>(PTy->getElementType()); FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
Type *RetTy = FTy->getReturnType(); Type *RetTy = FTy->getReturnType();
const AttrListPtr &PAL = CI->getAttributes(); const AttributeSet &PAL = CI->getAttributes();
if (PAL.getRetAttributes().hasAttributes()) if (PAL.getRetAttributes().hasAttributes())
Out << ' ' << PAL.getRetAttributes().getAsString(); Out << ' ' << PAL.getRetAttributes().getAsString();
@ -1882,7 +1882,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
PointerType *PTy = cast<PointerType>(Operand->getType()); PointerType *PTy = cast<PointerType>(Operand->getType());
FunctionType *FTy = cast<FunctionType>(PTy->getElementType()); FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
Type *RetTy = FTy->getReturnType(); Type *RetTy = FTy->getReturnType();
const AttrListPtr &PAL = II->getAttributes(); const AttributeSet &PAL = II->getAttributes();
// Print the calling convention being used. // Print the calling convention being used.
if (II->getCallingConv() != CallingConv::C) { if (II->getCallingConv() != CallingConv::C) {

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements the Attributes, AttributeImpl, AttrBuilder, // This file implements the Attributes, AttributeImpl, AttrBuilder,
// AttributeListImpl, and AttrListPtr classes. // AttributeListImpl, and AttributeSet classes.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -355,11 +355,11 @@ uint64_t AttributesImpl::getStackAlignment() const {
// AttributeListImpl Definition // AttributeListImpl Definition
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
AttrListPtr AttrListPtr::get(LLVMContext &C, AttributeSet AttributeSet::get(LLVMContext &C,
ArrayRef<AttributeWithIndex> Attrs) { ArrayRef<AttributeWithIndex> Attrs) {
// If there are no attributes then return a null AttributesList pointer. // If there are no attributes then return a null AttributesList pointer.
if (Attrs.empty()) if (Attrs.empty())
return AttrListPtr(); return AttributeSet();
#ifndef NDEBUG #ifndef NDEBUG
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) { for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
@ -387,14 +387,14 @@ AttrListPtr AttrListPtr::get(LLVMContext &C,
} }
// Return the AttributesList that we found or created. // Return the AttributesList that we found or created.
return AttrListPtr(PA); return AttributeSet(PA);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// AttrListPtr Method Implementations // AttributeSet Method Implementations
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) { const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
if (AttrList == RHS.AttrList) return *this; if (AttrList == RHS.AttrList) return *this;
AttrList = RHS.AttrList; AttrList = RHS.AttrList;
@ -404,13 +404,13 @@ const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
/// getNumSlots - Return the number of slots used in this attribute list. /// getNumSlots - Return the number of slots used in this attribute list.
/// This is the number of arguments that have an attribute set on them /// This is the number of arguments that have an attribute set on them
/// (including the function itself). /// (including the function itself).
unsigned AttrListPtr::getNumSlots() const { unsigned AttributeSet::getNumSlots() const {
return AttrList ? AttrList->Attrs.size() : 0; return AttrList ? AttrList->Attrs.size() : 0;
} }
/// getSlot - Return the AttributeWithIndex at the specified slot. This /// getSlot - Return the AttributeWithIndex at the specified slot. This
/// holds a number plus a set of attributes. /// holds a number plus a set of attributes.
const AttributeWithIndex &AttrListPtr::getSlot(unsigned Slot) const { const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!"); assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
return AttrList->Attrs[Slot]; return AttrList->Attrs[Slot];
} }
@ -418,7 +418,7 @@ const AttributeWithIndex &AttrListPtr::getSlot(unsigned Slot) const {
/// getAttributes - The attributes for the specified index are returned. /// getAttributes - The attributes for the specified index are returned.
/// Attributes for the result are denoted with Idx = 0. Function notes are /// Attributes for the result are denoted with Idx = 0. Function notes are
/// denoted with idx = ~0. /// denoted with idx = ~0.
Attributes AttrListPtr::getAttributes(unsigned Idx) const { Attributes AttributeSet::getAttributes(unsigned Idx) const {
if (AttrList == 0) return Attributes(); if (AttrList == 0) return Attributes();
const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs; const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
@ -431,7 +431,7 @@ Attributes AttrListPtr::getAttributes(unsigned Idx) const {
/// hasAttrSomewhere - Return true if the specified attribute is set for at /// hasAttrSomewhere - Return true if the specified attribute is set for at
/// least one parameter or for the return value. /// least one parameter or for the return value.
bool AttrListPtr::hasAttrSomewhere(Attributes::AttrVal Attr) const { bool AttributeSet::hasAttrSomewhere(Attributes::AttrVal Attr) const {
if (AttrList == 0) return false; if (AttrList == 0) return false;
const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs; const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
@ -442,17 +442,17 @@ bool AttrListPtr::hasAttrSomewhere(Attributes::AttrVal Attr) const {
return false; return false;
} }
unsigned AttrListPtr::getNumAttrs() const { unsigned AttributeSet::getNumAttrs() const {
return AttrList ? AttrList->Attrs.size() : 0; return AttrList ? AttrList->Attrs.size() : 0;
} }
Attributes &AttrListPtr::getAttributesAtIndex(unsigned i) const { Attributes &AttributeSet::getAttributesAtIndex(unsigned i) const {
assert(AttrList && "Trying to get an attribute from an empty list!"); assert(AttrList && "Trying to get an attribute from an empty list!");
assert(i < AttrList->Attrs.size() && "Index out of range!"); assert(i < AttrList->Attrs.size() && "Index out of range!");
return AttrList->Attrs[i].Attrs; return AttrList->Attrs[i].Attrs;
} }
AttrListPtr AttrListPtr::addAttr(LLVMContext &C, unsigned Idx, AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
Attributes Attrs) const { Attributes Attrs) const {
Attributes OldAttrs = getAttributes(Idx); Attributes OldAttrs = getAttributes(Idx);
#ifndef NDEBUG #ifndef NDEBUG
@ -497,7 +497,7 @@ AttrListPtr AttrListPtr::addAttr(LLVMContext &C, unsigned Idx,
return get(C, NewAttrList); return get(C, NewAttrList);
} }
AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx, AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
Attributes Attrs) const { Attributes Attrs) const {
#ifndef NDEBUG #ifndef NDEBUG
// FIXME it is not obvious how this should work for alignment. // FIXME it is not obvious how this should work for alignment.
@ -505,7 +505,7 @@ AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx,
assert(!Attrs.hasAttribute(Attributes::Alignment) && assert(!Attrs.hasAttribute(Attributes::Alignment) &&
"Attempt to exclude alignment!"); "Attempt to exclude alignment!");
#endif #endif
if (AttrList == 0) return AttrListPtr(); if (AttrList == 0) return AttributeSet();
Attributes OldAttrs = getAttributes(Idx); Attributes OldAttrs = getAttributes(Idx);
AttrBuilder NewAttrs = AttrBuilder NewAttrs =
@ -536,7 +536,7 @@ AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx,
return get(C, NewAttrList); return get(C, NewAttrList);
} }
void AttrListPtr::dump() const { void AttributeSet::dump() const {
dbgs() << "PAL[ "; dbgs() << "PAL[ ";
for (unsigned i = 0; i < getNumSlots(); ++i) { for (unsigned i = 0; i < getNumSlots(); ++i) {
const AttributeWithIndex &PAWI = getSlot(i); const AttributeWithIndex &PAWI = getSlot(i);

View File

@ -1380,27 +1380,27 @@ void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn); Function *Func = unwrap<Function>(Fn);
const AttrListPtr PAL = Func->getAttributes(); const AttributeSet PAL = Func->getAttributes();
AttrBuilder B(PA); AttrBuilder B(PA);
const AttrListPtr PALnew = const AttributeSet PALnew =
PAL.addAttr(Func->getContext(), AttrListPtr::FunctionIndex, PAL.addAttr(Func->getContext(), AttributeSet::FunctionIndex,
Attributes::get(Func->getContext(), B)); Attributes::get(Func->getContext(), B));
Func->setAttributes(PALnew); Func->setAttributes(PALnew);
} }
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
Function *Func = unwrap<Function>(Fn); Function *Func = unwrap<Function>(Fn);
const AttrListPtr PAL = Func->getAttributes(); const AttributeSet PAL = Func->getAttributes();
AttrBuilder B(PA); AttrBuilder B(PA);
const AttrListPtr PALnew = const AttributeSet PALnew =
PAL.removeAttr(Func->getContext(), AttrListPtr::FunctionIndex, PAL.removeAttr(Func->getContext(), AttributeSet::FunctionIndex,
Attributes::get(Func->getContext(), B)); Attributes::get(Func->getContext(), B));
Func->setAttributes(PALnew); Func->setAttributes(PALnew);
} }
LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn) { LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn) {
Function *Func = unwrap<Function>(Fn); Function *Func = unwrap<Function>(Fn);
const AttrListPtr PAL = Func->getAttributes(); const AttributeSet PAL = Func->getAttributes();
Attributes attr = PAL.getFnAttributes(); Attributes attr = PAL.getFnAttributes();
return (LLVMAttribute)attr.Raw(); return (LLVMAttribute)attr.Raw();
} }

View File

@ -249,13 +249,13 @@ void Function::dropAllReferences() {
} }
void Function::addAttribute(unsigned i, Attributes attr) { void Function::addAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes(); AttributeSet PAL = getAttributes();
PAL = PAL.addAttr(getContext(), i, attr); PAL = PAL.addAttr(getContext(), i, attr);
setAttributes(PAL); setAttributes(PAL);
} }
void Function::removeAttribute(unsigned i, Attributes attr) { void Function::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes(); AttributeSet PAL = getAttributes();
PAL = PAL.removeAttr(getContext(), i, attr); PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL); setAttributes(PAL);
} }

View File

@ -331,23 +331,23 @@ CallInst::CallInst(const CallInst &CI)
} }
void CallInst::addAttribute(unsigned i, Attributes attr) { void CallInst::addAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes(); AttributeSet PAL = getAttributes();
PAL = PAL.addAttr(getContext(), i, attr); PAL = PAL.addAttr(getContext(), i, attr);
setAttributes(PAL); setAttributes(PAL);
} }
void CallInst::removeAttribute(unsigned i, Attributes attr) { void CallInst::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes(); AttributeSet PAL = getAttributes();
PAL = PAL.removeAttr(getContext(), i, attr); PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL); setAttributes(PAL);
} }
bool CallInst::hasFnAttr(Attributes::AttrVal A) const { bool CallInst::hasFnAttr(Attributes::AttrVal A) const {
if (AttributeList.getParamAttributes(AttrListPtr::FunctionIndex) if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex)
.hasAttribute(A)) .hasAttribute(A))
return true; return true;
if (const Function *F = getCalledFunction()) if (const Function *F = getCalledFunction())
return F->getParamAttributes(AttrListPtr::FunctionIndex).hasAttribute(A); return F->getParamAttributes(AttributeSet::FunctionIndex).hasAttribute(A);
return false; return false;
} }
@ -572,11 +572,11 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
} }
bool InvokeInst::hasFnAttr(Attributes::AttrVal A) const { bool InvokeInst::hasFnAttr(Attributes::AttrVal A) const {
if (AttributeList.getParamAttributes(AttrListPtr::FunctionIndex). if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex).
hasAttribute(A)) hasAttribute(A))
return true; return true;
if (const Function *F = getCalledFunction()) if (const Function *F = getCalledFunction())
return F->getParamAttributes(AttrListPtr::FunctionIndex).hasAttribute(A); return F->getParamAttributes(AttributeSet::FunctionIndex).hasAttribute(A);
return false; return false;
} }
@ -589,13 +589,13 @@ bool InvokeInst::paramHasAttr(unsigned i, Attributes::AttrVal A) const {
} }
void InvokeInst::addAttribute(unsigned i, Attributes attr) { void InvokeInst::addAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes(); AttributeSet PAL = getAttributes();
PAL = PAL.addAttr(getContext(), i, attr); PAL = PAL.addAttr(getContext(), i, attr);
setAttributes(PAL); setAttributes(PAL);
} }
void InvokeInst::removeAttribute(unsigned i, Attributes attr) { void InvokeInst::removeAttribute(unsigned i, Attributes attr) {
AttrListPtr PAL = getAttributes(); AttributeSet PAL = getAttributes();
PAL = PAL.removeAttr(getContext(), i, attr); PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL); setAttributes(PAL);
} }

View File

@ -137,7 +137,7 @@ void Module::getMDKindNames(SmallVectorImpl<StringRef> &Result) const {
// //
Constant *Module::getOrInsertFunction(StringRef Name, Constant *Module::getOrInsertFunction(StringRef Name,
FunctionType *Ty, FunctionType *Ty,
AttrListPtr AttributeList) { AttributeSet AttributeList) {
// See if we have a definition for the specified function already. // See if we have a definition for the specified function already.
GlobalValue *F = getNamedValue(Name); GlobalValue *F = getNamedValue(Name);
if (F == 0) { if (F == 0) {
@ -170,7 +170,7 @@ Constant *Module::getOrInsertFunction(StringRef Name,
Constant *Module::getOrInsertTargetIntrinsic(StringRef Name, Constant *Module::getOrInsertTargetIntrinsic(StringRef Name,
FunctionType *Ty, FunctionType *Ty,
AttrListPtr AttributeList) { AttributeSet AttributeList) {
// See if we have a definition for the specified function already. // See if we have a definition for the specified function already.
GlobalValue *F = getNamedValue(Name); GlobalValue *F = getNamedValue(Name);
if (F == 0) { if (F == 0) {
@ -187,7 +187,7 @@ Constant *Module::getOrInsertTargetIntrinsic(StringRef Name,
Constant *Module::getOrInsertFunction(StringRef Name, Constant *Module::getOrInsertFunction(StringRef Name,
FunctionType *Ty) { FunctionType *Ty) {
return getOrInsertFunction(Name, Ty, AttrListPtr()); return getOrInsertFunction(Name, Ty, AttributeSet());
} }
// getOrInsertFunction - Look up the specified function in the module symbol // getOrInsertFunction - Look up the specified function in the module symbol
@ -196,7 +196,7 @@ Constant *Module::getOrInsertFunction(StringRef Name,
// arguments, which makes it easier for clients to use. // arguments, which makes it easier for clients to use.
// //
Constant *Module::getOrInsertFunction(StringRef Name, Constant *Module::getOrInsertFunction(StringRef Name,
AttrListPtr AttributeList, AttributeSet AttributeList,
Type *RetTy, ...) { Type *RetTy, ...) {
va_list Args; va_list Args;
va_start(Args, RetTy); va_start(Args, RetTy);
@ -229,7 +229,7 @@ Constant *Module::getOrInsertFunction(StringRef Name,
// Build the function type and chain to the other getOrInsertFunction... // Build the function type and chain to the other getOrInsertFunction...
return getOrInsertFunction(Name, return getOrInsertFunction(Name,
FunctionType::get(RetTy, ArgTys, false), FunctionType::get(RetTy, ArgTys, false),
AttrListPtr()); AttributeSet());
} }
// getFunction - Look up the specified function in the module symbol table. // getFunction - Look up the specified function in the module symbol table.

View File

@ -299,7 +299,7 @@ namespace {
SmallVectorImpl<Type*> &ArgTys); SmallVectorImpl<Type*> &ArgTys);
void VerifyParameterAttrs(Attributes Attrs, Type *Ty, void VerifyParameterAttrs(Attributes Attrs, Type *Ty,
bool isReturnValue, const Value *V); bool isReturnValue, const Value *V);
void VerifyFunctionAttrs(FunctionType *FT, const AttrListPtr &Attrs, void VerifyFunctionAttrs(FunctionType *FT, const AttributeSet &Attrs,
const Value *V); const Value *V);
void WriteValue(const Value *V) { void WriteValue(const Value *V) {
@ -585,7 +585,7 @@ void Verifier::VerifyParameterAttrs(Attributes Attrs, Type *Ty,
// VerifyFunctionAttrs - Check parameter attributes against a function type. // VerifyFunctionAttrs - Check parameter attributes against a function type.
// The value V is printed in error messages. // The value V is printed in error messages.
void Verifier::VerifyFunctionAttrs(FunctionType *FT, void Verifier::VerifyFunctionAttrs(FunctionType *FT,
const AttrListPtr &Attrs, const AttributeSet &Attrs,
const Value *V) { const Value *V) {
if (Attrs.isEmpty()) if (Attrs.isEmpty())
return; return;
@ -651,7 +651,7 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT,
"'noinline and alwaysinline' are incompatible!", V); "'noinline and alwaysinline' are incompatible!", V);
} }
static bool VerifyAttributeCount(const AttrListPtr &Attrs, unsigned Params) { static bool VerifyAttributeCount(const AttributeSet &Attrs, unsigned Params) {
if (Attrs.isEmpty()) if (Attrs.isEmpty())
return true; return true;
@ -687,7 +687,7 @@ void Verifier::visitFunction(Function &F) {
Assert1(!F.hasStructRetAttr() || F.getReturnType()->isVoidTy(), Assert1(!F.hasStructRetAttr() || F.getReturnType()->isVoidTy(),
"Invalid struct return type!", &F); "Invalid struct return type!", &F);
const AttrListPtr &Attrs = F.getAttributes(); const AttributeSet &Attrs = F.getAttributes();
Assert1(VerifyAttributeCount(Attrs, FT->getNumParams()), Assert1(VerifyAttributeCount(Attrs, FT->getNumParams()),
"Attributes after last parameter!", &F); "Attributes after last parameter!", &F);
@ -1200,7 +1200,7 @@ void Verifier::VerifyCallSite(CallSite CS) {
"Call parameter type does not match function signature!", "Call parameter type does not match function signature!",
CS.getArgument(i), FTy->getParamType(i), I); CS.getArgument(i), FTy->getParamType(i), I);
const AttrListPtr &Attrs = CS.getAttributes(); const AttributeSet &Attrs = CS.getAttributes();
Assert1(VerifyAttributeCount(Attrs, CS.arg_size()), Assert1(VerifyAttributeCount(Attrs, CS.arg_size()),
"Attributes after last parameter!", I); "Attributes after last parameter!", I);

View File

@ -431,7 +431,7 @@ namespace llvm {
/*Linkage=*/GlobalValue::ExternalLinkage, /*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"test1", mod); /*Name=*/"test1", mod);
func_test1->setCallingConv(CallingConv::C); func_test1->setCallingConv(CallingConv::C);
AttrListPtr func_test1_PAL; AttributeSet func_test1_PAL;
func_test1->setAttributes(func_test1_PAL); func_test1->setAttributes(func_test1_PAL);
Function* func_test2 = Function::Create( Function* func_test2 = Function::Create(
@ -439,7 +439,7 @@ namespace llvm {
/*Linkage=*/GlobalValue::ExternalLinkage, /*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"test2", mod); /*Name=*/"test2", mod);
func_test2->setCallingConv(CallingConv::C); func_test2->setCallingConv(CallingConv::C);
AttrListPtr func_test2_PAL; AttributeSet func_test2_PAL;
func_test2->setAttributes(func_test2_PAL); func_test2->setAttributes(func_test2_PAL);
Function* func_test3 = Function::Create( Function* func_test3 = Function::Create(
@ -447,7 +447,7 @@ namespace llvm {
/*Linkage=*/GlobalValue::ExternalLinkage, /*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"test3", mod); /*Name=*/"test3", mod);
func_test3->setCallingConv(CallingConv::C); func_test3->setCallingConv(CallingConv::C);
AttrListPtr func_test3_PAL; AttributeSet func_test3_PAL;
func_test3->setAttributes(func_test3_PAL); func_test3->setAttributes(func_test3_PAL);
Function* func_test4 = Function::Create( Function* func_test4 = Function::Create(
@ -455,7 +455,7 @@ namespace llvm {
/*Linkage=*/GlobalValue::ExternalLinkage, /*Linkage=*/GlobalValue::ExternalLinkage,
/*Name=*/"test4", mod); /*Name=*/"test4", mod);
func_test4->setCallingConv(CallingConv::C); func_test4->setCallingConv(CallingConv::C);
AttrListPtr func_test4_PAL; AttributeSet func_test4_PAL;
func_test4->setAttributes(func_test4_PAL); func_test4->setAttributes(func_test4_PAL);
// Global Variable Declarations // Global Variable Declarations
@ -475,7 +475,7 @@ namespace llvm {
// Block entry (label_entry) // Block entry (label_entry)
CallInst* int32_3 = CallInst::Create(func_test2, "", label_entry); CallInst* int32_3 = CallInst::Create(func_test2, "", label_entry);
int32_3->setCallingConv(CallingConv::C); int32_3->setCallingConv(CallingConv::C);
int32_3->setTailCall(false);AttrListPtr int32_3_PAL; int32_3->setTailCall(false);AttributeSet int32_3_PAL;
int32_3->setAttributes(int32_3_PAL); int32_3->setAttributes(int32_3_PAL);
ReturnInst::Create(getGlobalContext(), int32_3, label_entry); ReturnInst::Create(getGlobalContext(), int32_3, label_entry);
@ -490,7 +490,7 @@ namespace llvm {
// Block entry (label_entry_5) // Block entry (label_entry_5)
CallInst* int32_6 = CallInst::Create(func_test3, "", label_entry_5); CallInst* int32_6 = CallInst::Create(func_test3, "", label_entry_5);
int32_6->setCallingConv(CallingConv::C); int32_6->setCallingConv(CallingConv::C);
int32_6->setTailCall(false);AttrListPtr int32_6_PAL; int32_6->setTailCall(false);AttributeSet int32_6_PAL;
int32_6->setAttributes(int32_6_PAL); int32_6->setAttributes(int32_6_PAL);
ReturnInst::Create(getGlobalContext(), int32_6, label_entry_5); ReturnInst::Create(getGlobalContext(), int32_6, label_entry_5);
@ -505,7 +505,7 @@ namespace llvm {
// Block entry (label_entry_8) // Block entry (label_entry_8)
CallInst* int32_9 = CallInst::Create(func_test1, "", label_entry_8); CallInst* int32_9 = CallInst::Create(func_test1, "", label_entry_8);
int32_9->setCallingConv(CallingConv::C); int32_9->setCallingConv(CallingConv::C);
int32_9->setTailCall(false);AttrListPtr int32_9_PAL; int32_9->setTailCall(false);AttributeSet int32_9_PAL;
int32_9->setAttributes(int32_9_PAL); int32_9->setAttributes(int32_9_PAL);
ReturnInst::Create(getGlobalContext(), int32_9, label_entry_8); ReturnInst::Create(getGlobalContext(), int32_9, label_entry_8);

View File

@ -511,10 +511,10 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
OS << "// Add parameter attributes that are not common to all intrinsics.\n"; OS << "// Add parameter attributes that are not common to all intrinsics.\n";
OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n"; OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
if (TargetOnly) if (TargetOnly)
OS << "static AttrListPtr getAttributes(LLVMContext &C, " << TargetPrefix OS << "static AttributeSet getAttributes(LLVMContext &C, " << TargetPrefix
<< "Intrinsic::ID id) {\n"; << "Intrinsic::ID id) {\n";
else else
OS << "AttrListPtr Intrinsic::getAttributes(LLVMContext &C, ID id) {\n"; OS << "AttributeSet Intrinsic::getAttributes(LLVMContext &C, ID id) {\n";
// Compute the maximum number of attribute arguments and the map // Compute the maximum number of attribute arguments and the map
typedef std::map<const CodeGenIntrinsic*, unsigned, typedef std::map<const CodeGenIntrinsic*, unsigned,
@ -608,20 +608,20 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
break; break;
} }
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, " OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, "
<< "AttrListPtr::FunctionIndex, AttrVec);\n"; << "AttributeSet::FunctionIndex, AttrVec);\n";
} }
if (numAttrs) { if (numAttrs) {
OS << " NumAttrs = " << numAttrs << ";\n"; OS << " NumAttrs = " << numAttrs << ";\n";
OS << " break;\n"; OS << " break;\n";
} else { } else {
OS << " return AttrListPtr();\n"; OS << " return AttributeSet();\n";
} }
} }
OS << " }\n"; OS << " }\n";
OS << " }\n"; OS << " }\n";
OS << " return AttrListPtr::get(C, ArrayRef<AttributeWithIndex>(AWI, " OS << " return AttributeSet::get(C, ArrayRef<AttributeWithIndex>(AWI, "
"NumAttrs));\n"; "NumAttrs));\n";
OS << "}\n"; OS << "}\n";
OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n"; OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n";