forked from OSchip/llvm-project
Attributes Rewrite
Convert the internal representation of the Attributes class into a pointer to an opaque object that's uniqued by and stored in the LLVMContext object. The Attributes class then becomes a thin wrapper around this opaque object. Eventually, the internal representation will be expanded to include attributes that represent code generation options, etc. llvm-svn: 165917
This commit is contained in:
parent
40b6fac36c
commit
d079a446d7
|
@ -89,13 +89,12 @@ public:
|
||||||
ZExt = 27 ///< Zero extended before/after call
|
ZExt = 27 ///< Zero extended before/after call
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
AttributesImpl Attrs;
|
AttributesImpl *Attrs;
|
||||||
|
|
||||||
explicit Attributes(AttributesImpl *A);
|
explicit Attributes(AttributesImpl *A);
|
||||||
public:
|
public:
|
||||||
Attributes() : Attrs(0) {}
|
Attributes() : Attrs(0) {}
|
||||||
explicit Attributes(uint64_t Val);
|
explicit Attributes(LLVMContext &C, ArrayRef<AttrVal> Vals);
|
||||||
explicit Attributes(LLVMContext &C, AttrVal Val);
|
|
||||||
Attributes(const Attributes &A);
|
Attributes(const Attributes &A);
|
||||||
|
|
||||||
class Builder {
|
class Builder {
|
||||||
|
@ -105,6 +104,7 @@ public:
|
||||||
Builder() : Bits(0) {}
|
Builder() : Bits(0) {}
|
||||||
explicit Builder(uint64_t B) : Bits(B) {}
|
explicit Builder(uint64_t B) : Bits(B) {}
|
||||||
Builder(const Attributes &A) : Bits(A.Raw()) {}
|
Builder(const Attributes &A) : Bits(A.Raw()) {}
|
||||||
|
Builder(const Builder &B) : Bits(B.Bits) {}
|
||||||
|
|
||||||
void clear() { Bits = 0; }
|
void clear() { Bits = 0; }
|
||||||
|
|
||||||
|
@ -166,7 +166,6 @@ public:
|
||||||
|
|
||||||
/// get - Return a uniquified Attributes object. This takes the uniquified
|
/// get - Return a uniquified Attributes object. This takes the uniquified
|
||||||
/// value from the Builder and wraps it in the Attributes class.
|
/// value from the Builder and wraps it in the Attributes class.
|
||||||
static Attributes get(Builder &B);
|
|
||||||
static Attributes get(LLVMContext &Context, Builder &B);
|
static Attributes get(LLVMContext &Context, Builder &B);
|
||||||
|
|
||||||
/// @brief Return true if the attribute is present.
|
/// @brief Return true if the attribute is present.
|
||||||
|
@ -174,7 +173,7 @@ public:
|
||||||
|
|
||||||
/// @brief Return true if attributes exist
|
/// @brief Return true if attributes exist
|
||||||
bool hasAttributes() const {
|
bool hasAttributes() const {
|
||||||
return Attrs.hasAttributes();
|
return Attrs && Attrs->hasAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Return true if the attributes are a non-null intersection.
|
/// @brief Return true if the attributes are a non-null intersection.
|
||||||
|
@ -225,10 +224,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const Attributes &A) const {
|
bool operator == (const Attributes &A) const {
|
||||||
return Attrs.Bits == A.Attrs.Bits;
|
return Attrs == A.Attrs;
|
||||||
}
|
}
|
||||||
bool operator != (const Attributes &A) const {
|
bool operator != (const Attributes &A) const {
|
||||||
return Attrs.Bits != A.Attrs.Bits;
|
return Attrs != A.Attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Raw() const;
|
uint64_t Raw() const;
|
||||||
|
@ -261,7 +260,8 @@ public:
|
||||||
/// containing the LLVM attributes that have been decoded from the given
|
/// containing the LLVM attributes that have been decoded from the given
|
||||||
/// integer. This function must stay in sync with
|
/// integer. This function must stay in sync with
|
||||||
/// 'encodeLLVMAttributesForBitcode'.
|
/// 'encodeLLVMAttributesForBitcode'.
|
||||||
static Attributes decodeLLVMAttributesForBitcode(uint64_t EncodedAttrs) {
|
static Attributes decodeLLVMAttributesForBitcode(LLVMContext &C,
|
||||||
|
uint64_t EncodedAttrs) {
|
||||||
// The alignment is stored as a 16-bit raw value from bits 31--16. We shift
|
// The alignment is stored as a 16-bit raw value from bits 31--16. We shift
|
||||||
// the bits above 31 down by 11 bits.
|
// the bits above 31 down by 11 bits.
|
||||||
unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
|
unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
|
||||||
|
@ -272,7 +272,7 @@ public:
|
||||||
if (Alignment)
|
if (Alignment)
|
||||||
B.addAlignmentAttr(Alignment);
|
B.addAlignmentAttr(Alignment);
|
||||||
B.addRawValue((EncodedAttrs & (0xfffULL << 32)) >> 11);
|
B.addRawValue((EncodedAttrs & (0xfffULL << 32)) >> 11);
|
||||||
return Attributes::get(B);
|
return Attributes::get(C, B);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getAsString - The set of Attributes set in Attributes is converted to a
|
/// getAsString - The set of Attributes set in Attributes is converted to a
|
||||||
|
@ -294,7 +294,7 @@ struct AttributeWithIndex {
|
||||||
///< Index 0 is used for return value attributes.
|
///< Index 0 is used for return value attributes.
|
||||||
///< Index ~0U is used for function attributes.
|
///< Index ~0U is used for function attributes.
|
||||||
|
|
||||||
static AttributeWithIndex get(unsigned Idx,
|
static AttributeWithIndex get(LLVMContext &C, unsigned Idx,
|
||||||
ArrayRef<Attributes::AttrVal> Attrs) {
|
ArrayRef<Attributes::AttrVal> Attrs) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ struct AttributeWithIndex {
|
||||||
|
|
||||||
AttributeWithIndex P;
|
AttributeWithIndex P;
|
||||||
P.Index = Idx;
|
P.Index = Idx;
|
||||||
P.Attrs = Attributes::get(B);
|
P.Attrs = Attributes::get(C, B);
|
||||||
return P;
|
return P;
|
||||||
}
|
}
|
||||||
static AttributeWithIndex get(unsigned Idx, Attributes Attrs) {
|
static AttributeWithIndex get(unsigned Idx, Attributes Attrs) {
|
||||||
|
|
|
@ -180,7 +180,7 @@ public:
|
||||||
// Function Attributes are stored at ~0 index
|
// Function Attributes are stored at ~0 index
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(N);
|
B.addAttribute(N);
|
||||||
addAttribute(~0U, Attributes::get(B));
|
addAttribute(~0U, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// removeFnAttr - Remove function attributes from this function.
|
/// removeFnAttr - Remove function attributes from this function.
|
||||||
|
@ -280,7 +280,7 @@ public:
|
||||||
void setDoesNotAlias(unsigned n) {
|
void setDoesNotAlias(unsigned n) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoAlias);
|
B.addAttribute(Attributes::NoAlias);
|
||||||
addAttribute(n, Attributes::get(B));
|
addAttribute(n, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the parameter can be captured.
|
/// @brief Determine if the parameter can be captured.
|
||||||
|
@ -291,7 +291,7 @@ public:
|
||||||
void setDoesNotCapture(unsigned n) {
|
void setDoesNotCapture(unsigned n) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoCapture);
|
B.addAttribute(Attributes::NoCapture);
|
||||||
addAttribute(n, Attributes::get(B));
|
addAttribute(n, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// copyAttributesFrom - copy all additional attributes (those not needed to
|
/// copyAttributesFrom - copy all additional attributes (those not needed to
|
||||||
|
|
|
@ -1274,7 +1274,7 @@ public:
|
||||||
void setIsNoInline() {
|
void setIsNoInline() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoInline);
|
B.addAttribute(Attributes::NoInline);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Return true if the call can return twice
|
/// @brief Return true if the call can return twice
|
||||||
|
@ -1284,7 +1284,7 @@ public:
|
||||||
void setCanReturnTwice() {
|
void setCanReturnTwice() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReturnsTwice);
|
B.addAttribute(Attributes::ReturnsTwice);
|
||||||
addAttribute(~0U, Attributes::get(B));
|
addAttribute(~0U, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access memory.
|
/// @brief Determine if the call does not access memory.
|
||||||
|
@ -1294,7 +1294,7 @@ public:
|
||||||
void setDoesNotAccessMemory() {
|
void setDoesNotAccessMemory() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadNone);
|
B.addAttribute(Attributes::ReadNone);
|
||||||
addAttribute(~0U, Attributes::get(B));
|
addAttribute(~0U, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access or only reads memory.
|
/// @brief Determine if the call does not access or only reads memory.
|
||||||
|
@ -1304,7 +1304,7 @@ public:
|
||||||
void setOnlyReadsMemory() {
|
void setOnlyReadsMemory() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadOnly);
|
B.addAttribute(Attributes::ReadOnly);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot return.
|
/// @brief Determine if the call cannot return.
|
||||||
|
@ -1312,7 +1312,7 @@ public:
|
||||||
void setDoesNotReturn() {
|
void setDoesNotReturn() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoReturn);
|
B.addAttribute(Attributes::NoReturn);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot unwind.
|
/// @brief Determine if the call cannot unwind.
|
||||||
|
@ -1320,7 +1320,7 @@ public:
|
||||||
void setDoesNotThrow() {
|
void setDoesNotThrow() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call returns a structure through first
|
/// @brief Determine if the call returns a structure through first
|
||||||
|
@ -3029,7 +3029,7 @@ public:
|
||||||
void setIsNoInline() {
|
void setIsNoInline() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoInline);
|
B.addAttribute(Attributes::NoInline);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access memory.
|
/// @brief Determine if the call does not access memory.
|
||||||
|
@ -3039,7 +3039,7 @@ public:
|
||||||
void setDoesNotAccessMemory() {
|
void setDoesNotAccessMemory() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadNone);
|
B.addAttribute(Attributes::ReadNone);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access or only reads memory.
|
/// @brief Determine if the call does not access or only reads memory.
|
||||||
|
@ -3049,7 +3049,7 @@ public:
|
||||||
void setOnlyReadsMemory() {
|
void setOnlyReadsMemory() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadOnly);
|
B.addAttribute(Attributes::ReadOnly);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot return.
|
/// @brief Determine if the call cannot return.
|
||||||
|
@ -3057,7 +3057,7 @@ public:
|
||||||
void setDoesNotReturn() {
|
void setDoesNotReturn() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoReturn);
|
B.addAttribute(Attributes::NoReturn);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot unwind.
|
/// @brief Determine if the call cannot unwind.
|
||||||
|
@ -3065,7 +3065,7 @@ public:
|
||||||
void setDoesNotThrow() {
|
void setDoesNotThrow() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
addAttribute(~0, Attributes::get(B));
|
addAttribute(~0, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call returns a structure through first
|
/// @brief Determine if the call returns a structure through first
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Intrinsic {
|
||||||
/// Intrinsic::getType(ID) - Return the function type for an intrinsic.
|
/// Intrinsic::getType(ID) - Return the function type for an intrinsic.
|
||||||
///
|
///
|
||||||
FunctionType *getType(LLVMContext &Context, ID id,
|
FunctionType *getType(LLVMContext &Context, ID id,
|
||||||
ArrayRef<Type*> Tys = ArrayRef<Type*>());
|
ArrayRef<Type*> Tys = ArrayRef<Type*>());
|
||||||
|
|
||||||
/// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be
|
/// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be
|
||||||
/// overloaded.
|
/// overloaded.
|
||||||
|
@ -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(ID id);
|
AttrListPtr 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.
|
||||||
|
|
|
@ -1443,7 +1443,8 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
|
||||||
// Otherwise, handle normal operands.
|
// Otherwise, handle normal operands.
|
||||||
if (ParseOptionalAttrs(ArgAttrs, 0) || ParseValue(ArgTy, V, PFS))
|
if (ParseOptionalAttrs(ArgAttrs, 0) || ParseValue(ArgTy, V, PFS))
|
||||||
return true;
|
return true;
|
||||||
ArgList.push_back(ParamInfo(ArgLoc, V, Attributes::get(ArgAttrs)));
|
ArgList.push_back(ParamInfo(ArgLoc, V, Attributes::get(V->getContext(),
|
||||||
|
ArgAttrs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Lex.Lex(); // Lex the ')'.
|
Lex.Lex(); // Lex the ')'.
|
||||||
|
@ -1492,7 +1493,9 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
|
||||||
if (!FunctionType::isValidArgumentType(ArgTy))
|
if (!FunctionType::isValidArgumentType(ArgTy))
|
||||||
return Error(TypeLoc, "invalid type for function argument");
|
return Error(TypeLoc, "invalid type for function argument");
|
||||||
|
|
||||||
ArgList.push_back(ArgInfo(TypeLoc, ArgTy, Attributes::get(Attrs), Name));
|
ArgList.push_back(ArgInfo(TypeLoc, ArgTy,
|
||||||
|
Attributes::get(ArgTy->getContext(),
|
||||||
|
Attrs), Name));
|
||||||
|
|
||||||
while (EatIfPresent(lltok::comma)) {
|
while (EatIfPresent(lltok::comma)) {
|
||||||
// Handle ... at end of arg list.
|
// Handle ... at end of arg list.
|
||||||
|
@ -1518,7 +1521,9 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
|
||||||
if (!ArgTy->isFirstClassType())
|
if (!ArgTy->isFirstClassType())
|
||||||
return Error(TypeLoc, "invalid type for function argument");
|
return Error(TypeLoc, "invalid type for function argument");
|
||||||
|
|
||||||
ArgList.push_back(ArgInfo(TypeLoc, ArgTy, Attributes::get(Attrs), Name));
|
ArgList.push_back(ArgInfo(TypeLoc, ArgTy,
|
||||||
|
Attributes::get(ArgTy->getContext(), Attrs),
|
||||||
|
Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2766,7 +2771,9 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||||
SmallVector<AttributeWithIndex, 8> Attrs;
|
SmallVector<AttributeWithIndex, 8> Attrs;
|
||||||
|
|
||||||
if (RetAttrs.hasAttributes())
|
if (RetAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(0, Attributes::get(RetAttrs)));
|
Attrs.push_back(AttributeWithIndex::get(0,
|
||||||
|
Attributes::get(RetType->getContext(),
|
||||||
|
RetAttrs)));
|
||||||
|
|
||||||
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
|
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
|
||||||
ParamTypeList.push_back(ArgList[i].Ty);
|
ParamTypeList.push_back(ArgList[i].Ty);
|
||||||
|
@ -2775,7 +2782,9 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FuncAttrs.hasAttributes())
|
if (FuncAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(~0, Attributes::get(FuncAttrs)));
|
Attrs.push_back(AttributeWithIndex::get(~0,
|
||||||
|
Attributes::get(RetType->getContext(),
|
||||||
|
FuncAttrs)));
|
||||||
|
|
||||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||||
|
|
||||||
|
@ -3297,7 +3306,9 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
|
||||||
// Set up the Attributes for the function.
|
// Set up the Attributes for the function.
|
||||||
SmallVector<AttributeWithIndex, 8> Attrs;
|
SmallVector<AttributeWithIndex, 8> Attrs;
|
||||||
if (RetAttrs.hasAttributes())
|
if (RetAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(0, Attributes::get(RetAttrs)));
|
Attrs.push_back(AttributeWithIndex::get(0,
|
||||||
|
Attributes::get(Callee->getContext(),
|
||||||
|
RetAttrs)));
|
||||||
|
|
||||||
SmallVector<Value*, 8> Args;
|
SmallVector<Value*, 8> Args;
|
||||||
|
|
||||||
|
@ -3325,7 +3336,9 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
|
||||||
return Error(CallLoc, "not enough parameters specified for call");
|
return Error(CallLoc, "not enough parameters specified for call");
|
||||||
|
|
||||||
if (FnAttrs.hasAttributes())
|
if (FnAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(~0, Attributes::get(FnAttrs)));
|
Attrs.push_back(AttributeWithIndex::get(~0,
|
||||||
|
Attributes::get(Callee->getContext(),
|
||||||
|
FnAttrs)));
|
||||||
|
|
||||||
// Finish off the Attributes and check them
|
// Finish off the Attributes and check them
|
||||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||||
|
@ -3693,7 +3706,9 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
||||||
// Set up the Attributes for the function.
|
// Set up the Attributes for the function.
|
||||||
SmallVector<AttributeWithIndex, 8> Attrs;
|
SmallVector<AttributeWithIndex, 8> Attrs;
|
||||||
if (RetAttrs.hasAttributes())
|
if (RetAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(0, Attributes::get(RetAttrs)));
|
Attrs.push_back(AttributeWithIndex::get(0,
|
||||||
|
Attributes::get(Callee->getContext(),
|
||||||
|
RetAttrs)));
|
||||||
|
|
||||||
SmallVector<Value*, 8> Args;
|
SmallVector<Value*, 8> Args;
|
||||||
|
|
||||||
|
@ -3721,7 +3736,9 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
||||||
return Error(CallLoc, "not enough parameters specified for call");
|
return Error(CallLoc, "not enough parameters specified for call");
|
||||||
|
|
||||||
if (FnAttrs.hasAttributes())
|
if (FnAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(~0, Attributes::get(FnAttrs)));
|
Attrs.push_back(AttributeWithIndex::get(~0,
|
||||||
|
Attributes::get(Callee->getContext(),
|
||||||
|
FnAttrs)));
|
||||||
|
|
||||||
// Finish off the Attributes and check them
|
// Finish off the Attributes and check them
|
||||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||||
|
|
|
@ -476,14 +476,15 @@ bool BitcodeReader::ParseAttributeBlock() {
|
||||||
|
|
||||||
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
||||||
Attributes ReconstitutedAttr =
|
Attributes ReconstitutedAttr =
|
||||||
Attributes::decodeLLVMAttributesForBitcode(Record[i+1]);
|
Attributes::decodeLLVMAttributesForBitcode(Context, Record[i+1]);
|
||||||
Record[i+1] = ReconstitutedAttr.Raw();
|
Record[i+1] = ReconstitutedAttr.Raw();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
||||||
if (Attributes(Record[i+1]).hasAttributes())
|
Attributes::Builder B(Record[i+1]);
|
||||||
|
if (B.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(Record[i],
|
Attrs.push_back(AttributeWithIndex::get(Record[i],
|
||||||
Attributes(Record[i+1])));
|
Attributes::get(Context, B)));
|
||||||
}
|
}
|
||||||
|
|
||||||
MAttributes.push_back(AttrListPtr::get(Attrs));
|
MAttributes.push_back(AttrListPtr::get(Attrs));
|
||||||
|
|
|
@ -83,7 +83,7 @@ bool MBlazeIntrinsicInfo::isOverloaded(unsigned IntrID) const {
|
||||||
#undef GET_INTRINSIC_OVERLOAD_TABLE
|
#undef GET_INTRINSIC_OVERLOAD_TABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This defines the "getAttributes(ID id)" method.
|
/// This defines the "getAttributes(LLVMContext &C, ID id)" method.
|
||||||
#define GET_INTRINSIC_ATTRIBUTES
|
#define GET_INTRINSIC_ATTRIBUTES
|
||||||
#include "MBlazeGenIntrinsics.inc"
|
#include "MBlazeGenIntrinsics.inc"
|
||||||
#undef GET_INTRINSIC_ATTRIBUTES
|
#undef GET_INTRINSIC_ATTRIBUTES
|
||||||
|
@ -104,7 +104,8 @@ 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((mblazeIntrinsic::ID) IntrID);
|
AttrListPtr AList = getAttributes(M->getContext(),
|
||||||
|
(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),
|
||||||
AList));
|
AList));
|
||||||
|
|
|
@ -764,7 +764,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
||||||
// required when new return value attributes are added.
|
// required when new return value attributes are added.
|
||||||
if (NRetTy->isVoidTy())
|
if (NRetTy->isVoidTy())
|
||||||
RAttrs =
|
RAttrs =
|
||||||
Attributes::get(Attributes::Builder(RAttrs).
|
Attributes::get(NRetTy->getContext(), Attributes::Builder(RAttrs).
|
||||||
removeAttributes(Attributes::typeIncompatible(NRetTy)));
|
removeAttributes(Attributes::typeIncompatible(NRetTy)));
|
||||||
else
|
else
|
||||||
assert(!Attributes::Builder(RAttrs).
|
assert(!Attributes::Builder(RAttrs).
|
||||||
|
@ -837,7 +837,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
||||||
Attributes FnAttrs = CallPAL.getFnAttributes();
|
Attributes FnAttrs = CallPAL.getFnAttributes();
|
||||||
// Adjust in case the function was changed to return void.
|
// Adjust in case the function was changed to return void.
|
||||||
RAttrs =
|
RAttrs =
|
||||||
Attributes::get(Attributes::Builder(RAttrs).
|
Attributes::get(NF->getContext(), Attributes::Builder(RAttrs).
|
||||||
removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
|
removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
|
||||||
if (RAttrs.hasAttributes())
|
if (RAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
|
||||||
|
|
|
@ -215,12 +215,12 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadOnly)
|
B.addAttribute(Attributes::ReadOnly)
|
||||||
.addAttribute(Attributes::ReadNone);
|
.addAttribute(Attributes::ReadNone);
|
||||||
F->removeAttribute(~0, Attributes::get(B));
|
F->removeAttribute(~0, 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(~0, Attributes::get(B));
|
F->addAttribute(~0, Attributes::get(F->getContext(), B));
|
||||||
|
|
||||||
if (ReadsMemory)
|
if (ReadsMemory)
|
||||||
++NumReadOnly;
|
++NumReadOnly;
|
||||||
|
@ -379,7 +379,7 @@ bool FunctionAttrs::AddNoCaptureAttrs(const CallGraphSCC &SCC) {
|
||||||
for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end();
|
for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end();
|
||||||
A != E; ++A) {
|
A != E; ++A) {
|
||||||
if (A->getType()->isPointerTy() && !A->hasNoCaptureAttr()) {
|
if (A->getType()->isPointerTy() && !A->hasNoCaptureAttr()) {
|
||||||
A->addAttr(Attributes::get(B));
|
A->addAttr(Attributes::get(F->getContext(), B));
|
||||||
++NumNoCapture;
|
++NumNoCapture;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ bool FunctionAttrs::AddNoCaptureAttrs(const CallGraphSCC &SCC) {
|
||||||
if (!Tracker.Captured) {
|
if (!Tracker.Captured) {
|
||||||
if (Tracker.Uses.empty()) {
|
if (Tracker.Uses.empty()) {
|
||||||
// If it's trivially not captured, mark it nocapture now.
|
// If it's trivially not captured, mark it nocapture now.
|
||||||
A->addAttr(Attributes::get(B));
|
A->addAttr(Attributes::get(F->getContext(), B));
|
||||||
++NumNoCapture;
|
++NumNoCapture;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -427,7 +427,9 @@ bool FunctionAttrs::AddNoCaptureAttrs(const CallGraphSCC &SCC) {
|
||||||
// eg. "void f(int* x) { if (...) f(x); }"
|
// eg. "void f(int* x) { if (...) f(x); }"
|
||||||
if (ArgumentSCC[0]->Uses.size() == 1 &&
|
if (ArgumentSCC[0]->Uses.size() == 1 &&
|
||||||
ArgumentSCC[0]->Uses[0] == ArgumentSCC[0]) {
|
ArgumentSCC[0]->Uses[0] == ArgumentSCC[0]) {
|
||||||
ArgumentSCC[0]->Definition->addAttr(Attributes::get(B));
|
ArgumentSCC[0]->
|
||||||
|
Definition->
|
||||||
|
addAttr(Attributes::get(ArgumentSCC[0]->Definition->getContext(), B));
|
||||||
++NumNoCapture;
|
++NumNoCapture;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
@ -469,7 +471,7 @@ bool FunctionAttrs::AddNoCaptureAttrs(const CallGraphSCC &SCC) {
|
||||||
|
|
||||||
for (unsigned i = 0, e = ArgumentSCC.size(); i != e; ++i) {
|
for (unsigned i = 0, e = ArgumentSCC.size(); i != e; ++i) {
|
||||||
Argument *A = ArgumentSCC[i]->Definition;
|
Argument *A = ArgumentSCC[i]->Definition;
|
||||||
A->addAttr(Attributes::get(B));
|
A->addAttr(Attributes::get(A->getContext(), B));
|
||||||
++NumNoCapture;
|
++NumNoCapture;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2070,7 +2070,7 @@ static AttrListPtr StripNest(LLVMContext &C, const AttrListPtr &Attrs) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// There can be only one.
|
// There can be only one.
|
||||||
return Attrs.removeAttr(C, Attrs.getSlot(i).Index, Attributes::get(B));
|
return Attrs.removeAttr(C, Attrs.getSlot(i).Index, Attributes::get(C, B));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Attrs;
|
return Attrs;
|
||||||
|
|
|
@ -147,7 +147,8 @@ bool PruneEH::runOnSCC(CallGraphSCC &SCC) {
|
||||||
Function *F = (*I)->getFunction();
|
Function *F = (*I)->getFunction();
|
||||||
const AttrListPtr &PAL = F->getAttributes();
|
const AttrListPtr &PAL = F->getAttributes();
|
||||||
const AttrListPtr &NPAL = PAL.addAttr(F->getContext(), ~0,
|
const AttrListPtr &NPAL = PAL.addAttr(F->getContext(), ~0,
|
||||||
Attributes::get(NewAttributes));
|
Attributes::get(F->getContext(),
|
||||||
|
NewAttributes));
|
||||||
if (PAL != NPAL) {
|
if (PAL != NPAL) {
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
F->setAttributes(NPAL);
|
F->setAttributes(NPAL);
|
||||||
|
|
|
@ -1117,7 +1117,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
||||||
|
|
||||||
// Add the new return attributes.
|
// Add the new return attributes.
|
||||||
if (RAttrs.hasAttributes())
|
if (RAttrs.hasAttributes())
|
||||||
attrVec.push_back(AttributeWithIndex::get(0, Attributes::get(RAttrs)));
|
attrVec.push_back(
|
||||||
|
AttributeWithIndex::get(0, Attributes::get(FT->getContext(), RAttrs)));
|
||||||
|
|
||||||
AI = CS.arg_begin();
|
AI = CS.arg_begin();
|
||||||
for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
|
for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
|
||||||
|
|
|
@ -1791,7 +1791,7 @@ Constant *ObjCARCOpt::getRetainRVCallee(Module *M) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
||||||
Attributes::get(B));
|
Attributes::get(M->getContext(), B));
|
||||||
RetainRVCallee =
|
RetainRVCallee =
|
||||||
M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy,
|
M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy,
|
||||||
Attributes);
|
Attributes);
|
||||||
|
@ -1808,7 +1808,7 @@ Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
||||||
Attributes::get(B));
|
Attributes::get(C, B));
|
||||||
AutoreleaseRVCallee =
|
AutoreleaseRVCallee =
|
||||||
M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy,
|
M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy,
|
||||||
Attributes);
|
Attributes);
|
||||||
|
@ -1823,7 +1823,7 @@ Constant *ObjCARCOpt::getReleaseCallee(Module *M) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
||||||
Attributes::get(B));
|
Attributes::get(C, B));
|
||||||
ReleaseCallee =
|
ReleaseCallee =
|
||||||
M->getOrInsertFunction(
|
M->getOrInsertFunction(
|
||||||
"objc_release",
|
"objc_release",
|
||||||
|
@ -1840,7 +1840,7 @@ Constant *ObjCARCOpt::getRetainCallee(Module *M) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
||||||
Attributes::get(B));
|
Attributes::get(C, B));
|
||||||
RetainCallee =
|
RetainCallee =
|
||||||
M->getOrInsertFunction(
|
M->getOrInsertFunction(
|
||||||
"objc_retain",
|
"objc_retain",
|
||||||
|
@ -1872,7 +1872,7 @@ Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
||||||
Attributes::get(B));
|
Attributes::get(C, B));
|
||||||
AutoreleaseCallee =
|
AutoreleaseCallee =
|
||||||
M->getOrInsertFunction(
|
M->getOrInsertFunction(
|
||||||
"objc_autorelease",
|
"objc_autorelease",
|
||||||
|
@ -3850,8 +3850,8 @@ Constant *ObjCARCContract::getStoreStrongCallee(Module *M) {
|
||||||
Attributes::Builder BNoCapture;
|
Attributes::Builder BNoCapture;
|
||||||
BNoCapture.addAttribute(Attributes::NoCapture);
|
BNoCapture.addAttribute(Attributes::NoCapture);
|
||||||
AttrListPtr Attributes = AttrListPtr()
|
AttrListPtr Attributes = AttrListPtr()
|
||||||
.addAttr(M->getContext(), ~0u, Attributes::get(BNoUnwind))
|
.addAttr(M->getContext(), ~0u, Attributes::get(C, BNoUnwind))
|
||||||
.addAttr(M->getContext(), 1, Attributes::get(BNoCapture));
|
.addAttr(M->getContext(), 1, Attributes::get(C, BNoCapture));
|
||||||
|
|
||||||
StoreStrongCallee =
|
StoreStrongCallee =
|
||||||
M->getOrInsertFunction(
|
M->getOrInsertFunction(
|
||||||
|
@ -3871,7 +3871,7 @@ Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
||||||
Attributes::get(B));
|
Attributes::get(C, B));
|
||||||
RetainAutoreleaseCallee =
|
RetainAutoreleaseCallee =
|
||||||
M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes);
|
M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes);
|
||||||
}
|
}
|
||||||
|
@ -3887,7 +3887,7 @@ Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
||||||
Attributes::get(B));
|
Attributes::get(C, B));
|
||||||
RetainAutoreleaseRVCallee =
|
RetainAutoreleaseRVCallee =
|
||||||
M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy,
|
M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy,
|
||||||
Attributes);
|
Attributes);
|
||||||
|
|
|
@ -350,7 +350,7 @@ struct StrToOpt : public LibCallOptimization {
|
||||||
// It would be readonly too, except that it still may write to errno.
|
// It would be readonly too, except that it still may write to errno.
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoCapture);
|
B.addAttribute(Attributes::NoCapture);
|
||||||
CI->addAttribute(1, Attributes::get(B));
|
CI->addAttribute(1, Attributes::get(Callee->getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -41,9 +41,10 @@ Value *llvm::EmitStrLen(Value *Ptr, 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(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(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u,
|
||||||
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
Constant *StrLen = M->getOrInsertFunction("strlen", AttrListPtr::get(AWI),
|
Constant *StrLen = M->getOrInsertFunction("strlen", AttrListPtr::get(AWI),
|
||||||
|
@ -67,9 +68,10 @@ Value *llvm::EmitStrNLen(Value *Ptr, Value *MaxLen, IRBuilder<> &B,
|
||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[2];
|
AttributeWithIndex AWI[2];
|
||||||
AWI[0] = AttributeWithIndex::get(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(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u,
|
||||||
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
Constant *StrNLen = M->getOrInsertFunction("strnlen", AttrListPtr::get(AWI),
|
Constant *StrNLen = M->getOrInsertFunction("strnlen", AttrListPtr::get(AWI),
|
||||||
|
@ -95,7 +97,8 @@ 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(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
AttributeWithIndex::get(M->getContext(), ~0u,
|
||||||
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
Type *I8Ptr = B.getInt8PtrTy();
|
Type *I8Ptr = B.getInt8PtrTy();
|
||||||
Type *I32Ty = B.getInt32Ty();
|
Type *I32Ty = B.getInt32Ty();
|
||||||
|
@ -117,10 +120,11 @@ Value *llvm::EmitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len,
|
||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[3];
|
AttributeWithIndex AWI[3];
|
||||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(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(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u,
|
||||||
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
Value *StrNCmp = M->getOrInsertFunction("strncmp", AttrListPtr::get(AWI),
|
Value *StrNCmp = M->getOrInsertFunction("strncmp", AttrListPtr::get(AWI),
|
||||||
|
@ -147,8 +151,8 @@ 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(2, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
||||||
Type *I8Ptr = B.getInt8PtrTy();
|
Type *I8Ptr = B.getInt8PtrTy();
|
||||||
Value *StrCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
Value *StrCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
||||||
I8Ptr, I8Ptr, I8Ptr, NULL);
|
I8Ptr, I8Ptr, I8Ptr, NULL);
|
||||||
|
@ -169,8 +173,8 @@ 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(2, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
||||||
Type *I8Ptr = B.getInt8PtrTy();
|
Type *I8Ptr = B.getInt8PtrTy();
|
||||||
Value *StrNCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
Value *StrNCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
||||||
I8Ptr, I8Ptr, I8Ptr,
|
I8Ptr, I8Ptr, I8Ptr,
|
||||||
|
@ -193,7 +197,7 @@ 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(~0u, Attributes::NoUnwind);
|
AWI = AttributeWithIndex::get(M->getContext(), ~0u, 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(AWI),
|
AttrListPtr::get(AWI),
|
||||||
|
@ -221,7 +225,8 @@ 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(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
AWI = AttributeWithIndex::get(M->getContext(), ~0u,
|
||||||
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(AWI),
|
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(AWI),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
|
@ -246,10 +251,11 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
|
||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[3];
|
AttributeWithIndex AWI[3];
|
||||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(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(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u,
|
||||||
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI),
|
Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI),
|
||||||
|
@ -325,8 +331,8 @@ 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(1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
||||||
|
|
||||||
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI),
|
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI),
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
|
@ -347,8 +353,8 @@ 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(2, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
||||||
Constant *F;
|
Constant *F;
|
||||||
if (File->getType()->isPointerTy())
|
if (File->getType()->isPointerTy())
|
||||||
F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI),
|
F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI),
|
||||||
|
@ -378,9 +384,9 @@ Value *llvm::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B,
|
||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[3];
|
AttributeWithIndex AWI[3];
|
||||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(2, Attributes::NoCapture);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
AWI[2] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u, 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())
|
||||||
|
@ -409,9 +415,9 @@ Value *llvm::EmitFWrite(Value *Ptr, Value *Size, Value *File,
|
||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[3];
|
AttributeWithIndex AWI[3];
|
||||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(4, Attributes::NoCapture);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attributes::NoCapture);
|
||||||
AWI[2] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u, 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;
|
||||||
|
|
|
@ -27,21 +27,18 @@ using namespace llvm;
|
||||||
// Attributes Implementation
|
// Attributes Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
Attributes::Attributes(uint64_t Val) : Attrs(Val) {}
|
Attributes::Attributes(LLVMContext &C, ArrayRef<AttrVal> Vals) {
|
||||||
|
Attributes::Builder B;
|
||||||
|
for (ArrayRef<AttrVal>::iterator I = Vals.begin(), E = Vals.end();
|
||||||
|
I != E; ++I)
|
||||||
|
B.addAttribute(*I);
|
||||||
|
Attrs = Attributes::get(C, B).Attrs;
|
||||||
|
}
|
||||||
|
|
||||||
Attributes::Attributes(LLVMContext &C, AttrVal Val)
|
Attributes::Attributes(AttributesImpl *A) : Attrs(A) {}
|
||||||
: Attrs(Attributes::get(Attributes::Builder().addAttribute(Val)).Attrs) {}
|
|
||||||
|
|
||||||
Attributes::Attributes(AttributesImpl *A) : Attrs(A->Bits) {}
|
|
||||||
|
|
||||||
Attributes::Attributes(const Attributes &A) : Attrs(A.Attrs) {}
|
Attributes::Attributes(const Attributes &A) : Attrs(A.Attrs) {}
|
||||||
|
|
||||||
// FIXME: This is temporary until we have implemented the uniquified version of
|
|
||||||
// AttributesImpl.
|
|
||||||
Attributes Attributes::get(Attributes::Builder &B) {
|
|
||||||
return Attributes(B.Bits);
|
|
||||||
}
|
|
||||||
|
|
||||||
Attributes Attributes::get(LLVMContext &Context, Attributes::Builder &B) {
|
Attributes Attributes::get(LLVMContext &Context, Attributes::Builder &B) {
|
||||||
// If there are no attributes, return an empty Attributes class.
|
// If there are no attributes, return an empty Attributes class.
|
||||||
if (B.Bits == 0)
|
if (B.Bits == 0)
|
||||||
|
@ -67,18 +64,18 @@ Attributes Attributes::get(LLVMContext &Context, Attributes::Builder &B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attributes::hasAttribute(AttrVal Val) const {
|
bool Attributes::hasAttribute(AttrVal Val) const {
|
||||||
return Attrs.hasAttribute(Val);
|
return Attrs && Attrs->hasAttribute(Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attributes::hasAttributes(const Attributes &A) const {
|
bool Attributes::hasAttributes(const Attributes &A) const {
|
||||||
return Attrs.hasAttributes(A);
|
return Attrs && Attrs->hasAttributes(A);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This returns the alignment field of an attribute as a byte alignment value.
|
/// This returns the alignment field of an attribute as a byte alignment value.
|
||||||
unsigned Attributes::getAlignment() const {
|
unsigned Attributes::getAlignment() const {
|
||||||
if (!hasAttribute(Attributes::Alignment))
|
if (!hasAttribute(Attributes::Alignment))
|
||||||
return 0;
|
return 0;
|
||||||
return 1U << ((Attrs.getAlignment() >> 16) - 1);
|
return 1U << ((Attrs->getAlignment() >> 16) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This returns the stack alignment field of an attribute as a byte alignment
|
/// This returns the stack alignment field of an attribute as a byte alignment
|
||||||
|
@ -86,11 +83,11 @@ unsigned Attributes::getAlignment() const {
|
||||||
unsigned Attributes::getStackAlignment() const {
|
unsigned Attributes::getStackAlignment() const {
|
||||||
if (!hasAttribute(Attributes::StackAlignment))
|
if (!hasAttribute(Attributes::StackAlignment))
|
||||||
return 0;
|
return 0;
|
||||||
return 1U << ((Attrs.getStackAlignment() >> 26) - 1);
|
return 1U << ((Attrs->getStackAlignment() >> 26) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Attributes::Raw() const {
|
uint64_t Attributes::Raw() const {
|
||||||
return Attrs.Bits;
|
return Attrs ? Attrs->Bits : 0; // FIXME: Don't access this directly!
|
||||||
}
|
}
|
||||||
|
|
||||||
Attributes Attributes::typeIncompatible(Type *Ty) {
|
Attributes Attributes::typeIncompatible(Type *Ty) {
|
||||||
|
@ -109,7 +106,7 @@ Attributes Attributes::typeIncompatible(Type *Ty) {
|
||||||
.addAttribute(Attributes::NoCapture)
|
.addAttribute(Attributes::NoCapture)
|
||||||
.addAttribute(Attributes::StructRet);
|
.addAttribute(Attributes::StructRet);
|
||||||
|
|
||||||
return Attributes(Incompatible.Bits); // FIXME: Use Attributes::get().
|
return Attributes::get(Ty->getContext(), Incompatible);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Attributes::getAsString() const {
|
std::string Attributes::getAsString() const {
|
||||||
|
@ -514,7 +511,7 @@ AttrListPtr AttrListPtr::addAttr(LLVMContext &C, unsigned Idx,
|
||||||
// If there are attributes already at this index, merge them in.
|
// If there are attributes already at this index, merge them in.
|
||||||
if (i != e && OldAttrList[i].Index == Idx) {
|
if (i != e && OldAttrList[i].Index == Idx) {
|
||||||
Attrs =
|
Attrs =
|
||||||
Attributes::get(Attributes::Builder(Attrs).
|
Attributes::get(C, Attributes::Builder(Attrs).
|
||||||
addAttributes(OldAttrList[i].Attrs));
|
addAttributes(OldAttrList[i].Attrs));
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -555,7 +552,7 @@ AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx,
|
||||||
|
|
||||||
// If there are attributes already at this index, merge them in.
|
// If there are attributes already at this index, merge them in.
|
||||||
assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
|
assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
|
||||||
Attrs = Attributes::get(Attributes::Builder(OldAttrList[i].Attrs).
|
Attrs = Attributes::get(C, Attributes::Builder(OldAttrList[i].Attrs).
|
||||||
removeAttributes(Attrs));
|
removeAttributes(Attrs));
|
||||||
++i;
|
++i;
|
||||||
if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
|
if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
|
||||||
|
|
|
@ -148,7 +148,8 @@ bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) {
|
||||||
if (NewFn)
|
if (NewFn)
|
||||||
F = NewFn;
|
F = NewFn;
|
||||||
if (unsigned id = F->getIntrinsicID())
|
if (unsigned id = F->getIntrinsicID())
|
||||||
F->setAttributes(Intrinsic::getAttributes((Intrinsic::ID)id));
|
F->setAttributes(Intrinsic::getAttributes(F->getContext(),
|
||||||
|
(Intrinsic::ID)id));
|
||||||
return Upgraded;
|
return Upgraded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1381,16 +1381,20 @@ 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 AttrListPtr PAL = Func->getAttributes();
|
||||||
const AttrListPtr PALnew = PAL.addAttr(Func->getContext(), ~0U,
|
Attributes::Builder B(PA);
|
||||||
Attributes(PA));
|
const AttrListPtr PALnew =
|
||||||
|
PAL.addAttr(Func->getContext(), ~0U,
|
||||||
|
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 AttrListPtr PAL = Func->getAttributes();
|
||||||
const AttrListPtr PALnew = PAL.removeAttr(Func->getContext(), ~0U,
|
Attributes::Builder B(PA);
|
||||||
Attributes(PA));
|
const AttrListPtr PALnew =
|
||||||
|
PAL.removeAttr(Func->getContext(), ~0U,
|
||||||
|
Attributes::get(Func->getContext(), B));
|
||||||
Func->setAttributes(PALnew);
|
Func->setAttributes(PALnew);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1460,11 +1464,15 @@ LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
|
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
|
||||||
unwrap<Argument>(Arg)->addAttr(Attributes(PA));
|
Argument *A = unwrap<Argument>(Arg);
|
||||||
|
Attributes::Builder B(PA);
|
||||||
|
A->addAttr(Attributes::get(A->getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
|
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
|
||||||
unwrap<Argument>(Arg)->removeAttr(Attributes(PA));
|
Argument *A = unwrap<Argument>(Arg);
|
||||||
|
Attributes::Builder B(PA);
|
||||||
|
A->removeAttr(Attributes::get(A->getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
|
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
|
||||||
|
@ -1478,7 +1486,8 @@ LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
|
||||||
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
|
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAlignmentAttr(align);
|
B.addAlignmentAttr(align);
|
||||||
unwrap<Argument>(Arg)->addAttr(Attributes::get(B));
|
unwrap<Argument>(Arg)->addAttr(Attributes::
|
||||||
|
get(unwrap<Argument>(Arg)->getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--.. Operations on basic blocks ..........................................--*/
|
/*--.. Operations on basic blocks ..........................................--*/
|
||||||
|
@ -1667,15 +1676,19 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
|
||||||
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
|
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
|
||||||
LLVMAttribute PA) {
|
LLVMAttribute PA) {
|
||||||
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
||||||
|
Attributes::Builder B(PA);
|
||||||
Call.setAttributes(
|
Call.setAttributes(
|
||||||
Call.getAttributes().addAttr(Call->getContext(), index, Attributes(PA)));
|
Call.getAttributes().addAttr(Call->getContext(), index,
|
||||||
|
Attributes::get(Call->getContext(), B)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
|
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
|
||||||
LLVMAttribute PA) {
|
LLVMAttribute PA) {
|
||||||
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
||||||
|
Attributes::Builder B(PA);
|
||||||
Call.setAttributes(
|
Call.setAttributes(
|
||||||
Call.getAttributes().removeAttr(Call->getContext(), index, Attributes(PA)));
|
Call.getAttributes().removeAttr(Call->getContext(), index,
|
||||||
|
Attributes::get(Call->getContext(), B)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
|
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
|
||||||
|
@ -1684,7 +1697,7 @@ void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAlignmentAttr(align);
|
B.addAlignmentAttr(align);
|
||||||
Call.setAttributes(Call.getAttributes().addAttr(Call->getContext(), index,
|
Call.setAttributes(Call.getAttributes().addAttr(Call->getContext(), index,
|
||||||
Attributes::get(B)));
|
Attributes::get(Call->getContext(), B)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--.. Operations on call instructions (only) ..............................--*/
|
/*--.. Operations on call instructions (only) ..............................--*/
|
||||||
|
|
|
@ -185,7 +185,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage,
|
||||||
|
|
||||||
// Ensure intrinsics have the right parameter attributes.
|
// Ensure intrinsics have the right parameter attributes.
|
||||||
if (unsigned IID = getIntrinsicID())
|
if (unsigned IID = getIntrinsicID())
|
||||||
setAttributes(Intrinsic::getAttributes(Intrinsic::ID(IID)));
|
setAttributes(Intrinsic::getAttributes(getContext(), Intrinsic::ID(IID)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -618,7 +618,7 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT,
|
||||||
Attributes::Builder NotFn(FAttrs);
|
Attributes::Builder NotFn(FAttrs);
|
||||||
NotFn.removeFunctionOnlyAttrs();
|
NotFn.removeFunctionOnlyAttrs();
|
||||||
Assert1(!NotFn.hasAttributes(), "Attributes '" +
|
Assert1(!NotFn.hasAttributes(), "Attributes '" +
|
||||||
Attributes::get(NotFn).getAsString() +
|
Attributes::get(V->getContext(), NotFn).getAsString() +
|
||||||
"' do not apply to the function!", V);
|
"' do not apply to the function!", V);
|
||||||
|
|
||||||
// Check for mutually incompatible attributes.
|
// Check for mutually incompatible attributes.
|
||||||
|
|
|
@ -510,10 +510,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(" << TargetPrefix
|
OS << "static AttrListPtr getAttributes(LLVMContext &C, " << TargetPrefix
|
||||||
<< "Intrinsic::ID id) {\n";
|
<< "Intrinsic::ID id) {\n";
|
||||||
else
|
else
|
||||||
OS << "AttrListPtr Intrinsic::getAttributes(ID id) {\n";
|
OS << "AttrListPtr 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,
|
||||||
|
@ -582,7 +582,7 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
|
||||||
++ai;
|
++ai;
|
||||||
} while (ai != ae && intrinsic.ArgumentAttributes[ai].first == argNo);
|
} while (ai != ae && intrinsic.ArgumentAttributes[ai].first == argNo);
|
||||||
|
|
||||||
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get("
|
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, "
|
||||||
<< argNo+1 << ", AttrVec);\n";
|
<< argNo+1 << ", AttrVec);\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
|
||||||
OS << " AttrVec.push_back(Attributes::ReadNone);\n";
|
OS << " AttrVec.push_back(Attributes::ReadNone);\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(~0, "
|
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, ~0, "
|
||||||
<< "AttrVec);\n";
|
<< "AttrVec);\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue