bool hasStructRetAttr() const;
/// addAttr - Add a Attribute to an argument
- void addAttr(Attributes);
+ void addAttr(Attribute);
/// removeAttr - Remove a Attribute from an argument
- void removeAttr(Attributes);
+ void removeAttr(Attribute);
/// classof - Methods for support type inquiry through isa, cast, and
/// dyn_cast:
class LLVMContext;
class Type;
-/// Attributes - A bitset of attributes.
-class Attributes {
+/// Attribute - A bitset of attributes.
+class Attribute {
public:
/// Function parameters and results can have attributes to indicate how they
/// should be treated by optimizations and code generation. This enumeration
};
private:
AttributesImpl *Attrs;
- Attributes(AttributesImpl *A) : Attrs(A) {}
+ Attribute(AttributesImpl *A) : Attrs(A) {}
public:
- Attributes() : Attrs(0) {}
+ Attribute() : Attrs(0) {}
- /// get - Return a uniquified Attributes object. This takes the uniquified
- /// value from the Builder and wraps it in the Attributes class.
- static Attributes get(LLVMContext &Context, ArrayRef<AttrVal> Vals);
- static Attributes get(LLVMContext &Context, AttrBuilder &B);
+ /// get - Return a uniquified Attribute object. This takes the uniquified
+ /// value from the Builder and wraps it in the Attribute class.
+ static Attribute get(LLVMContext &Context, ArrayRef<AttrVal> Vals);
+ static Attribute get(LLVMContext &Context, AttrBuilder &B);
/// @brief Return true if the attribute is present.
bool hasAttribute(AttrVal Val) const;
bool hasAttributes() const;
/// @brief Return true if the attributes are a non-null intersection.
- bool hasAttributes(const Attributes &A) const;
+ bool hasAttributes(const Attribute &A) const;
/// @brief Returns the alignment field of an attribute as a byte alignment
/// value.
/// @brief Parameter attributes that do not apply to vararg call arguments.
bool hasIncompatibleWithVarArgsAttrs() const {
- return hasAttribute(Attributes::StructRet);
+ return hasAttribute(Attribute::StructRet);
}
- /// @brief Attributes that only apply to function parameters.
+ /// @brief Attribute that only apply to function parameters.
bool hasParameterOnlyAttrs() const {
- return hasAttribute(Attributes::ByVal) ||
- hasAttribute(Attributes::Nest) ||
- hasAttribute(Attributes::StructRet) ||
- hasAttribute(Attributes::NoCapture);
+ return hasAttribute(Attribute::ByVal) ||
+ hasAttribute(Attribute::Nest) ||
+ hasAttribute(Attribute::StructRet) ||
+ hasAttribute(Attribute::NoCapture);
}
- /// @brief Attributes that may be applied to the function itself. These cannot
+ /// @brief Attribute that may be applied to the function itself. These cannot
/// be used on return values or function parameters.
bool hasFunctionOnlyAttrs() const {
- return hasAttribute(Attributes::NoReturn) ||
- hasAttribute(Attributes::NoUnwind) ||
- hasAttribute(Attributes::ReadNone) ||
- hasAttribute(Attributes::ReadOnly) ||
- hasAttribute(Attributes::NoInline) ||
- hasAttribute(Attributes::AlwaysInline) ||
- hasAttribute(Attributes::OptimizeForSize) ||
- hasAttribute(Attributes::StackProtect) ||
- hasAttribute(Attributes::StackProtectReq) ||
- hasAttribute(Attributes::NoRedZone) ||
- hasAttribute(Attributes::NoImplicitFloat) ||
- hasAttribute(Attributes::Naked) ||
- hasAttribute(Attributes::InlineHint) ||
- hasAttribute(Attributes::StackAlignment) ||
- hasAttribute(Attributes::UWTable) ||
- hasAttribute(Attributes::NonLazyBind) ||
- hasAttribute(Attributes::ReturnsTwice) ||
- hasAttribute(Attributes::AddressSafety) ||
- hasAttribute(Attributes::MinSize);
+ return hasAttribute(Attribute::NoReturn) ||
+ hasAttribute(Attribute::NoUnwind) ||
+ hasAttribute(Attribute::ReadNone) ||
+ hasAttribute(Attribute::ReadOnly) ||
+ hasAttribute(Attribute::NoInline) ||
+ hasAttribute(Attribute::AlwaysInline) ||
+ hasAttribute(Attribute::OptimizeForSize) ||
+ hasAttribute(Attribute::StackProtect) ||
+ hasAttribute(Attribute::StackProtectReq) ||
+ hasAttribute(Attribute::NoRedZone) ||
+ hasAttribute(Attribute::NoImplicitFloat) ||
+ hasAttribute(Attribute::Naked) ||
+ hasAttribute(Attribute::InlineHint) ||
+ hasAttribute(Attribute::StackAlignment) ||
+ hasAttribute(Attribute::UWTable) ||
+ hasAttribute(Attribute::NonLazyBind) ||
+ hasAttribute(Attribute::ReturnsTwice) ||
+ hasAttribute(Attribute::AddressSafety) ||
+ hasAttribute(Attribute::MinSize);
}
- bool operator==(const Attributes &A) const {
+ bool operator==(const Attribute &A) const {
return Attrs == A.Attrs;
}
- bool operator!=(const Attributes &A) const {
+ bool operator!=(const Attribute &A) const {
return Attrs != A.Attrs;
}
uint64_t Raw() const;
/// @brief Which attributes cannot be applied to a type.
- static Attributes typeIncompatible(Type *Ty);
+ static Attribute typeIncompatible(Type *Ty);
/// encodeLLVMAttributesForBitcode - This returns an integer containing an
/// encoding of all the LLVM attributes found in the given attribute bitset.
/// Any change to this encoding is a breaking change to bitcode compatibility.
- static uint64_t encodeLLVMAttributesForBitcode(Attributes Attrs);
+ static uint64_t encodeLLVMAttributesForBitcode(Attribute Attrs);
/// decodeLLVMAttributesForBitcode - This returns an attribute bitset
/// containing the LLVM attributes that have been decoded from the given
/// integer. This function must stay in sync with
/// 'encodeLLVMAttributesForBitcode'.
- static Attributes decodeLLVMAttributesForBitcode(LLVMContext &C,
+ static Attribute decodeLLVMAttributesForBitcode(LLVMContext &C,
uint64_t EncodedAttrs);
- /// getAsString - The set of Attributes set in Attributes is converted to a
+ /// getAsString - The set of attributes set in Attribute is converted to a
/// string of equivalent mnemonics. This is, presumably, for writing out the
/// mnemonics for the assembly writer.
/// @brief Convert attribute bits to text
};
//===----------------------------------------------------------------------===//
-/// AttrBuilder - This class is used in conjunction with the Attributes::get
-/// method to create an Attributes object. The object itself is uniquified. The
+/// AttrBuilder - This class is used in conjunction with the Attribute::get
+/// method to create an Attribute object. The object itself is uniquified. The
/// Builder's value, however, is not. So this can be used as a quick way to test
/// for equality, presence of attributes, etc.
class AttrBuilder {
public:
AttrBuilder() : Bits(0) {}
explicit AttrBuilder(uint64_t B) : Bits(B) {}
- AttrBuilder(const Attributes &A) : Bits(A.Raw()) {}
+ AttrBuilder(const Attribute &A) : Bits(A.Raw()) {}
void clear() { Bits = 0; }
/// addAttribute - Add an attribute to the builder.
- AttrBuilder &addAttribute(Attributes::AttrVal Val);
+ AttrBuilder &addAttribute(Attribute::AttrVal Val);
/// removeAttribute - Remove an attribute from the builder.
- AttrBuilder &removeAttribute(Attributes::AttrVal Val);
+ AttrBuilder &removeAttribute(Attribute::AttrVal Val);
/// addAttribute - Add the attributes from A to the builder.
- AttrBuilder &addAttributes(const Attributes &A);
+ AttrBuilder &addAttributes(const Attribute &A);
/// removeAttribute - Remove the attributes from A from the builder.
- AttrBuilder &removeAttributes(const Attributes &A);
+ AttrBuilder &removeAttributes(const Attribute &A);
/// hasAttribute - Return true if the builder has the specified attribute.
- bool hasAttribute(Attributes::AttrVal A) const;
+ bool hasAttribute(Attribute::AttrVal A) const;
/// hasAttributes - Return true if the builder has IR-level attributes.
bool hasAttributes() const;
/// hasAttributes - Return true if the builder has any attribute that's in the
/// specified attribute.
- bool hasAttributes(const Attributes &A) const;
+ bool hasAttributes(const Attribute &A) const;
/// hasAlignmentAttr - Return true if the builder has an alignment attribute.
bool hasAlignmentAttr() const;
uint64_t getStackAlignment() const;
/// addAlignmentAttr - This turns an int alignment (which must be a power of
- /// 2) into the form used internally in Attributes.
+ /// 2) into the form used internally in Attribute.
AttrBuilder &addAlignmentAttr(unsigned Align);
/// addStackAlignmentAttr - This turns an int stack alignment (which must be a
- /// power of 2) into the form used internally in Attributes.
+ /// power of 2) into the form used internally in Attribute.
AttrBuilder &addStackAlignmentAttr(unsigned Align);
/// addRawValue - Add the raw value to the internal representation.
/// @brief Remove attributes that are used on functions only.
void removeFunctionOnlyAttrs() {
- removeAttribute(Attributes::NoReturn)
- .removeAttribute(Attributes::NoUnwind)
- .removeAttribute(Attributes::ReadNone)
- .removeAttribute(Attributes::ReadOnly)
- .removeAttribute(Attributes::NoInline)
- .removeAttribute(Attributes::AlwaysInline)
- .removeAttribute(Attributes::OptimizeForSize)
- .removeAttribute(Attributes::StackProtect)
- .removeAttribute(Attributes::StackProtectReq)
- .removeAttribute(Attributes::NoRedZone)
- .removeAttribute(Attributes::NoImplicitFloat)
- .removeAttribute(Attributes::Naked)
- .removeAttribute(Attributes::InlineHint)
- .removeAttribute(Attributes::StackAlignment)
- .removeAttribute(Attributes::UWTable)
- .removeAttribute(Attributes::NonLazyBind)
- .removeAttribute(Attributes::ReturnsTwice)
- .removeAttribute(Attributes::AddressSafety)
- .removeAttribute(Attributes::MinSize);
+ removeAttribute(Attribute::NoReturn)
+ .removeAttribute(Attribute::NoUnwind)
+ .removeAttribute(Attribute::ReadNone)
+ .removeAttribute(Attribute::ReadOnly)
+ .removeAttribute(Attribute::NoInline)
+ .removeAttribute(Attribute::AlwaysInline)
+ .removeAttribute(Attribute::OptimizeForSize)
+ .removeAttribute(Attribute::StackProtect)
+ .removeAttribute(Attribute::StackProtectReq)
+ .removeAttribute(Attribute::NoRedZone)
+ .removeAttribute(Attribute::NoImplicitFloat)
+ .removeAttribute(Attribute::Naked)
+ .removeAttribute(Attribute::InlineHint)
+ .removeAttribute(Attribute::StackAlignment)
+ .removeAttribute(Attribute::UWTable)
+ .removeAttribute(Attribute::NonLazyBind)
+ .removeAttribute(Attribute::ReturnsTwice)
+ .removeAttribute(Attribute::AddressSafety)
+ .removeAttribute(Attribute::MinSize);
}
uint64_t Raw() const { return Bits; }
/// AttributeWithIndex - This is just a pair of values to associate a set of
/// attributes with an index.
struct AttributeWithIndex {
- Attributes Attrs; ///< The attributes that are set, or'd together.
+ Attribute Attrs; ///< The attributes that are set, or'd together.
unsigned Index; ///< Index of the parameter for which the attributes apply.
///< Index 0 is used for return value attributes.
///< Index ~0U is used for function attributes.
static AttributeWithIndex get(LLVMContext &C, unsigned Idx,
- ArrayRef<Attributes::AttrVal> Attrs) {
- return get(Idx, Attributes::get(C, Attrs));
+ ArrayRef<Attribute::AttrVal> Attrs) {
+ return get(Idx, Attribute::get(C, Attrs));
}
- static AttributeWithIndex get(unsigned Idx, Attributes Attrs) {
+ static AttributeWithIndex get(unsigned Idx, Attribute Attrs) {
AttributeWithIndex P;
P.Index = Idx;
P.Attrs = Attrs;
/// @brief The attributes for the specified index are returned. Attributes
/// for the result are denoted with Idx = 0.
- Attributes getAttributes(unsigned Idx) const;
+ Attribute getAttributes(unsigned Idx) const;
explicit AttributeSet(AttributeListImpl *LI) : AttrList(LI) {}
public:
// Attribute List Construction and Mutation
//===--------------------------------------------------------------------===//
- /// get - Return a Attributes list with the specified parameters in it.
+ /// get - Return an AttributeSet with the specified parameters in it.
static AttributeSet get(LLVMContext &C, ArrayRef<AttributeWithIndex> Attrs);
/// addAttr - Add the specified attribute at the specified index to this
/// attribute list. Since attribute lists are immutable, this
/// returns the new list.
- AttributeSet addAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const;
+ AttributeSet addAttr(LLVMContext &C, unsigned Idx, Attribute Attrs) const;
/// removeAttr - Remove the specified attribute at the specified index from
/// this attribute list. Since attribute lists are immutable, this
/// returns the new list.
- AttributeSet removeAttr(LLVMContext &C, unsigned Idx, Attributes Attrs) const;
+ AttributeSet removeAttr(LLVMContext &C, unsigned Idx, Attribute Attrs) const;
//===--------------------------------------------------------------------===//
// Attribute List Accessors
//===--------------------------------------------------------------------===//
/// getParamAttributes - The attributes for the specified index are
/// returned.
- Attributes getParamAttributes(unsigned Idx) const {
+ Attribute getParamAttributes(unsigned Idx) const {
return getAttributes(Idx);
}
/// getRetAttributes - The attributes for the ret value are
/// returned.
- Attributes getRetAttributes() const {
+ Attribute getRetAttributes() const {
return getAttributes(ReturnIndex);
}
/// getFnAttributes - The function attributes are returned.
- Attributes getFnAttributes() const {
+ Attribute getFnAttributes() const {
return getAttributes(FunctionIndex);
}
/// paramHasAttr - Return true if the specified parameter index has the
/// specified attribute set.
- bool paramHasAttr(unsigned Idx, Attributes Attr) const {
+ bool paramHasAttr(unsigned Idx, Attribute Attr) const {
return getAttributes(Idx).hasAttributes(Attr);
}
/// hasAttrSomewhere - Return true if the specified attribute is set for at
/// least one parameter or for the return value.
- bool hasAttrSomewhere(Attributes::AttrVal Attr) const;
+ bool hasAttrSomewhere(Attribute::AttrVal Attr) const;
unsigned getNumAttrs() const;
- Attributes &getAttributesAtIndex(unsigned i) const;
+ Attribute &getAttributesAtIndex(unsigned i) const;
/// operator==/!= - Provide equality predicates.
bool operator==(const AttributeSet &RHS) const
return AttrList;
}
- // Attributes are stored as a dense set of slots, where there is one
- // slot for each argument that has an attribute. This allows walking over the
- // dense set instead of walking the sparse list of attributes.
+ // Attributes are stored as a dense set of slots, where there is one slot for
+ // each argument that has an attribute. This allows walking over the dense
+ // set instead of walking the sparse list of attributes.
/// isEmpty - Return true if there are no attributes.
///
/// between it and the return.
///
/// This function only tests target-independent requirements.
-bool isInTailCallPosition(ImmutableCallSite CS, Attributes CalleeRetAttr,
+bool isInTailCallPosition(ImmutableCallSite CS, Attribute CalleeRetAttr,
const TargetLowering &TLI);
bool isInTailCallPosition(SelectionDAG &DAG, SDNode *Node,
/// getFnAttributes - Return the function attributes for querying.
///
- Attributes getFnAttributes() const {
+ Attribute getFnAttributes() const {
return AttributeList.getFnAttributes();
}
/// addFnAttr - Add function attributes to this function.
///
- void addFnAttr(Attributes::AttrVal N) {
- // Function Attributes are stored at ~0 index
- addAttribute(AttributeSet::FunctionIndex, Attributes::get(getContext(), N));
+ void addFnAttr(Attribute::AttrVal N) {
+ // Function Attribute are stored at ~0 index
+ addAttribute(AttributeSet::FunctionIndex, Attribute::get(getContext(), N));
}
/// removeFnAttr - Remove function attributes from this function.
///
- void removeFnAttr(Attributes N) {
- // Function Attributes are stored at ~0 index
+ void removeFnAttr(Attribute N) {
+ // Function Attribute are stored at ~0 index
removeAttribute(~0U, N);
}
/// getRetAttributes - Return the return attributes for querying.
- Attributes getRetAttributes() const {
+ Attribute getRetAttributes() const {
return AttributeList.getRetAttributes();
}
/// getParamAttributes - Return the parameter attributes for querying.
- Attributes getParamAttributes(unsigned Idx) const {
+ Attribute getParamAttributes(unsigned Idx) const {
return AttributeList.getParamAttributes(Idx);
}
/// addAttribute - adds the attribute to the list of attributes.
- void addAttribute(unsigned i, Attributes attr);
+ void addAttribute(unsigned i, Attribute attr);
/// removeAttribute - removes the attribute from the list of attributes.
- void removeAttribute(unsigned i, Attributes attr);
+ void removeAttribute(unsigned i, Attribute attr);
/// @brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
/// @brief Determine if the function does not access memory.
bool doesNotAccessMemory() const {
- return getFnAttributes().hasAttribute(Attributes::ReadNone);
+ return getFnAttributes().hasAttribute(Attribute::ReadNone);
}
void setDoesNotAccessMemory() {
- addFnAttr(Attributes::ReadNone);
+ addFnAttr(Attribute::ReadNone);
}
/// @brief Determine if the function does not access or only reads memory.
bool onlyReadsMemory() const {
return doesNotAccessMemory() ||
- getFnAttributes().hasAttribute(Attributes::ReadOnly);
+ getFnAttributes().hasAttribute(Attribute::ReadOnly);
}
void setOnlyReadsMemory() {
- addFnAttr(Attributes::ReadOnly);
+ addFnAttr(Attribute::ReadOnly);
}
/// @brief Determine if the function cannot return.
bool doesNotReturn() const {
- return getFnAttributes().hasAttribute(Attributes::NoReturn);
+ return getFnAttributes().hasAttribute(Attribute::NoReturn);
}
void setDoesNotReturn() {
- addFnAttr(Attributes::NoReturn);
+ addFnAttr(Attribute::NoReturn);
}
/// @brief Determine if the function cannot unwind.
bool doesNotThrow() const {
- return getFnAttributes().hasAttribute(Attributes::NoUnwind);
+ return getFnAttributes().hasAttribute(Attribute::NoUnwind);
}
void setDoesNotThrow() {
- addFnAttr(Attributes::NoUnwind);
+ addFnAttr(Attribute::NoUnwind);
}
/// @brief True if the ABI mandates (or the user requested) that this
/// function be in a unwind table.
bool hasUWTable() const {
- return getFnAttributes().hasAttribute(Attributes::UWTable);
+ return getFnAttributes().hasAttribute(Attribute::UWTable);
}
void setHasUWTable() {
- addFnAttr(Attributes::UWTable);
+ addFnAttr(Attribute::UWTable);
}
/// @brief True if this function needs an unwind table.
/// @brief Determine if the function returns a structure through first
/// pointer argument.
bool hasStructRetAttr() const {
- return getParamAttributes(1).hasAttribute(Attributes::StructRet);
+ return getParamAttributes(1).hasAttribute(Attribute::StructRet);
}
/// @brief Determine if the parameter does not alias other parameters.
/// @param n The parameter to check. 1 is the first parameter, 0 is the return
bool doesNotAlias(unsigned n) const {
- return getParamAttributes(n).hasAttribute(Attributes::NoAlias);
+ return getParamAttributes(n).hasAttribute(Attribute::NoAlias);
}
void setDoesNotAlias(unsigned n) {
- addAttribute(n, Attributes::get(getContext(), Attributes::NoAlias));
+ addAttribute(n, Attribute::get(getContext(), Attribute::NoAlias));
}
/// @brief Determine if the parameter can be captured.
/// @param n The parameter to check. 1 is the first parameter, 0 is the return
bool doesNotCapture(unsigned n) const {
- return getParamAttributes(n).hasAttribute(Attributes::NoCapture);
+ return getParamAttributes(n).hasAttribute(Attribute::NoCapture);
}
void setDoesNotCapture(unsigned n) {
- addAttribute(n, Attributes::get(getContext(), Attributes::NoCapture));
+ addAttribute(n, Attribute::get(getContext(), Attribute::NoCapture));
}
/// copyAttributesFrom - copy all additional attributes (those not needed to
void setAttributes(const AttributeSet &Attrs) { AttributeList = Attrs; }
/// addAttribute - adds the attribute to the list of attributes.
- void addAttribute(unsigned i, Attributes attr);
+ void addAttribute(unsigned i, Attribute attr);
/// removeAttribute - removes the attribute from the list of attributes.
- void removeAttribute(unsigned i, Attributes attr);
+ void removeAttribute(unsigned i, Attribute attr);
/// \brief Determine whether this call has the given attribute.
- bool hasFnAttr(Attributes::AttrVal A) const;
+ bool hasFnAttr(Attribute::AttrVal A) const;
/// \brief Determine whether the call or the callee has the given attributes.
- bool paramHasAttr(unsigned i, Attributes::AttrVal A) const;
+ bool paramHasAttr(unsigned i, Attribute::AttrVal A) const;
/// \brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
}
/// \brief Return true if the call should not be inlined.
- bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
+ bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
void setIsNoInline() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::NoInline));
+ Attribute::get(getContext(), Attribute::NoInline));
}
/// \brief Return true if the call can return twice
bool canReturnTwice() const {
- return hasFnAttr(Attributes::ReturnsTwice);
+ return hasFnAttr(Attribute::ReturnsTwice);
}
void setCanReturnTwice() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::ReturnsTwice));
+ Attribute::get(getContext(), Attribute::ReturnsTwice));
}
/// \brief Determine if the call does not access memory.
bool doesNotAccessMemory() const {
- return hasFnAttr(Attributes::ReadNone);
+ return hasFnAttr(Attribute::ReadNone);
}
void setDoesNotAccessMemory() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::ReadNone));
+ Attribute::get(getContext(), Attribute::ReadNone));
}
/// \brief Determine if the call does not access or only reads memory.
bool onlyReadsMemory() const {
- return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
+ return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
}
void setOnlyReadsMemory() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::ReadOnly));
+ Attribute::get(getContext(), Attribute::ReadOnly));
}
/// \brief Determine if the call cannot return.
- bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
+ bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); }
void setDoesNotReturn() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::NoReturn));
+ Attribute::get(getContext(), Attribute::NoReturn));
}
/// \brief Determine if the call cannot unwind.
- bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
+ bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); }
void setDoesNotThrow() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::NoUnwind));
+ Attribute::get(getContext(), Attribute::NoUnwind));
}
/// \brief Determine if the call returns a structure through first
/// pointer argument.
bool hasStructRetAttr() const {
// Be friendly and also check the callee.
- return paramHasAttr(1, Attributes::StructRet);
+ return paramHasAttr(1, Attribute::StructRet);
}
/// \brief Determine if any call argument is an aggregate passed by value.
bool hasByValArgument() const {
for (unsigned I = 0, E = AttributeList.getNumAttrs(); I != E; ++I)
- if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attributes::ByVal))
+ if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attribute::ByVal))
return true;
return false;
}
void setAttributes(const AttributeSet &Attrs) { AttributeList = Attrs; }
/// addAttribute - adds the attribute to the list of attributes.
- void addAttribute(unsigned i, Attributes attr);
+ void addAttribute(unsigned i, Attribute attr);
/// removeAttribute - removes the attribute from the list of attributes.
- void removeAttribute(unsigned i, Attributes attr);
+ void removeAttribute(unsigned i, Attribute attr);
/// \brief Determine whether this call has the NoAlias attribute.
- bool hasFnAttr(Attributes::AttrVal A) const;
+ bool hasFnAttr(Attribute::AttrVal A) const;
/// \brief Determine whether the call or the callee has the given attributes.
- bool paramHasAttr(unsigned i, Attributes::AttrVal A) const;
+ bool paramHasAttr(unsigned i, Attribute::AttrVal A) const;
/// \brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
}
/// \brief Return true if the call should not be inlined.
- bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
+ bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
void setIsNoInline() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::NoInline));
+ Attribute::get(getContext(), Attribute::NoInline));
}
/// \brief Determine if the call does not access memory.
bool doesNotAccessMemory() const {
- return hasFnAttr(Attributes::ReadNone);
+ return hasFnAttr(Attribute::ReadNone);
}
void setDoesNotAccessMemory() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::ReadNone));
+ Attribute::get(getContext(), Attribute::ReadNone));
}
/// \brief Determine if the call does not access or only reads memory.
bool onlyReadsMemory() const {
- return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
+ return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
}
void setOnlyReadsMemory() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::ReadOnly));
+ Attribute::get(getContext(), Attribute::ReadOnly));
}
/// \brief Determine if the call cannot return.
- bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
+ bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); }
void setDoesNotReturn() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::NoReturn));
+ Attribute::get(getContext(), Attribute::NoReturn));
}
/// \brief Determine if the call cannot unwind.
- bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
+ bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); }
void setDoesNotThrow() {
addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(getContext(), Attributes::NoUnwind));
+ Attribute::get(getContext(), Attribute::NoUnwind));
}
/// \brief Determine if the call returns a structure through first
/// pointer argument.
bool hasStructRetAttr() const {
// Be friendly and also check the callee.
- return paramHasAttr(1, Attributes::StructRet);
+ return paramHasAttr(1, Attribute::StructRet);
}
/// \brief Determine if any call argument is an aggregate passed by value.
bool hasByValArgument() const {
for (unsigned I = 0, E = AttributeList.getNumAttrs(); I != E; ++I)
- if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attributes::ByVal))
+ if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attribute::ByVal))
return true;
return false;
}
}
/// \brief Return true if this function has the given attribute.
- bool hasFnAttr(Attributes::AttrVal A) const {
+ bool hasFnAttr(Attribute::AttrVal A) const {
CALLSITE_DELEGATE_GETTER(hasFnAttr(A));
}
/// \brief Return true if the call or the callee has the given attribute.
- bool paramHasAttr(unsigned i, Attributes::AttrVal A) const {
+ bool paramHasAttr(unsigned i, Attribute::AttrVal A) const {
CALLSITE_DELEGATE_GETTER(paramHasAttr(i, A));
}
/// @brief Determine whether this argument is not captured.
bool doesNotCapture(unsigned ArgNo) const {
- return paramHasAttr(ArgNo + 1, Attributes::NoCapture);
+ return paramHasAttr(ArgNo + 1, Attribute::NoCapture);
}
/// @brief Determine whether this argument is passed by value.
bool isByValArgument(unsigned ArgNo) const {
- return paramHasAttr(ArgNo + 1, Attributes::ByVal);
+ return paramHasAttr(ArgNo + 1, Attribute::ByVal);
}
/// hasArgument - Returns true if this CallSite passes the given Value* as an
FunctionType *FTy, bool isTailCall, SDValue callee,
ArgListTy &args, SelectionDAG &dag, DebugLoc dl,
ImmutableCallSite &cs)
- : Chain(chain), RetTy(retTy), RetSExt(cs.paramHasAttr(0, Attributes::SExt)),
- RetZExt(cs.paramHasAttr(0, Attributes::ZExt)), IsVarArg(FTy->isVarArg()),
- IsInReg(cs.paramHasAttr(0, Attributes::InReg)),
+ : Chain(chain), RetTy(retTy), RetSExt(cs.paramHasAttr(0, Attribute::SExt)),
+ RetZExt(cs.paramHasAttr(0, Attribute::ZExt)), IsVarArg(FTy->isVarArg()),
+ IsInReg(cs.paramHasAttr(0, Attribute::InReg)),
DoesNotReturn(cs.doesNotReturn()),
IsReturnValueUsed(!cs.getInstruction()->use_empty()),
IsTailCall(isTailCall), NumFixedArgs(FTy->getNumParams()),
/// GetReturnInfo - Given an LLVM IR type and return type attributes,
/// compute the return value EVTs and flags, and optionally also
/// the offsets, if the return value is being lowered to memory.
-void GetReturnInfo(Type* ReturnType, Attributes attr,
+void GetReturnInfo(Type* ReturnType, Attribute attr,
SmallVectorImpl<ISD::OutputArg> &Outs,
const TargetLowering &TLI);
bool llvm::isNoAliasCall(const Value *V) {
if (isa<CallInst>(V) || isa<InvokeInst>(V))
return ImmutableCallSite(cast<Instruction>(V))
- .paramHasAttr(0, Attributes::NoAlias);
+ .paramHasAttr(0, Attribute::NoAlias);
return false;
}
// as volatile if they are live across a setjmp call, and they probably
// won't do this in callers.
exposesReturnsTwice = F->callsFunctionThatReturnsTwice() &&
- !F->getFnAttributes().hasAttribute(Attributes::ReturnsTwice);
+ !F->getFnAttributes().hasAttribute(Attribute::ReturnsTwice);
// Look at the size of the callee.
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
bool CallAnalyzer::visitCallSite(CallSite CS) {
if (CS.isCall() && cast<CallInst>(CS.getInstruction())->canReturnTwice() &&
- !F.getFnAttributes().hasAttribute(Attributes::ReturnsTwice)) {
+ !F.getFnAttributes().hasAttribute(Attribute::ReturnsTwice)) {
// This aborts the entire analysis.
ExposesReturnsTwice = true;
return false;
// Calls to functions with always-inline attributes should be inlined
// whenever possible.
- if (Callee->getFnAttributes().hasAttribute(Attributes::AlwaysInline)) {
+ if (Callee->getFnAttributes().hasAttribute(Attribute::AlwaysInline)) {
if (isInlineViable(*Callee))
return llvm::InlineCost::getAlways();
return llvm::InlineCost::getNever();
// something else. Don't inline functions marked noinline or call sites
// marked noinline.
if (Callee->mayBeOverridden() ||
- Callee->getFnAttributes().hasAttribute(Attributes::NoInline) ||
+ Callee->getFnAttributes().hasAttribute(Attribute::NoInline) ||
CS.isNoInline())
return llvm::InlineCost::getNever();
}
bool InlineCostAnalyzer::isInlineViable(Function &F) {
- bool ReturnsTwice =F.getFnAttributes().hasAttribute(Attributes::ReturnsTwice);
+ bool ReturnsTwice =F.getFnAttributes().hasAttribute(Attribute::ReturnsTwice);
for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; ++BI) {
// Disallow inlining of functions which contain an indirect branch.
if (isa<IndirectBrInst>(BI->getTerminator()))
static bool hasNoAliasAttr(const Value *V, bool LookThroughBitCast) {
ImmutableCallSite CS(LookThroughBitCast ? V->stripPointerCasts() : V);
- return CS && CS.hasFnAttr(Attributes::NoAlias);
+ return CS && CS.hasFnAttr(Attribute::NoAlias);
}
if (LIOffs+NewLoadByteSize > MemLocEnd &&
LI->getParent()->getParent()->getFnAttributes().
- hasAttribute(Attributes::AddressSafety))
+ hasAttribute(Attribute::AddressSafety))
// We will be reading past the location accessed by the original program.
// While this is safe in a regular build, Address Safety analysis tools
// may start reporting false warnings. So, don't do widening.
B.addAlignmentAttr(Alignment);
continue;
}
- case lltok::kw_address_safety: B.addAttribute(Attributes::AddressSafety); break;
- case lltok::kw_alwaysinline: B.addAttribute(Attributes::AlwaysInline); break;
- case lltok::kw_inlinehint: B.addAttribute(Attributes::InlineHint); break;
- case lltok::kw_minsize: B.addAttribute(Attributes::MinSize); break;
- case lltok::kw_naked: B.addAttribute(Attributes::Naked); break;
- case lltok::kw_noinline: B.addAttribute(Attributes::NoInline); break;
- case lltok::kw_nonlazybind: B.addAttribute(Attributes::NonLazyBind); break;
- case lltok::kw_noredzone: B.addAttribute(Attributes::NoRedZone); break;
- case lltok::kw_noimplicitfloat: B.addAttribute(Attributes::NoImplicitFloat); break;
- case lltok::kw_noreturn: B.addAttribute(Attributes::NoReturn); break;
- case lltok::kw_nounwind: B.addAttribute(Attributes::NoUnwind); break;
- case lltok::kw_optsize: B.addAttribute(Attributes::OptimizeForSize); break;
- case lltok::kw_readnone: B.addAttribute(Attributes::ReadNone); break;
- case lltok::kw_readonly: B.addAttribute(Attributes::ReadOnly); break;
- case lltok::kw_returns_twice: B.addAttribute(Attributes::ReturnsTwice); break;
- case lltok::kw_ssp: B.addAttribute(Attributes::StackProtect); break;
- case lltok::kw_sspreq: B.addAttribute(Attributes::StackProtectReq); break;
- case lltok::kw_uwtable: B.addAttribute(Attributes::UWTable); break;
+ case lltok::kw_address_safety: B.addAttribute(Attribute::AddressSafety); break;
+ case lltok::kw_alwaysinline: B.addAttribute(Attribute::AlwaysInline); break;
+ case lltok::kw_inlinehint: B.addAttribute(Attribute::InlineHint); break;
+ case lltok::kw_minsize: B.addAttribute(Attribute::MinSize); break;
+ case lltok::kw_naked: B.addAttribute(Attribute::Naked); break;
+ case lltok::kw_noinline: B.addAttribute(Attribute::NoInline); break;
+ case lltok::kw_nonlazybind: B.addAttribute(Attribute::NonLazyBind); break;
+ case lltok::kw_noredzone: B.addAttribute(Attribute::NoRedZone); break;
+ case lltok::kw_noimplicitfloat: B.addAttribute(Attribute::NoImplicitFloat); break;
+ case lltok::kw_noreturn: B.addAttribute(Attribute::NoReturn); break;
+ case lltok::kw_nounwind: B.addAttribute(Attribute::NoUnwind); break;
+ case lltok::kw_optsize: B.addAttribute(Attribute::OptimizeForSize); break;
+ case lltok::kw_readnone: B.addAttribute(Attribute::ReadNone); break;
+ case lltok::kw_readonly: B.addAttribute(Attribute::ReadOnly); break;
+ case lltok::kw_returns_twice: B.addAttribute(Attribute::ReturnsTwice); break;
+ case lltok::kw_ssp: B.addAttribute(Attribute::StackProtect); break;
+ case lltok::kw_sspreq: B.addAttribute(Attribute::StackProtectReq); break;
+ case lltok::kw_uwtable: B.addAttribute(Attribute::UWTable); break;
// Error handling.
case lltok::kw_zeroext:
B.addAlignmentAttr(Alignment);
continue;
}
- case lltok::kw_byval: B.addAttribute(Attributes::ByVal); break;
- case lltok::kw_inreg: B.addAttribute(Attributes::InReg); break;
- case lltok::kw_nest: B.addAttribute(Attributes::Nest); break;
- case lltok::kw_noalias: B.addAttribute(Attributes::NoAlias); break;
- case lltok::kw_nocapture: B.addAttribute(Attributes::NoCapture); break;
- case lltok::kw_signext: B.addAttribute(Attributes::SExt); break;
- case lltok::kw_sret: B.addAttribute(Attributes::StructRet); break;
- case lltok::kw_zeroext: B.addAttribute(Attributes::ZExt); break;
+ case lltok::kw_byval: B.addAttribute(Attribute::ByVal); break;
+ case lltok::kw_inreg: B.addAttribute(Attribute::InReg); break;
+ case lltok::kw_nest: B.addAttribute(Attribute::Nest); break;
+ case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
+ case lltok::kw_nocapture: B.addAttribute(Attribute::NoCapture); break;
+ case lltok::kw_signext: B.addAttribute(Attribute::SExt); break;
+ case lltok::kw_sret: B.addAttribute(Attribute::StructRet); break;
+ case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
case lltok::kw_noreturn: case lltok::kw_nounwind:
case lltok::kw_uwtable: case lltok::kw_returns_twice:
switch (Token) {
default: // End of attributes.
return HaveError;
- case lltok::kw_inreg: B.addAttribute(Attributes::InReg); break;
- case lltok::kw_noalias: B.addAttribute(Attributes::NoAlias); break;
- case lltok::kw_signext: B.addAttribute(Attributes::SExt); break;
- case lltok::kw_zeroext: B.addAttribute(Attributes::ZExt); break;
+ case lltok::kw_inreg: B.addAttribute(Attribute::InReg); break;
+ case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
+ case lltok::kw_signext: B.addAttribute(Attribute::SExt); break;
+ case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
// Error handling.
case lltok::kw_sret: case lltok::kw_nocapture:
// Otherwise, handle normal operands.
if (ParseOptionalParamAttrs(ArgAttrs) || ParseValue(ArgTy, V, PFS))
return true;
- ArgList.push_back(ParamInfo(ArgLoc, V, Attributes::get(V->getContext(),
+ ArgList.push_back(ParamInfo(ArgLoc, V, Attribute::get(V->getContext(),
ArgAttrs)));
}
return Error(TypeLoc, "invalid type for function argument");
ArgList.push_back(ArgInfo(TypeLoc, ArgTy,
- Attributes::get(ArgTy->getContext(),
+ Attribute::get(ArgTy->getContext(),
Attrs), Name));
while (EatIfPresent(lltok::comma)) {
return Error(TypeLoc, "invalid type for function argument");
ArgList.push_back(ArgInfo(TypeLoc, ArgTy,
- Attributes::get(ArgTy->getContext(), Attrs),
+ Attribute::get(ArgTy->getContext(), Attrs),
Name));
}
}
// If the alignment was parsed as an attribute, move to the alignment field.
if (FuncAttrs.hasAlignmentAttr()) {
Alignment = FuncAttrs.getAlignment();
- FuncAttrs.removeAttribute(Attributes::Alignment);
+ FuncAttrs.removeAttribute(Attribute::Alignment);
}
// Okay, if we got here, the function is syntactically valid. Convert types
if (RetAttrs.hasAttributes())
Attrs.push_back(
AttributeWithIndex::get(AttributeSet::ReturnIndex,
- Attributes::get(RetType->getContext(),
+ Attribute::get(RetType->getContext(),
RetAttrs)));
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
if (FuncAttrs.hasAttributes())
Attrs.push_back(
AttributeWithIndex::get(AttributeSet::FunctionIndex,
- Attributes::get(RetType->getContext(),
+ Attribute::get(RetType->getContext(),
FuncAttrs)));
AttributeSet PAL = AttributeSet::get(Context, Attrs);
- if (PAL.getParamAttributes(1).hasAttribute(Attributes::StructRet) &&
+ if (PAL.getParamAttributes(1).hasAttribute(Attribute::StructRet) &&
!RetType->isVoidTy())
return Error(RetTypeLoc, "functions with 'sret' argument must return void");
Value *Callee;
if (ConvertValIDToValue(PFTy, CalleeID, Callee, &PFS)) return true;
- // Set up the Attributes for the function.
+ // Set up the Attribute for the function.
SmallVector<AttributeWithIndex, 8> Attrs;
if (RetAttrs.hasAttributes())
Attrs.push_back(
AttributeWithIndex::get(AttributeSet::ReturnIndex,
- Attributes::get(Callee->getContext(),
+ Attribute::get(Callee->getContext(),
RetAttrs)));
SmallVector<Value*, 8> Args;
if (FnAttrs.hasAttributes())
Attrs.push_back(
AttributeWithIndex::get(AttributeSet::FunctionIndex,
- Attributes::get(Callee->getContext(),
+ Attribute::get(Callee->getContext(),
FnAttrs)));
- // Finish off the Attributes and check them
+ // Finish off the Attribute and check them
AttributeSet PAL = AttributeSet::get(Context, Attrs);
InvokeInst *II = InvokeInst::Create(Callee, NormalBB, UnwindBB, Args);
Value *Callee;
if (ConvertValIDToValue(PFTy, CalleeID, Callee, &PFS)) return true;
- // Set up the Attributes for the function.
+ // Set up the Attribute for the function.
SmallVector<AttributeWithIndex, 8> Attrs;
if (RetAttrs.hasAttributes())
Attrs.push_back(
AttributeWithIndex::get(AttributeSet::ReturnIndex,
- Attributes::get(Callee->getContext(),
+ Attribute::get(Callee->getContext(),
RetAttrs)));
SmallVector<Value*, 8> Args;
if (FnAttrs.hasAttributes())
Attrs.push_back(
AttributeWithIndex::get(AttributeSet::FunctionIndex,
- Attributes::get(Callee->getContext(),
+ Attribute::get(Callee->getContext(),
FnAttrs)));
- // Finish off the Attributes and check them
+ // Finish off the Attribute and check them
AttributeSet PAL = AttributeSet::get(Context, Attrs);
CallInst *CI = CallInst::Create(Callee, Args);
struct ParamInfo {
LocTy Loc;
Value *V;
- Attributes Attrs;
- ParamInfo(LocTy loc, Value *v, Attributes attrs)
+ Attribute Attrs;
+ ParamInfo(LocTy loc, Value *v, Attribute attrs)
: Loc(loc), V(v), Attrs(attrs) {}
};
bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
struct ArgInfo {
LocTy Loc;
Type *Ty;
- Attributes Attrs;
+ Attribute Attrs;
std::string Name;
- ArgInfo(LocTy L, Type *ty, Attributes Attr, const std::string &N)
+ ArgInfo(LocTy L, Type *ty, Attribute Attr, const std::string &N)
: Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
};
bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
return Error("Invalid ENTRY record");
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
- Attributes ReconstitutedAttr =
- Attributes::decodeLLVMAttributesForBitcode(Context, Record[i+1]);
+ Attribute ReconstitutedAttr =
+ Attribute::decodeLLVMAttributesForBitcode(Context, Record[i+1]);
Record[i+1] = ReconstitutedAttr.Raw();
}
AttrBuilder B(Record[i+1]);
if (B.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(Record[i],
- Attributes::get(Context, B)));
+ Attribute::get(Context, B)));
}
MAttributes.push_back(AttributeSet::get(Context, Attrs));
for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
const AttributeWithIndex &PAWI = A.getSlot(i);
Record.push_back(PAWI.Index);
- Record.push_back(Attributes::encodeLLVMAttributesForBitcode(PAWI.Attrs));
+ Record.push_back(Attribute::encodeLLVMAttributesForBitcode(PAWI.Attrs));
}
Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
unsigned &Entry = AttributeMap[PAL.getRawPointer()];
if (Entry == 0) {
// Never saw this before, add it.
- Attributes.push_back(PAL);
- Entry = Attributes.size();
+ Attribute.push_back(PAL);
+ Entry = Attribute.size();
}
}
typedef DenseMap<void*, unsigned> AttributeMapType;
AttributeMapType AttributeMap;
- std::vector<AttributeSet> Attributes;
+ std::vector<AttributeSet> Attribute;
/// GlobalBasicBlockIDs - This map memoizes the basic block ID's referenced by
/// the "getGlobalBasicBlockID" method.
return BasicBlocks;
}
const std::vector<AttributeSet> &getAttributes() const {
- return Attributes;
+ return Attribute;
}
/// getGlobalBasicBlockID - This returns the function-specific ID for the
/// between it and the return.
///
/// This function only tests target-independent requirements.
-bool llvm::isInTailCallPosition(ImmutableCallSite CS, Attributes CalleeRetAttr,
+bool llvm::isInTailCallPosition(ImmutableCallSite CS, Attribute CalleeRetAttr,
const TargetLowering &TLI) {
const Instruction *I = CS.getInstruction();
const BasicBlock *ExitBB = I->getParent();
// Conservatively require the attributes of the call to match those of
// the return. Ignore noalias because it doesn't affect the call sequence.
const Function *F = ExitBB->getParent();
- Attributes CallerRetAttr = F->getAttributes().getRetAttributes();
- if (AttrBuilder(CalleeRetAttr).removeAttribute(Attributes::NoAlias) !=
- AttrBuilder(CallerRetAttr).removeAttribute(Attributes::NoAlias))
+ Attribute CallerRetAttr = F->getAttributes().getRetAttributes();
+ if (AttrBuilder(CalleeRetAttr).removeAttribute(Attribute::NoAlias) !=
+ AttrBuilder(CallerRetAttr).removeAttribute(Attribute::NoAlias))
return false;
// It's not safe to eliminate the sign / zero extension of the return value.
- if (CallerRetAttr.hasAttribute(Attributes::ZExt) ||
- CallerRetAttr.hasAttribute(Attributes::SExt))
+ if (CallerRetAttr.hasAttribute(Attribute::ZExt) ||
+ CallerRetAttr.hasAttribute(Attribute::SExt))
return false;
// Otherwise, make sure the unmodified return value of I is the return value.
// Conservatively require the attributes of the call to match those of
// the return. Ignore noalias because it doesn't affect the call sequence.
- Attributes CallerRetAttr = F->getAttributes().getRetAttributes();
+ Attribute CallerRetAttr = F->getAttributes().getRetAttributes();
if (AttrBuilder(CallerRetAttr)
- .removeAttribute(Attributes::NoAlias).hasAttributes())
+ .removeAttribute(Attribute::NoAlias).hasAttributes())
return false;
// It's not safe to eliminate the sign / zero extension of the return value.
- if (CallerRetAttr.hasAttribute(Attributes::ZExt) ||
- CallerRetAttr.hasAttribute(Attributes::SExt))
+ if (CallerRetAttr.hasAttribute(Attribute::ZExt) ||
+ CallerRetAttr.hasAttribute(Attribute::SExt))
return false;
// Check if the only use is a function return node.
DIE *Parent;
- /// Attributes values.
+ /// Attribute values.
///
SmallVector<DIEValue*, 32> Values;
BumpPtrAllocator DIEValueAllocator;
//===--------------------------------------------------------------------===//
- // Attributes used to construct specific Dwarf sections.
+ // Attribute used to construct specific Dwarf sections.
//
CompileUnit *FirstCU;
MachineFunction *MF = MBB1->getParent();
if (EffectiveTailLen >= 2 &&
MF->getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize) &&
+ hasAttribute(Attribute::OptimizeForSize) &&
(I1 == MBB1->begin() || I2 == MBB2->begin()))
return true;
///
bool CodePlacementOpt::AlignLoops(MachineFunction &MF) {
const Function *F = MF.getFunction();
- if (F->getFnAttributes().hasAttribute(Attributes::OptimizeForSize))
+ if (F->getFnAttributes().hasAttribute(Attribute::OptimizeForSize))
return false;
unsigned Align = TLI->getPrefLoopAlignment();
// unnatural CFGs and backedges that were introduced purely because of the
// loop rotations done during this layout pass.
if (F.getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize))
+ hasAttribute(Attribute::OptimizeForSize))
return;
unsigned Align = TLI->getPrefLoopAlignment();
if (!Align)
MFInfo = 0;
FrameInfo = new (Allocator) MachineFrameInfo(*TM.getFrameLowering(),
TM.Options.RealignStack);
- if (Fn->getFnAttributes().hasAttribute(Attributes::StackAlignment))
+ if (Fn->getFnAttributes().hasAttribute(Attribute::StackAlignment))
FrameInfo->ensureMaxAlignment(Fn->getAttributes().
getFnAttributes().getStackAlignment());
ConstantPool = new (Allocator) MachineConstantPool(TM.getDataLayout());
Alignment = TM.getTargetLowering()->getMinFunctionAlignment();
// FIXME: Shouldn't use pref alignment if explicit alignment is set on Fn.
- if (!Fn->getFnAttributes().hasAttribute(Attributes::OptimizeForSize))
+ if (!Fn->getFnAttributes().hasAttribute(Attribute::OptimizeForSize))
Alignment = std::max(Alignment,
TM.getTargetLowering()->getPrefFunctionAlignment());
FunctionNumber = FunctionNum;
placeCSRSpillsAndRestores(Fn);
// Add the code to save and restore the callee saved registers
- if (!F->getFnAttributes().hasAttribute(Attributes::Naked))
+ if (!F->getFnAttributes().hasAttribute(Attribute::Naked))
insertCSRSpillsAndRestores(Fn);
// Allow the target machine to make final modifications to the function
// called functions. Because of this, calculateCalleeSavedRegisters()
// must be called before this function in order to set the AdjustsStack
// and MaxCallFrameSize variables.
- if (!F->getFnAttributes().hasAttribute(Attributes::Naked))
+ if (!F->getFnAttributes().hasAttribute(Attribute::Naked))
insertPrologEpilogCode(Fn);
// Replace all MO_FrameIndex operands with physical register references
return;
// In Naked functions we aren't going to save any registers.
- if (Fn.getFunction()->getFnAttributes().hasAttribute(Attributes::Naked))
+ if (Fn.getFunction()->getFnAttributes().hasAttribute(Attribute::Naked))
return;
std::vector<CalleeSavedInfo> CSI;
MachineFrameInfo *MFI = MF.getFrameInfo();
bool OptSize =
MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize);
+ hasAttribute(Attribute::OptimizeForSize);
FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Dst);
if (FI && !MFI->isFixedObjectIndex(FI->getIndex()))
DstAlignCanChange = true;
MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo *MFI = MF.getFrameInfo();
bool OptSize = MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize);
+ hasAttribute(Attribute::OptimizeForSize);
FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Dst);
if (FI && !MFI->isFixedObjectIndex(FI->getIndex()))
DstAlignCanChange = true;
MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo *MFI = MF.getFrameInfo();
bool OptSize = MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize);
+ hasAttribute(Attribute::OptimizeForSize);
FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Dst);
if (FI && !MFI->isFixedObjectIndex(FI->getIndex()))
DstAlignCanChange = true;
ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
const Function *F = I.getParent()->getParent();
- if (F->getRetAttributes().hasAttribute(Attributes::SExt))
+ if (F->getRetAttributes().hasAttribute(Attribute::SExt))
ExtendKind = ISD::SIGN_EXTEND;
- else if (F->getRetAttributes().hasAttribute(Attributes::ZExt))
+ else if (F->getRetAttributes().hasAttribute(Attribute::ZExt))
ExtendKind = ISD::ZERO_EXTEND;
if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger())
// 'inreg' on function refers to return value
ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy();
- if (F->getRetAttributes().hasAttribute(Attributes::InReg))
+ if (F->getRetAttributes().hasAttribute(Attribute::InReg))
Flags.setInReg();
// Propagate extension type if any
return DAG.getConstantFP(1.0, LHS.getValueType());
const Function *F = DAG.getMachineFunction().getFunction();
- if (!F->getFnAttributes().hasAttribute(Attributes::OptimizeForSize) ||
+ if (!F->getFnAttributes().hasAttribute(Attribute::OptimizeForSize) ||
// If optimizing for size, don't insert too many multiplies. This
// inserts up to 5 multiplies.
CountPopulation_32(Val)+Log2_32(Val) < 7) {
Entry.Node = ArgNode; Entry.Ty = V->getType();
unsigned attrInd = i - CS.arg_begin() + 1;
- Entry.isSExt = CS.paramHasAttr(attrInd, Attributes::SExt);
- Entry.isZExt = CS.paramHasAttr(attrInd, Attributes::ZExt);
- Entry.isInReg = CS.paramHasAttr(attrInd, Attributes::InReg);
- Entry.isSRet = CS.paramHasAttr(attrInd, Attributes::StructRet);
- Entry.isNest = CS.paramHasAttr(attrInd, Attributes::Nest);
- Entry.isByVal = CS.paramHasAttr(attrInd, Attributes::ByVal);
+ Entry.isSExt = CS.paramHasAttr(attrInd, Attribute::SExt);
+ Entry.isZExt = CS.paramHasAttr(attrInd, Attribute::ZExt);
+ Entry.isInReg = CS.paramHasAttr(attrInd, Attribute::InReg);
+ Entry.isSRet = CS.paramHasAttr(attrInd, Attribute::StructRet);
+ Entry.isNest = CS.paramHasAttr(attrInd, Attribute::Nest);
+ Entry.isByVal = CS.paramHasAttr(attrInd, Attribute::ByVal);
Entry.Alignment = CS.getParamAlignment(attrInd);
Args.push_back(Entry);
}
unsigned OriginalAlignment =
TD->getABITypeAlignment(ArgTy);
- if (F.getParamAttributes(Idx).hasAttribute(Attributes::ZExt))
+ if (F.getParamAttributes(Idx).hasAttribute(Attribute::ZExt))
Flags.setZExt();
- if (F.getParamAttributes(Idx).hasAttribute(Attributes::SExt))
+ if (F.getParamAttributes(Idx).hasAttribute(Attribute::SExt))
Flags.setSExt();
- if (F.getParamAttributes(Idx).hasAttribute(Attributes::InReg))
+ if (F.getParamAttributes(Idx).hasAttribute(Attribute::InReg))
Flags.setInReg();
- if (F.getParamAttributes(Idx).hasAttribute(Attributes::StructRet))
+ if (F.getParamAttributes(Idx).hasAttribute(Attribute::StructRet))
Flags.setSRet();
- if (F.getParamAttributes(Idx).hasAttribute(Attributes::ByVal)) {
+ if (F.getParamAttributes(Idx).hasAttribute(Attribute::ByVal)) {
Flags.setByVal();
PointerType *Ty = cast<PointerType>(I->getType());
Type *ElementTy = Ty->getElementType();
FrameAlign = TLI.getByValTypeAlignment(ElementTy);
Flags.setByValAlign(FrameAlign);
}
- if (F.getParamAttributes(Idx).hasAttribute(Attributes::Nest))
+ if (F.getParamAttributes(Idx).hasAttribute(Attribute::Nest))
Flags.setNest();
Flags.setOrigAlign(OriginalAlignment);
if (!I->use_empty()) {
ISD::NodeType AssertOp = ISD::DELETED_NODE;
- if (F.getParamAttributes(Idx).hasAttribute(Attributes::SExt))
+ if (F.getParamAttributes(Idx).hasAttribute(Attribute::SExt))
AssertOp = ISD::AssertSext;
- else if (F.getParamAttributes(Idx).hasAttribute(Attributes::ZExt))
+ else if (F.getParamAttributes(Idx).hasAttribute(Attribute::ZExt))
AssertOp = ISD::AssertZext;
ArgValues.push_back(getCopyFromParts(DAG, dl, &InVals[i],
/// type of the given function. This does not require a DAG or a return value,
/// and is suitable for use before any DAGs for the function are constructed.
/// TODO: Move this out of TargetLowering.cpp.
-void llvm::GetReturnInfo(Type* ReturnType, Attributes attr,
+void llvm::GetReturnInfo(Type* ReturnType, Attribute attr,
SmallVectorImpl<ISD::OutputArg> &Outs,
const TargetLowering &TLI) {
SmallVector<EVT, 4> ValueVTs;
EVT VT = ValueVTs[j];
ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
- if (attr.hasAttribute(Attributes::SExt))
+ if (attr.hasAttribute(Attribute::SExt))
ExtendKind = ISD::SIGN_EXTEND;
- else if (attr.hasAttribute(Attributes::ZExt))
+ else if (attr.hasAttribute(Attribute::ZExt))
ExtendKind = ISD::ZERO_EXTEND;
// FIXME: C calling convention requires the return type to be promoted to
// 'inreg' on function refers to return value
ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy();
- if (attr.hasAttribute(Attributes::InReg))
+ if (attr.hasAttribute(Attribute::InReg))
Flags.setInReg();
// Propagate extension type if any
- if (attr.hasAttribute(Attributes::SExt))
+ if (attr.hasAttribute(Attribute::SExt))
Flags.setSExt();
- else if (attr.hasAttribute(Attributes::ZExt))
+ else if (attr.hasAttribute(Attribute::ZExt))
Flags.setZExt();
for (unsigned i = 0; i < NumParts; ++i)
/// add a guard variable to functions that call alloca, and functions with
/// buffers larger than SSPBufferSize bytes.
bool StackProtector::RequiresStackProtector() const {
- if (F->getFnAttributes().hasAttribute(Attributes::StackProtectReq))
+ if (F->getFnAttributes().hasAttribute(Attribute::StackProtectReq))
return true;
- if (!F->getFnAttributes().hasAttribute(Attributes::StackProtect))
+ if (!F->getFnAttributes().hasAttribute(Attribute::StackProtect))
return false;
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
unsigned MaxDuplicateCount;
if (TailDuplicateSize.getNumOccurrences() == 0 &&
MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize))
+ hasAttribute(Attribute::OptimizeForSize))
MaxDuplicateCount = 1;
else
MaxDuplicateCount = TailDuplicateSize;
DWARFAbbreviationDeclaration::extract(DataExtractor data, uint32_t* offset_ptr,
uint32_t code) {
Code = code;
- Attributes.clear();
+ Attribute.clear();
if (Code) {
Tag = data.getULEB128(offset_ptr);
HasChildren = data.getU8(offset_ptr);
uint16_t form = data.getULEB128(offset_ptr);
if (attr && form)
- Attributes.push_back(DWARFAttribute(attr, form));
+ Attribute.push_back(DWARFAttribute(attr, form));
else
break;
}
else
OS << format("DW_TAG_Unknown_%x", getTag());
OS << "\tDW_CHILDREN_" << (hasChildren() ? "yes" : "no") << '\n';
- for (unsigned i = 0, e = Attributes.size(); i != e; ++i) {
+ for (unsigned i = 0, e = Attribute.size(); i != e; ++i) {
OS << '\t';
- const char *attrString = AttributeString(Attributes[i].getAttribute());
+ const char *attrString = AttributeString(Attribute[i].getAttribute());
if (attrString)
OS << attrString;
else
- OS << format("DW_AT_Unknown_%x", Attributes[i].getAttribute());
+ OS << format("DW_AT_Unknown_%x", Attribute[i].getAttribute());
OS << '\t';
- const char *formString = FormEncodingString(Attributes[i].getForm());
+ const char *formString = FormEncodingString(Attribute[i].getForm());
if (formString)
OS << formString;
else
- OS << format("DW_FORM_Unknown_%x", Attributes[i].getForm());
+ OS << format("DW_FORM_Unknown_%x", Attribute[i].getForm());
OS << '\n';
}
OS << '\n';
uint32_t
DWARFAbbreviationDeclaration::findAttributeIndex(uint16_t attr) const {
- for (uint32_t i = 0, e = Attributes.size(); i != e; ++i) {
- if (Attributes[i].getAttribute() == attr)
+ for (uint32_t i = 0, e = Attribute.size(); i != e; ++i) {
+ if (Attribute[i].getAttribute() == attr)
return i;
}
return -1U;
uint32_t Code;
uint32_t Tag;
bool HasChildren;
- SmallVector<DWARFAttribute, 8> Attributes;
+ SmallVector<DWARFAttribute, 8> Attribute;
public:
enum { InvalidCode = 0 };
DWARFAbbreviationDeclaration()
uint32_t getCode() const { return Code; }
uint32_t getTag() const { return Tag; }
bool hasChildren() const { return HasChildren; }
- uint32_t getNumAttributes() const { return Attributes.size(); }
+ uint32_t getNumAttributes() const { return Attribute.size(); }
uint16_t getAttrByIndex(uint32_t idx) const {
- return Attributes.size() > idx ? Attributes[idx].getAttribute() : 0;
+ return Attribute.size() > idx ? Attribute[idx].getAttribute() : 0;
}
uint16_t getFormByIndex(uint32_t idx) const {
- return Attributes.size() > idx ? Attributes[idx].getForm() : 0;
+ return Attribute.size() > idx ? Attribute[idx].getForm() : 0;
}
uint32_t findAttributeIndex(uint16_t attr) const;
bool isValid() const { return Code != 0 && Tag != 0; }
void dump(raw_ostream &OS) const;
const SmallVectorImpl<DWARFAttribute> &getAttributes() const {
- return Attributes;
+ return Attribute;
}
};
case DW_AT_APPLE_property: return "DW_AT_APPLE_property";
case DW_AT_APPLE_objc_complete_type: return "DW_AT_APPLE_objc_complete_type";
- // DWARF5 Fission Extension Attributes
+ // DWARF5 Fission Extension Attribute
case DW_AT_GNU_dwo_name: return "DW_AT_GNU_dwo_name";
case DW_AT_GNU_dwo_id: return "DW_AT_GNU_dwo_id";
case DW_AT_GNU_ranges_base: return "DW_AT_GNU_ranges_base";
if (Latency > 0 && Subtarget.isThumb2()) {
const MachineFunction *MF = DefMI->getParent()->getParent();
if (MF->getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize))
+ hasAttribute(Attribute::OptimizeForSize))
--Latency;
}
return Latency;
unsigned StackAlign = MF.getTarget().getFrameLowering()->getStackAlignment();
bool requiresRealignment =
((MFI->getMaxAlignment() > StackAlign) ||
- F->getFnAttributes().hasAttribute(Attributes::StackAlignment));
+ F->getFnAttributes().hasAttribute(Attribute::StackAlignment));
return requiresRealignment && canRealignStack(MF);
}
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
- if (CS.paramHasAttr(AttrInd, Attributes::SExt))
+ if (CS.paramHasAttr(AttrInd, Attribute::SExt))
Flags.setSExt();
- if (CS.paramHasAttr(AttrInd, Attributes::ZExt))
+ if (CS.paramHasAttr(AttrInd, Attribute::ZExt))
Flags.setZExt();
// FIXME: Only handle *easy* calls for now.
- if (CS.paramHasAttr(AttrInd, Attributes::InReg) ||
- CS.paramHasAttr(AttrInd, Attributes::StructRet) ||
- CS.paramHasAttr(AttrInd, Attributes::Nest) ||
- CS.paramHasAttr(AttrInd, Attributes::ByVal))
+ if (CS.paramHasAttr(AttrInd, Attribute::InReg) ||
+ CS.paramHasAttr(AttrInd, Attribute::StructRet) ||
+ CS.paramHasAttr(AttrInd, Attribute::Nest) ||
+ CS.paramHasAttr(AttrInd, Attribute::ByVal))
return false;
Type *ArgTy = (*i)->getType();
return;
// Naked functions don't spill callee-saved registers.
- if (MF.getFunction()->getFnAttributes().hasAttribute(Attributes::Naked))
+ if (MF.getFunction()->getFnAttributes().hasAttribute(Attribute::Naked))
return;
// We are planning to use NEON instructions vst1 / vld1.
// FIXME: handle tail calls differently.
unsigned CallOpc;
bool HasMinSizeAttr = MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::MinSize);
+ hasAttribute(Attribute::MinSize);
if (Subtarget->isThumb()) {
if ((!isDirect || isARMFunc) && !Subtarget->hasV5TOps())
CallOpc = ARMISD::CALL_NOLINK;
} else {
// Check whether we can use NEON instructions.
if (!MF->getFunction()->getFnAttributes().
- hasAttribute(Attributes::NoImplicitFloat) &&
+ hasAttribute(Attribute::NoImplicitFloat) &&
Subtarget->hasNEON()) {
if ((Align % 16 == 0) && SizeVal >= 16) {
ldrOpc = ARM::VLD1q32wb_fixed;
// See if we can use NEON instructions for this...
if ((!IsMemset || ZeroMemset) &&
Subtarget->hasNEON() &&
- !F->getFnAttributes().hasAttribute(Attributes::NoImplicitFloat)) {
+ !F->getFnAttributes().hasAttribute(Attribute::NoImplicitFloat)) {
bool Fast;
if (Size >= 16 &&
(memOpAlign(SrcAlign, DstAlign, 16) ||
// When -Oz is set, the function carries MinSize attribute.
MinimizeSize =
- MF.getFunction()->getFnAttributes().hasAttribute(Attributes::MinSize);
+ MF.getFunction()->getFnAttributes().hasAttribute(Attribute::MinSize);
bool Modified = false;
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
Out << " {\n AttrBuilder B;\n";
#define HANDLE_ATTR(X) \
- if (attrs.hasAttribute(Attributes::X)) \
- Out << " B.addAttribute(Attributes::" #X ");\n"; \
- attrs.removeAttribute(Attributes::X);
+ if (attrs.hasAttribute(Attribute::X)) \
+ Out << " B.addAttribute(Attribute::" #X ");\n"; \
+ attrs.removeAttribute(Attribute::X);
HANDLE_ATTR(SExt);
HANDLE_ATTR(ZExt);
HANDLE_ATTR(NonLazyBind);
HANDLE_ATTR(MinSize);
#undef HANDLE_ATTR
- if (attrs.hasAttribute(Attributes::StackAlignment))
+ if (attrs.hasAttribute(Attribute::StackAlignment))
Out << " B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n";
- attrs.removeAttribute(Attributes::StackAlignment);
+ attrs.removeAttribute(Attribute::StackAlignment);
assert(!attrs.hasAttributes() && "Unhandled attribute!");
- Out << " PAWI.Attrs = Attributes::get(mod->getContext(), B);\n }";
+ Out << " PAWI.Attrs = Attribute::get(mod->getContext(), B);\n }";
nl(Out);
Out << "Attrs.push_back(PAWI);";
nl(Out);
unsigned Idx = 1;
for (Function::arg_iterator AI = F.arg_begin(), AE = F.arg_end(); AI != AE;
++AI, ++Idx) {
- if (F.getParamAttributes(Idx).hasAttribute(Attributes::SExt)) {
+ if (F.getParamAttributes(Idx).hasAttribute(Attribute::SExt)) {
Argument* Arg = AI;
if (!isa<PointerType>(Arg->getType())) {
for (Instruction::use_iterator UI = Arg->use_begin();
}
if (PAL.getParamAttributes(paramIndex+1).
- hasAttribute(Attributes::ByVal) == false) {
+ hasAttribute(Attribute::ByVal) == false) {
// Just a scalar
const PointerType *PTy = dyn_cast<PointerType>(Ty);
if (isKernelFunc) {
// to newly created nodes. The SDNOdes for params have to
// appear in the same order as their order of appearance
// in the original function. "idx+1" holds that order.
- if (PAL.getParamAttributes(i+1).hasAttribute(Attributes::ByVal) == false) {
+ if (PAL.getParamAttributes(i+1).hasAttribute(Attribute::ByVal) == false) {
// A plain scalar.
if (isABI || isKernel) {
// If ABI, load from the param symbol
// SVR4, we also require a stack frame if we need to spill the CR,
// since this spill area is addressed relative to the stack pointer.
bool DisableRedZone = MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::NoRedZone);
+ hasAttribute(Attribute::NoRedZone);
// FIXME SVR4 The 32-bit SVR4 ABI has no red zone. However, it can
// still generate stackless code if all local vars are reg-allocated.
// Try: (FrameSize <= 224
// Naked functions have no stack frame pushed, so we don't have a frame
// pointer.
- if (MF.getFunction()->getFnAttributes().hasAttribute(Attributes::Naked))
+ if (MF.getFunction()->getFnAttributes().hasAttribute(Attribute::Naked))
return false;
return MF.getTarget().Options.DisableFramePointerElim(MF) ||
MFI->hasVarSizedObjects()) &&
MFI->getStackSize() &&
!MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::Naked);
+ hasAttribute(Attribute::Naked);
unsigned FrameReg = isPPC64 ? (is31 ? PPC::X31 : PPC::X1) :
(is31 ? PPC::R31 : PPC::R1);
SDValue FrameAddr = DAG.getCopyFromReg(DAG.getEntryNode(), dl, FrameReg,
// to Offset to get the correct offset.
// Naked functions have stack size 0, although getStackSize may not reflect that
// because we didn't call all the pieces that compute it for naked functions.
- if (!MF.getFunction()->getFnAttributes().hasAttribute(Attributes::Naked))
+ if (!MF.getFunction()->getFnAttributes().hasAttribute(Attribute::Naked))
Offset += MFI->getStackSize();
// If we can, encode the offset directly into the instruction. If this is a
CallingConv::ID CC = CS.getCallingConv();
if (CC == CallingConv::Fast || CC == CallingConv::GHC)
return 0;
- if (!CS.paramHasAttr(1, Attributes::StructRet))
+ if (!CS.paramHasAttr(1, Attribute::StructRet))
return 0;
- if (CS.paramHasAttr(1, Attributes::InReg))
+ if (CS.paramHasAttr(1, Attribute::InReg))
return 0;
return 4;
}
Value *ArgVal = *i;
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
- if (CS.paramHasAttr(AttrInd, Attributes::SExt))
+ if (CS.paramHasAttr(AttrInd, Attribute::SExt))
Flags.setSExt();
- if (CS.paramHasAttr(AttrInd, Attributes::ZExt))
+ if (CS.paramHasAttr(AttrInd, Attribute::ZExt))
Flags.setZExt();
- if (CS.paramHasAttr(AttrInd, Attributes::ByVal)) {
+ if (CS.paramHasAttr(AttrInd, Attribute::ByVal)) {
PointerType *Ty = cast<PointerType>(ArgVal->getType());
Type *ElementTy = Ty->getElementType();
unsigned FrameSize = TD.getTypeAllocSize(ElementTy);
return false;
}
- if (CS.paramHasAttr(AttrInd, Attributes::InReg))
+ if (CS.paramHasAttr(AttrInd, Attribute::InReg))
Flags.setInReg();
- if (CS.paramHasAttr(AttrInd, Attributes::Nest))
+ if (CS.paramHasAttr(AttrInd, Attribute::Nest))
Flags.setNest();
// If this is an i1/i8/i16 argument, promote to i32 to avoid an extra
ISD::InputArg MyFlags;
MyFlags.VT = RegisterVT.getSimpleVT();
MyFlags.Used = !CS.getInstruction()->use_empty();
- if (CS.paramHasAttr(0, Attributes::SExt))
+ if (CS.paramHasAttr(0, Attribute::SExt))
MyFlags.Flags.setSExt();
- if (CS.paramHasAttr(0, Attributes::ZExt))
+ if (CS.paramHasAttr(0, Attribute::ZExt))
MyFlags.Flags.setZExt();
- if (CS.paramHasAttr(0, Attributes::InReg))
+ if (CS.paramHasAttr(0, Attribute::InReg))
MyFlags.Flags.setInReg();
Ins.push_back(MyFlags);
}
// function, and use up to 128 bytes of stack space, don't have a frame
// pointer, calls, or dynamic alloca then we do not need to adjust the
// stack pointer (we fit in the Red Zone).
- if (Is64Bit && !Fn->getFnAttributes().hasAttribute(Attributes::NoRedZone) &&
+ if (Is64Bit && !Fn->getFnAttributes().hasAttribute(Attribute::NoRedZone) &&
!RegInfo->needsStackRealignment(MF) &&
!MFI->hasVarSizedObjects() && // No dynamic alloca.
!MFI->adjustsStack() && // No calls.
void X86DAGToDAGISel::PreprocessISelDAG() {
// OptForSize is used in pattern predicates that isel is matching.
OptForSize = MF->getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize);
+ hasAttribute(Attribute::OptimizeForSize);
for (SelectionDAG::allnodes_iterator I = CurDAG->allnodes_begin(),
E = CurDAG->allnodes_end(); I != E; ) {
MachineFunction &MF) const {
const Function *F = MF.getFunction();
if ((!IsMemset || ZeroMemset) &&
- !F->getFnAttributes().hasAttribute(Attributes::NoImplicitFloat)) {
+ !F->getFnAttributes().hasAttribute(Attribute::NoImplicitFloat)) {
if (Size >= 16 &&
(Subtarget->isUnalignedMemAccessFast() ||
((DstAlign == 0 || DstAlign >= 16) &&
TotalNumIntRegs);
bool NoImplicitFloatOps = Fn->getFnAttributes().
- hasAttribute(Attributes::NoImplicitFloat);
+ hasAttribute(Attribute::NoImplicitFloat);
assert(!(NumXMMRegs && !Subtarget->hasSSE1()) &&
"SSE register cannot be used when SSE is disabled!");
assert(!(NumXMMRegs && MF.getTarget().Options.UseSoftFloat &&
} else if (Subtarget->isPICStyleRIPRel() &&
isa<Function>(GV) &&
cast<Function>(GV)->getFnAttributes().
- hasAttribute(Attributes::NonLazyBind)) {
+ hasAttribute(Attribute::NonLazyBind)) {
// If the function is marked as non-lazy, generate an indirect call
// which loads from the GOT directly. This avoids runtime overhead
// at the cost of eager binding (and one extra byte of encoding).
bool HasInt256 = Subtarget->hasInt256();
MachineFunction &MF = DAG.getMachineFunction();
bool OptForSize = MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize);
+ hasAttribute(Attribute::OptimizeForSize);
assert(VT.getSizeInBits() != 64 && "Can't lower MMX shuffles");
assert(!getTargetMachine().Options.UseSoftFloat &&
!(DAG.getMachineFunction()
.getFunction()->getFnAttributes()
- .hasAttribute(Attributes::NoImplicitFloat)) &&
+ .hasAttribute(Attribute::NoImplicitFloat)) &&
Subtarget->hasSSE1());
}
for (FunctionType::param_iterator I = FTy->param_begin(),
E = FTy->param_end(); I != E; ++I, ++Idx)
- if (Attrs.getParamAttributes(Idx).hasAttribute(Attributes::InReg))
+ if (Attrs.getParamAttributes(Idx).hasAttribute(Attribute::InReg))
// FIXME: should only count parameters that are lowered to integers.
InRegCount += (TD->getTypeSizeInBits(*I) + 31) / 32;
const Function *F = DAG.getMachineFunction().getFunction();
bool NoImplicitFloatOps = F->getFnAttributes().
- hasAttribute(Attributes::NoImplicitFloat);
+ hasAttribute(Attribute::NoImplicitFloat);
bool F64IsLegal = !DAG.getTarget().Options.UseSoftFloat && !NoImplicitFloatOps
&& Subtarget->hasSSE2();
if ((VT.isVector() ||
// Unless optimizing for size, don't fold to avoid partial
// register update stalls
if (!MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize) &&
+ hasAttribute(Attribute::OptimizeForSize) &&
hasPartialRegUpdate(MI->getOpcode()))
return 0;
// Unless optimizing for size, don't fold to avoid partial
// register update stalls
if (!MF.getFunction()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize) &&
+ hasAttribute(Attribute::OptimizeForSize) &&
hasPartialRegUpdate(MI->getOpcode()))
return 0;
unsigned StackAlign = TM.getFrameLowering()->getStackAlignment();
bool requiresRealignment =
((MFI->getMaxAlignment() > StackAlign) ||
- F->getFnAttributes().hasAttribute(Attributes::StackAlignment));
+ F->getFnAttributes().hasAttribute(Attribute::StackAlignment));
// If we've requested that we force align the stack do so now.
if (ForceStackAlign)
const AttributeSet &PAL = MF.getFunction()->getAttributes();
for (unsigned I = 0, E = PAL.getNumAttrs(); I != E; ++I)
- if (PAL.getAttributesAtIndex(I).hasAttribute(Attributes::Nest)) {
+ if (PAL.getAttributesAtIndex(I).hasAttribute(Attribute::Nest)) {
loadFromStack(MBB, MBBI, XCore::R11, 0, dl, TII);
break;
}
SmallPtrSet<Argument*, 8> ByValArgsToTransform;
for (unsigned i = 0; i != PointerArgs.size(); ++i) {
bool isByVal=F->getParamAttributes(PointerArgs[i].second+1).
- hasAttribute(Attributes::ByVal);
+ hasAttribute(Attribute::ByVal);
Argument *PtrArg = PointerArgs[i].first;
Type *AgTy = cast<PointerType>(PtrArg->getType())->getElementType();
// what the new GEP/Load instructions we are inserting look like.
std::map<IndicesVector, LoadInst*> OriginalLoads;
- // Attributes - Keep track of the parameter attributes for the arguments
+ // Attribute - Keep track of the parameter attributes for the arguments
// that we are *not* promoting. For the ones that we do promote, the parameter
// attributes are lost
SmallVector<AttributeWithIndex, 8> AttributesVec;
const AttributeSet &PAL = F->getAttributes();
// Add any return attributes.
- Attributes attrs = PAL.getRetAttributes();
+ Attribute attrs = PAL.getRetAttributes();
if (attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
attrs));
} else if (!ArgsToPromote.count(I)) {
// Unchanged argument
Params.push_back(I->getType());
- Attributes attrs = PAL.getParamAttributes(ArgIndex);
+ Attribute attrs = PAL.getParamAttributes(ArgIndex);
if (attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), attrs));
} else if (I->use_empty()) {
const AttributeSet &CallPAL = CS.getAttributes();
// Add any return attributes.
- Attributes attrs = CallPAL.getRetAttributes();
+ Attribute attrs = CallPAL.getRetAttributes();
if (attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
attrs));
if (!ArgsToPromote.count(I) && !ByValArgsToTransform.count(I)) {
Args.push_back(*AI); // Unmodified argument
- Attributes Attrs = CallPAL.getParamAttributes(ArgIndex);
+ Attribute Attrs = CallPAL.getParamAttributes(ArgIndex);
if (Attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
// Push any varargs arguments on the list.
for (; AI != CS.arg_end(); ++AI, ++ArgIndex) {
Args.push_back(*AI);
- Attributes Attrs = CallPAL.getParamAttributes(ArgIndex);
+ Attribute Attrs = CallPAL.getParamAttributes(ArgIndex);
if (Attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
}
SmallVector<AttributeWithIndex, 8> AttributesVec;
for (unsigned i = 0; PAL.getSlot(i).Index <= NumArgs; ++i)
AttributesVec.push_back(PAL.getSlot(i));
- Attributes FnAttrs = PAL.getFnAttributes();
+ Attribute FnAttrs = PAL.getFnAttributes();
if (FnAttrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
FnAttrs));
const AttributeSet &PAL = F->getAttributes();
// The existing function return attributes.
- Attributes RAttrs = PAL.getRetAttributes();
- Attributes FnAttrs = PAL.getFnAttributes();
+ Attribute RAttrs = PAL.getRetAttributes();
+ Attribute FnAttrs = PAL.getFnAttributes();
// Find out the new return value.
// required when new return value attributes are added.
if (NRetTy->isVoidTy())
RAttrs =
- Attributes::get(NRetTy->getContext(), AttrBuilder(RAttrs).
- removeAttributes(Attributes::typeIncompatible(NRetTy)));
+ Attribute::get(NRetTy->getContext(), AttrBuilder(RAttrs).
+ removeAttributes(Attribute::typeIncompatible(NRetTy)));
else
assert(!AttrBuilder(RAttrs).
- hasAttributes(Attributes::typeIncompatible(NRetTy)) &&
+ hasAttributes(Attribute::typeIncompatible(NRetTy)) &&
"Return attributes no longer compatible?");
if (RAttrs.hasAttributes())
// Get the original parameter attributes (skipping the first one, that is
// for the return value.
- Attributes Attrs = PAL.getParamAttributes(i + 1);
+ Attribute Attrs = PAL.getParamAttributes(i + 1);
if (Attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), Attrs));
} else {
const AttributeSet &CallPAL = CS.getAttributes();
// The call return attributes.
- Attributes RAttrs = CallPAL.getRetAttributes();
- Attributes FnAttrs = CallPAL.getFnAttributes();
+ Attribute RAttrs = CallPAL.getRetAttributes();
+ Attribute FnAttrs = CallPAL.getFnAttributes();
// Adjust in case the function was changed to return void.
RAttrs =
- Attributes::get(NF->getContext(), AttrBuilder(RAttrs).
- removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
+ Attribute::get(NF->getContext(), AttrBuilder(RAttrs).
+ removeAttributes(Attribute::typeIncompatible(NF->getReturnType())));
if (RAttrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
RAttrs));
if (ArgAlive[i]) {
Args.push_back(*I);
// Get original parameter attributes, but skip return attributes.
- Attributes Attrs = CallPAL.getParamAttributes(i + 1);
+ Attribute Attrs = CallPAL.getParamAttributes(i + 1);
if (Attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
}
// Push any varargs arguments on the list. Don't forget their attributes.
for (CallSite::arg_iterator E = CS.arg_end(); I != E; ++I, ++i) {
Args.push_back(*I);
- Attributes Attrs = CallPAL.getParamAttributes(i + 1);
+ Attribute Attrs = CallPAL.getParamAttributes(i + 1);
if (Attrs.hasAttributes())
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
}
// Clear out any existing attributes.
AttrBuilder B;
- B.addAttribute(Attributes::ReadOnly)
- .addAttribute(Attributes::ReadNone);
+ B.addAttribute(Attribute::ReadOnly)
+ .addAttribute(Attribute::ReadNone);
F->removeAttribute(AttributeSet::FunctionIndex,
- Attributes::get(F->getContext(), B));
+ Attribute::get(F->getContext(), B));
// Add in the new attribute.
B.clear();
- B.addAttribute(ReadsMemory ? Attributes::ReadOnly : Attributes::ReadNone);
+ B.addAttribute(ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone);
F->addAttribute(AttributeSet::FunctionIndex,
- Attributes::get(F->getContext(), B));
+ Attribute::get(F->getContext(), B));
if (ReadsMemory)
++NumReadOnly;
ArgumentGraph AG;
AttrBuilder B;
- B.addAttribute(Attributes::NoCapture);
+ B.addAttribute(Attribute::NoCapture);
// Check each function in turn, determining which pointer arguments are not
// captured.
for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end();
A != E; ++A) {
if (A->getType()->isPointerTy() && !A->hasNoCaptureAttr()) {
- A->addAttr(Attributes::get(F->getContext(), B));
+ A->addAttr(Attribute::get(F->getContext(), B));
++NumNoCapture;
Changed = true;
}
if (!Tracker.Captured) {
if (Tracker.Uses.empty()) {
// If it's trivially not captured, mark it nocapture now.
- A->addAttr(Attributes::get(F->getContext(), B));
+ A->addAttr(Attribute::get(F->getContext(), B));
++NumNoCapture;
Changed = true;
} else {
ArgumentSCC[0]->Uses[0] == ArgumentSCC[0]) {
ArgumentSCC[0]->
Definition->
- addAttr(Attributes::get(ArgumentSCC[0]->Definition->getContext(), B));
+ addAttr(Attribute::get(ArgumentSCC[0]->Definition->getContext(), B));
++NumNoCapture;
Changed = true;
}
for (unsigned i = 0, e = ArgumentSCC.size(); i != e; ++i) {
Argument *A = ArgumentSCC[i]->Definition;
- A->addAttr(Attributes::get(A->getContext(), B));
+ A->addAttr(Attribute::get(A->getContext(), B));
++NumNoCapture;
Changed = true;
}
case Instruction::Call:
case Instruction::Invoke: {
CallSite CS(RVI);
- if (CS.paramHasAttr(0, Attributes::NoAlias))
+ if (CS.paramHasAttr(0, Attribute::NoAlias))
break;
if (CS.getCalledFunction() &&
SCCNodes.count(CS.getCalledFunction()))
static AttributeSet StripNest(LLVMContext &C, const AttributeSet &Attrs) {
for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
- if (!Attrs.getSlot(i).Attrs.hasAttribute(Attributes::Nest))
+ if (!Attrs.getSlot(i).Attrs.hasAttribute(Attribute::Nest))
continue;
// There can be only one.
return Attrs.removeAttr(C, Attrs.getSlot(i).Index,
- Attributes::get(C, Attributes::Nest));
+ Attribute::get(C, Attribute::Nest));
}
return Attrs;
Changed = true;
}
- if (F->getAttributes().hasAttrSomewhere(Attributes::Nest) &&
+ if (F->getAttributes().hasAttrSomewhere(Attribute::Nest) &&
!F->hasAddressTaken()) {
// The function is not used by a trampoline intrinsic, so it is safe
// to remove the 'nest' attribute.
// that are viable for inlining. FIXME: We shouldn't even get here for
// declarations.
if (Callee && !Callee->isDeclaration() &&
- Callee->getFnAttributes().hasAttribute(Attributes::AlwaysInline) &&
+ Callee->getFnAttributes().hasAttribute(Attribute::AlwaysInline) &&
CA.isInlineViable(*Callee))
return InlineCost::getAlways();
// If the inlined function had a higher stack protection level than the
// calling function, then bump up the caller's stack protection level.
- if (Callee->getFnAttributes().hasAttribute(Attributes::StackProtectReq))
- Caller->addFnAttr(Attributes::StackProtectReq);
- else if (Callee->getFnAttributes().hasAttribute(Attributes::StackProtect) &&
- !Caller->getFnAttributes().hasAttribute(Attributes::StackProtectReq))
- Caller->addFnAttr(Attributes::StackProtect);
+ if (Callee->getFnAttributes().hasAttribute(Attribute::StackProtectReq))
+ Caller->addFnAttr(Attribute::StackProtectReq);
+ else if (Callee->getFnAttributes().hasAttribute(Attribute::StackProtect) &&
+ !Caller->getFnAttributes().hasAttribute(Attribute::StackProtectReq))
+ Caller->addFnAttr(Attribute::StackProtect);
// Look at all of the allocas that we inlined through this call site. If we
// have already inlined other allocas through other calls into this function,
// would decrease the threshold.
Function *Caller = CS.getCaller();
bool OptSize = Caller && !Caller->isDeclaration() &&
- Caller->getFnAttributes().hasAttribute(Attributes::OptimizeForSize);
+ Caller->getFnAttributes().hasAttribute(Attribute::OptimizeForSize);
if (!(InlineLimit.getNumOccurrences() > 0) && OptSize &&
OptSizeThreshold < thres)
thres = OptSizeThreshold;
// and the caller does not need to minimize its size.
Function *Callee = CS.getCalledFunction();
bool InlineHint = Callee && !Callee->isDeclaration() &&
- Callee->getFnAttributes().hasAttribute(Attributes::InlineHint);
+ Callee->getFnAttributes().hasAttribute(Attribute::InlineHint);
if (InlineHint && HintThreshold > thres
- && !Caller->getFnAttributes().hasAttribute(Attributes::MinSize))
+ && !Caller->getFnAttributes().hasAttribute(Attribute::MinSize))
thres = HintThreshold;
return thres;
// about always-inline functions. This is a bit of a hack to share code
// between here and the InlineAlways pass.
if (AlwaysInlineOnly &&
- !F->getFnAttributes().hasAttribute(Attributes::AlwaysInline))
+ !F->getFnAttributes().hasAttribute(Attribute::AlwaysInline))
continue;
// If the only remaining users of the function are dead constants, remove
AttrBuilder NewAttributes;
if (!SCCMightUnwind)
- NewAttributes.addAttribute(Attributes::NoUnwind);
+ NewAttributes.addAttribute(Attribute::NoUnwind);
if (!SCCMightReturn)
- NewAttributes.addAttribute(Attributes::NoReturn);
+ NewAttributes.addAttribute(Attribute::NoReturn);
Function *F = (*I)->getFunction();
const AttributeSet &PAL = F->getAttributes();
const AttributeSet &NPAL = PAL.addAttr(F->getContext(), ~0,
- Attributes::get(F->getContext(),
+ Attribute::get(F->getContext(),
NewAttributes));
if (PAL != NPAL) {
MadeChange = true;
if (!CallerPAL.isEmpty() && !Caller->use_empty()) {
AttrBuilder RAttrs = CallerPAL.getRetAttributes();
- if (RAttrs.hasAttributes(Attributes::typeIncompatible(NewRetTy)))
+ if (RAttrs.hasAttributes(Attribute::typeIncompatible(NewRetTy)))
return false; // Attribute not compatible with transformed value.
}
if (!CastInst::isCastable(ActTy, ParamTy))
return false; // Cannot transform this parameter value.
- Attributes Attrs = CallerPAL.getParamAttributes(i + 1);
+ Attribute Attrs = CallerPAL.getParamAttributes(i + 1);
if (AttrBuilder(Attrs).
- hasAttributes(Attributes::typeIncompatible(ParamTy)))
+ hasAttributes(Attribute::typeIncompatible(ParamTy)))
return false; // Attribute not compatible with transformed value.
// If the parameter is passed as a byval argument, then we have to have a
// sized type and the sized type has to have the same size as the old type.
- if (ParamTy != ActTy && Attrs.hasAttribute(Attributes::ByVal)) {
+ if (ParamTy != ActTy && Attrs.hasAttribute(Attribute::ByVal)) {
PointerType *ParamPTy = dyn_cast<PointerType>(ParamTy);
if (ParamPTy == 0 || !ParamPTy->getElementType()->isSized() || TD == 0)
return false;
for (unsigned i = CallerPAL.getNumSlots(); i; --i) {
if (CallerPAL.getSlot(i - 1).Index <= FT->getNumParams())
break;
- Attributes PAttrs = CallerPAL.getSlot(i - 1).Attrs;
+ Attribute PAttrs = CallerPAL.getSlot(i - 1).Attrs;
if (PAttrs.hasIncompatibleWithVarArgsAttrs())
return false;
}
// If the return value is not being used, the type may not be compatible
// with the existing attributes. Wipe out any problematic attributes.
- RAttrs.removeAttributes(Attributes::typeIncompatible(NewRetTy));
+ RAttrs.removeAttributes(Attribute::typeIncompatible(NewRetTy));
// Add the new return attributes.
if (RAttrs.hasAttributes())
attrVec.push_back(
AttributeWithIndex::get(AttributeSet::ReturnIndex,
- Attributes::get(FT->getContext(), RAttrs)));
+ Attribute::get(FT->getContext(), RAttrs)));
AI = CS.arg_begin();
for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
}
// Add any parameter attributes.
- Attributes PAttrs = CallerPAL.getParamAttributes(i + 1);
+ Attribute PAttrs = CallerPAL.getParamAttributes(i + 1);
if (PAttrs.hasAttributes())
attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs));
}
}
// Add any parameter attributes.
- Attributes PAttrs = CallerPAL.getParamAttributes(i + 1);
+ Attribute PAttrs = CallerPAL.getParamAttributes(i + 1);
if (PAttrs.hasAttributes())
attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs));
}
}
}
- Attributes FnAttrs = CallerPAL.getFnAttributes();
+ Attribute FnAttrs = CallerPAL.getFnAttributes();
if (FnAttrs.hasAttributes())
attrVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
FnAttrs));
// If the call already has the 'nest' attribute somewhere then give up -
// otherwise 'nest' would occur twice after splicing in the chain.
for (unsigned I = 0, E = Attrs.getNumAttrs(); I != E; ++I)
- if (Attrs.getAttributesAtIndex(I).hasAttribute(Attributes::Nest))
+ if (Attrs.getAttributesAtIndex(I).hasAttribute(Attribute::Nest))
return 0;
assert(Tramp &&
if (!NestAttrs.isEmpty()) {
unsigned NestIdx = 1;
Type *NestTy = 0;
- Attributes NestAttr;
+ Attribute NestAttr;
// Look for a parameter marked with the 'nest' attribute.
for (FunctionType::param_iterator I = NestFTy->param_begin(),
E = NestFTy->param_end(); I != E; ++NestIdx, ++I)
- if (NestAttrs.getParamAttributes(NestIdx).hasAttribute(Attributes::Nest)){
+ if (NestAttrs.getParamAttributes(NestIdx).hasAttribute(Attribute::Nest)){
// Record the parameter type and any other attributes.
NestTy = *I;
NestAttr = NestAttrs.getParamAttributes(NestIdx);
// mean appending it. Likewise for attributes.
// Add any result attributes.
- Attributes Attr = Attrs.getRetAttributes();
+ Attribute Attr = Attrs.getRetAttributes();
if (Attr.hasAttributes())
NewAttrs.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
Attr));
// If needed, insert __asan_init before checking for AddressSafety attr.
maybeInsertAsanInitAtFunctionEntry(F);
- if (!F.getFnAttributes().hasAttribute(Attributes::AddressSafety))
+ if (!F.getFnAttributes().hasAttribute(Attribute::AddressSafety))
return false;
if (!ClDebugFunc.empty() && ClDebugFunc != F.getName())
WriteoutF = Function::Create(WriteoutFTy, GlobalValue::InternalLinkage,
"__llvm_gcov_writeout", M);
WriteoutF->setUnnamedAddr(true);
- WriteoutF->addFnAttr(Attributes::NoInline);
+ WriteoutF->addFnAttr(Attribute::NoInline);
if (NoRedZone)
- WriteoutF->addFnAttr(Attributes::NoRedZone);
+ WriteoutF->addFnAttr(Attribute::NoRedZone);
BasicBlock *BB = BasicBlock::Create(*Ctx, "entry", WriteoutF);
IRBuilder<> Builder(BB);
"__llvm_gcov_init", M);
F->setUnnamedAddr(true);
F->setLinkage(GlobalValue::InternalLinkage);
- F->addFnAttr(Attributes::NoInline);
+ F->addFnAttr(Attribute::NoInline);
if (NoRedZone)
- F->addFnAttr(Attributes::NoRedZone);
+ F->addFnAttr(Attribute::NoRedZone);
BB = BasicBlock::Create(*Ctx, "entry", F);
Builder.SetInsertPoint(BB);
cast<Function>(GCOVProfiler::getIncrementIndirectCounterFunc());
Fn->setUnnamedAddr(true);
Fn->setLinkage(GlobalValue::InternalLinkage);
- Fn->addFnAttr(Attributes::NoInline);
+ Fn->addFnAttr(Attribute::NoInline);
if (NoRedZone)
- Fn->addFnAttr(Attributes::NoRedZone);
+ Fn->addFnAttr(Attribute::NoRedZone);
Type *Int32Ty = Type::getInt32Ty(*Ctx);
Type *Int64Ty = Type::getInt64Ty(*Ctx);
else
FlushF->setLinkage(GlobalValue::InternalLinkage);
FlushF->setUnnamedAddr(true);
- FlushF->addFnAttr(Attributes::NoInline);
+ FlushF->addFnAttr(Attribute::NoInline);
if (NoRedZone)
- FlushF->addFnAttr(Attributes::NoRedZone);
+ FlushF->addFnAttr(Attribute::NoRedZone);
BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF);
if (Function *Func = Call->getCalledFunction()) {
// Clear out readonly/readnone attributes.
AttrBuilder B;
- B.addAttribute(Attributes::ReadOnly)
- .addAttribute(Attributes::ReadNone);
+ B.addAttribute(Attribute::ReadOnly)
+ .addAttribute(Attribute::ReadNone);
Func->removeAttribute(AttributeSet::FunctionIndex,
- Attributes::get(Func->getContext(), B));
+ Attribute::get(Func->getContext(), B));
}
}
IRBuilder<> IRB(&I);
Value *ArgShadowBase = getShadowPtrForArgument(A, IRB, ArgOffset);
DEBUG(dbgs() << " Arg#" << i << ": " << *A <<
" Shadow: " << *ArgShadow << "\n");
- if (CS.paramHasAttr(i + 1, Attributes::ByVal)) {
+ if (CS.paramHasAttr(i + 1, Attribute::ByVal)) {
assert(A->getType()->isPointerTy() &&
"ByVal argument is not a pointer!");
Size = MS.TD->getTypeAllocSize(A->getType()->getPointerElementType());
// Clear out readonly/readnone attributes.
AttrBuilder B;
- B.addAttribute(Attributes::ReadOnly)
- .addAttribute(Attributes::ReadNone);
+ B.addAttribute(Attribute::ReadOnly)
+ .addAttribute(Attribute::ReadNone);
F.removeAttribute(AttributeSet::FunctionIndex,
- Attributes::get(F.getContext(), B));
+ Attribute::get(F.getContext(), B));
return Visitor.runOnFunction();
}
TLInfo = &getAnalysis<TargetLibraryInfo>();
DT = getAnalysisIfAvailable<DominatorTree>();
PFI = getAnalysisIfAvailable<ProfileInfo>();
- OptSize = F.getFnAttributes().hasAttribute(Attributes::OptimizeForSize);
+ OptSize = F.getFnAttributes().hasAttribute(Attribute::OptimizeForSize);
/// This optimization identifies DIV instructions that can be
/// profitably bypassed and carried out with a shorter, faster divide.
// It's not safe to eliminate the sign / zero extension of the return value.
// See llvm::isInTailCallPosition().
const Function *F = BB->getParent();
- Attributes CallerRetAttr = F->getAttributes().getRetAttributes();
- if (CallerRetAttr.hasAttribute(Attributes::ZExt) ||
- CallerRetAttr.hasAttribute(Attributes::SExt))
+ Attribute CallerRetAttr = F->getAttributes().getRetAttributes();
+ if (CallerRetAttr.hasAttribute(Attribute::ZExt) ||
+ CallerRetAttr.hasAttribute(Attribute::SExt))
return false;
// Make sure there are no instructions between the PHI and return, or that the
// Conservatively require the attributes of the call to match those of the
// return. Ignore noalias because it doesn't affect the call sequence.
- Attributes CalleeRetAttr = CS.getAttributes().getRetAttributes();
+ Attribute CalleeRetAttr = CS.getAttributes().getRetAttributes();
if (AttrBuilder(CalleeRetAttr).
- removeAttribute(Attributes::NoAlias) !=
+ removeAttribute(Attribute::NoAlias) !=
AttrBuilder(CallerRetAttr).
- removeAttribute(Attributes::NoAlias))
+ removeAttribute(Attribute::NoAlias))
continue;
// Make sure the call instruction is followed by an unconditional branch to
unsigned Threshold = CurrentThreshold;
if (!UserThreshold &&
Header->getParent()->getFnAttributes().
- hasAttribute(Attributes::OptimizeForSize))
+ hasAttribute(Attribute::OptimizeForSize))
Threshold = OptSizeUnrollThreshold;
// Find trip count and trip multiple if count is not available
// Do not do non-trivial unswitch while optimizing for size.
if (OptimizeForSize ||
- F->getFnAttributes().hasAttribute(Attributes::OptimizeForSize))
+ F->getFnAttributes().hasAttribute(Attribute::OptimizeForSize))
return false;
UnswitchNontrivialCondition(LoopCond, Val, currentLoop);
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- AttributeSet Attributes =
+ AttributeSet Attribute =
AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(C, Attributes::NoUnwind));
+ Attribute::get(C, Attribute::NoUnwind));
RetainRVCallee =
M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy,
- Attributes);
+ Attribute);
}
return RetainRVCallee;
}
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- AttributeSet Attributes =
+ AttributeSet Attribute =
AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(C, Attributes::NoUnwind));
+ Attribute::get(C, Attribute::NoUnwind));
AutoreleaseRVCallee =
M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy,
- Attributes);
+ Attribute);
}
return AutoreleaseRVCallee;
}
if (!ReleaseCallee) {
LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
- AttributeSet Attributes =
+ AttributeSet Attribute =
AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(C, Attributes::NoUnwind));
+ Attribute::get(C, Attribute::NoUnwind));
ReleaseCallee =
M->getOrInsertFunction(
"objc_release",
FunctionType::get(Type::getVoidTy(C), Params, /*isVarArg=*/false),
- Attributes);
+ Attribute);
}
return ReleaseCallee;
}
if (!RetainCallee) {
LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
- AttributeSet Attributes =
+ AttributeSet Attribute =
AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(C, Attributes::NoUnwind));
+ Attribute::get(C, Attribute::NoUnwind));
RetainCallee =
M->getOrInsertFunction(
"objc_retain",
FunctionType::get(Params[0], Params, /*isVarArg=*/false),
- Attributes);
+ Attribute);
}
return RetainCallee;
}
if (!AutoreleaseCallee) {
LLVMContext &C = M->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
- AttributeSet Attributes =
+ AttributeSet Attribute =
AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(C, Attributes::NoUnwind));
+ Attribute::get(C, Attribute::NoUnwind));
AutoreleaseCallee =
M->getOrInsertFunction(
"objc_autorelease",
FunctionType::get(Params[0], Params, /*isVarArg=*/false),
- Attributes);
+ Attribute);
}
return AutoreleaseCallee;
}
Type *I8XX = PointerType::getUnqual(I8X);
Type *Params[] = { I8XX, I8X };
- AttributeSet Attributes = AttributeSet()
+ AttributeSet Attribute = AttributeSet()
.addAttr(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(C, Attributes::NoUnwind))
- .addAttr(M->getContext(), 1, Attributes::get(C, Attributes::NoCapture));
+ Attribute::get(C, Attribute::NoUnwind))
+ .addAttr(M->getContext(), 1, Attribute::get(C, Attribute::NoCapture));
StoreStrongCallee =
M->getOrInsertFunction(
"objc_storeStrong",
FunctionType::get(Type::getVoidTy(C), Params, /*isVarArg=*/false),
- Attributes);
+ Attribute);
}
return StoreStrongCallee;
}
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- AttributeSet Attributes =
+ AttributeSet Attribute =
AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(C, Attributes::NoUnwind));
+ Attribute::get(C, Attribute::NoUnwind));
RetainAutoreleaseCallee =
- M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes);
+ M->getOrInsertFunction("objc_retainAutorelease", FTy, Attribute);
}
return RetainAutoreleaseCallee;
}
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- AttributeSet Attributes =
+ AttributeSet Attribute =
AttributeSet().addAttr(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(C, Attributes::NoUnwind));
+ Attribute::get(C, Attribute::NoUnwind));
RetainAutoreleaseRVCallee =
M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy,
- Attributes);
+ Attribute);
}
return RetainAutoreleaseRVCallee;
}
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
- Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
+ Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- ArrayRef<Attributes::AttrVal>(AVs, 2));
+ ArrayRef<Attribute::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext();
Constant *StrLen = M->getOrInsertFunction("strlen",
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
- Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
+ Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- ArrayRef<Attributes::AttrVal>(AVs, 2));
+ ArrayRef<Attribute::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext();
Constant *StrNLen = M->getOrInsertFunction("strnlen",
return 0;
Module *M = B.GetInsertBlock()->getParent()->getParent();
- Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
+ Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AttributeWithIndex AWI =
AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- ArrayRef<Attributes::AttrVal>(AVs, 2));
+ ArrayRef<Attribute::AttrVal>(AVs, 2));
Type *I8Ptr = B.getInt8PtrTy();
Type *I32Ty = B.getInt32Ty();
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[3];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
- AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
- Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
+ AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
+ Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- ArrayRef<Attributes::AttrVal>(AVs, 2));
+ ArrayRef<Attribute::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *StrNCmp = M->getOrInsertFunction("strncmp",
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::NoUnwind);
+ Attribute::NoUnwind);
Type *I8Ptr = B.getInt8PtrTy();
Value *StrCpy = M->getOrInsertFunction(Name,
AttributeSet::get(M->getContext(), AWI),
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::NoUnwind);
+ Attribute::NoUnwind);
Type *I8Ptr = B.getInt8PtrTy();
Value *StrNCpy = M->getOrInsertFunction(Name,
AttributeSet::get(M->getContext(),
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI;
AWI = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::NoUnwind);
+ Attribute::NoUnwind);
LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *MemCpy = M->getOrInsertFunction("__memcpy_chk",
AttributeSet::get(M->getContext(), AWI),
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI;
- Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
+ Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- ArrayRef<Attributes::AttrVal>(AVs, 2));
+ ArrayRef<Attribute::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *MemChr = M->getOrInsertFunction("memchr",
AttributeSet::get(M->getContext(), AWI),
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[3];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
- AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
- Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
+ AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
+ Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- ArrayRef<Attributes::AttrVal>(AVs, 2));
+ ArrayRef<Attribute::AttrVal>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *MemCmp = M->getOrInsertFunction("memcmp",
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::NoUnwind);
+ Attribute::NoUnwind);
Value *PutS = M->getOrInsertFunction("puts",
AttributeSet::get(M->getContext(), AWI),
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::NoUnwind);
+ Attribute::NoUnwind);
Constant *F;
if (File->getType()->isPointerTy())
F = M->getOrInsertFunction("fputc",
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[3];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
- AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
+ AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::NoUnwind);
+ Attribute::NoUnwind);
StringRef FPutsName = TLI->getName(LibFunc::fputs);
Constant *F;
if (File->getType()->isPointerTy())
Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[3];
- AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
- AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attributes::NoCapture);
+ AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
+ AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attribute::NoCapture);
AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
- Attributes::NoUnwind);
+ Attribute::NoUnwind);
LLVMContext &Context = B.GetInsertBlock()->getContext();
StringRef FWriteName = TLI->getName(LibFunc::fwrite);
Constant *F;
if (isa<ConstantPointerNull>(EndPtr)) {
// With a null EndPtr, this function won't capture the main argument.
// It would be readonly too, except that it still may write to errno.
- CI->addAttribute(1, Attributes::get(Callee->getContext(),
- Attributes::NoCapture));
+ CI->addAttribute(1, Attribute::get(Callee->getContext(),
+ Attribute::NoCapture));
}
return 0;
// Check the function attribues to find out if this function should be
// optimized for size.
Function *F = L->getHeader()->getParent();
- Attributes::AttrVal SzAttr= Attributes::OptimizeForSize;
+ Attribute::AttrVal SzAttr= Attribute::OptimizeForSize;
bool OptForSize = F->getFnAttributes().hasAttribute(SzAttr);
unsigned VF = CM.selectVectorizationFactor(OptForSize, VectorizationFactor);
void printModule(const Module *M);
void writeOperand(const Value *Op, bool PrintType);
- void writeParamOperand(const Value *Operand, Attributes Attrs);
+ void writeParamOperand(const Value *Operand, Attribute Attrs);
void writeAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope);
void writeAllMDNodes();
void printGlobal(const GlobalVariable *GV);
void printAlias(const GlobalAlias *GV);
void printFunction(const Function *F);
- void printArgument(const Argument *FA, Attributes Attrs);
+ void printArgument(const Argument *FA, Attribute Attrs);
void printBasicBlock(const BasicBlock *BB);
void printInstruction(const Instruction &I);
}
void AssemblyWriter::writeParamOperand(const Value *Operand,
- Attributes Attrs) {
+ Attribute Attrs) {
if (Operand == 0) {
Out << "<null operand!>";
return;
FunctionType *FT = F->getFunctionType();
const AttributeSet &Attrs = F->getAttributes();
- Attributes RetAttrs = Attrs.getRetAttributes();
+ Attribute RetAttrs = Attrs.getRetAttributes();
if (RetAttrs.hasAttributes())
Out << Attrs.getRetAttributes().getAsString() << ' ';
TypePrinter.print(F->getReturnType(), Out);
// Output type...
TypePrinter.print(FT->getParamType(i), Out);
- Attributes ArgAttrs = Attrs.getParamAttributes(i+1);
+ Attribute ArgAttrs = Attrs.getParamAttributes(i+1);
if (ArgAttrs.hasAttributes())
Out << ' ' << ArgAttrs.getAsString();
}
Out << ')';
if (F->hasUnnamedAddr())
Out << " unnamed_addr";
- Attributes FnAttrs = Attrs.getFnAttributes();
+ Attribute FnAttrs = Attrs.getFnAttributes();
if (FnAttrs.hasAttributes())
Out << ' ' << Attrs.getFnAttributes().getAsString();
if (F->hasSection()) {
/// the function. Simply print it out
///
void AssemblyWriter::printArgument(const Argument *Arg,
- Attributes Attrs) {
+ Attribute Attrs) {
// Output type...
TypePrinter.print(Arg->getType(), Out);
-//===-- Attributes.cpp - Implement AttributesList -------------------------===//
+//===-- Attribute.cpp - Implement AttributesList -------------------------===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
//
-// This file implements the Attributes, AttributeImpl, AttrBuilder,
+// This file implements the Attribute, AttributeImpl, AttrBuilder,
// AttributeListImpl, and AttributeSet classes.
//
//===----------------------------------------------------------------------===//
using namespace llvm;
//===----------------------------------------------------------------------===//
-// Attributes Implementation
+// Attribute Implementation
//===----------------------------------------------------------------------===//
-Attributes Attributes::get(LLVMContext &Context, ArrayRef<AttrVal> Vals) {
+Attribute Attribute::get(LLVMContext &Context, ArrayRef<AttrVal> Vals) {
AttrBuilder B;
for (ArrayRef<AttrVal>::iterator I = Vals.begin(), E = Vals.end();
I != E; ++I)
B.addAttribute(*I);
- return Attributes::get(Context, B);
+ return Attribute::get(Context, B);
}
-Attributes Attributes::get(LLVMContext &Context, AttrBuilder &B) {
- // If there are no attributes, return an empty Attributes class.
+Attribute Attribute::get(LLVMContext &Context, AttrBuilder &B) {
+ // If there are no attributes, return an empty Attribute class.
if (!B.hasAttributes())
- return Attributes();
+ return Attribute();
// Otherwise, build a key to look up the existing attributes.
LLVMContextImpl *pImpl = Context.pImpl;
}
// Return the AttributesList that we found or created.
- return Attributes(PA);
+ return Attribute(PA);
}
-bool Attributes::hasAttribute(AttrVal Val) const {
+bool Attribute::hasAttribute(AttrVal Val) const {
return Attrs && Attrs->hasAttribute(Val);
}
-bool Attributes::hasAttributes() const {
+bool Attribute::hasAttributes() const {
return Attrs && Attrs->hasAttributes();
}
-bool Attributes::hasAttributes(const Attributes &A) const {
+bool Attribute::hasAttributes(const Attribute &A) const {
return Attrs && Attrs->hasAttributes(A);
}
/// This returns the alignment field of an attribute as a byte alignment value.
-unsigned Attributes::getAlignment() const {
- if (!hasAttribute(Attributes::Alignment))
+unsigned Attribute::getAlignment() const {
+ if (!hasAttribute(Attribute::Alignment))
return 0;
return 1U << ((Attrs->getAlignment() >> 16) - 1);
}
/// This returns the stack alignment field of an attribute as a byte alignment
/// value.
-unsigned Attributes::getStackAlignment() const {
- if (!hasAttribute(Attributes::StackAlignment))
+unsigned Attribute::getStackAlignment() const {
+ if (!hasAttribute(Attribute::StackAlignment))
return 0;
return 1U << ((Attrs->getStackAlignment() >> 26) - 1);
}
-uint64_t Attributes::Raw() const {
+uint64_t Attribute::Raw() const {
return Attrs ? Attrs->Raw() : 0;
}
-Attributes Attributes::typeIncompatible(Type *Ty) {
+Attribute Attribute::typeIncompatible(Type *Ty) {
AttrBuilder Incompatible;
if (!Ty->isIntegerTy())
- // Attributes that only apply to integers.
- Incompatible.addAttribute(Attributes::SExt)
- .addAttribute(Attributes::ZExt);
+ // Attribute that only apply to integers.
+ Incompatible.addAttribute(Attribute::SExt)
+ .addAttribute(Attribute::ZExt);
if (!Ty->isPointerTy())
- // Attributes that only apply to pointers.
- Incompatible.addAttribute(Attributes::ByVal)
- .addAttribute(Attributes::Nest)
- .addAttribute(Attributes::NoAlias)
- .addAttribute(Attributes::NoCapture)
- .addAttribute(Attributes::StructRet);
+ // Attribute that only apply to pointers.
+ Incompatible.addAttribute(Attribute::ByVal)
+ .addAttribute(Attribute::Nest)
+ .addAttribute(Attribute::NoAlias)
+ .addAttribute(Attribute::NoCapture)
+ .addAttribute(Attribute::StructRet);
- return Attributes::get(Ty->getContext(), Incompatible);
+ return Attribute::get(Ty->getContext(), Incompatible);
}
/// encodeLLVMAttributesForBitcode - This returns an integer containing an
/// encoding of all the LLVM attributes found in the given attribute bitset.
/// Any change to this encoding is a breaking change to bitcode compatibility.
-uint64_t Attributes::encodeLLVMAttributesForBitcode(Attributes Attrs) {
+uint64_t Attribute::encodeLLVMAttributesForBitcode(Attribute Attrs) {
// FIXME: It doesn't make sense to store the alignment information as an
// expanded out value, we should store it as a log2 value. However, we can't
// just change that here without breaking bitcode compatibility. If this ever
// Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
// log2 encoded value. Shift the bits above the alignment up by 11 bits.
uint64_t EncodedAttrs = Attrs.Raw() & 0xffff;
- if (Attrs.hasAttribute(Attributes::Alignment))
+ if (Attrs.hasAttribute(Attribute::Alignment))
EncodedAttrs |= Attrs.getAlignment() << 16;
EncodedAttrs |= (Attrs.Raw() & (0xffffULL << 21)) << 11;
return EncodedAttrs;
/// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
/// the LLVM attributes that have been decoded from the given integer. This
/// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
-Attributes Attributes::decodeLLVMAttributesForBitcode(LLVMContext &C,
+Attribute Attribute::decodeLLVMAttributesForBitcode(LLVMContext &C,
uint64_t EncodedAttrs) {
// The alignment is stored as a 16-bit raw value from bits 31--16. We shift
// the bits above 31 down by 11 bits.
if (Alignment)
B.addAlignmentAttr(Alignment);
B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
- return Attributes::get(C, B);
+ return Attribute::get(C, B);
}
-std::string Attributes::getAsString() const {
+std::string Attribute::getAsString() const {
std::string Result;
- if (hasAttribute(Attributes::ZExt))
+ if (hasAttribute(Attribute::ZExt))
Result += "zeroext ";
- if (hasAttribute(Attributes::SExt))
+ if (hasAttribute(Attribute::SExt))
Result += "signext ";
- if (hasAttribute(Attributes::NoReturn))
+ if (hasAttribute(Attribute::NoReturn))
Result += "noreturn ";
- if (hasAttribute(Attributes::NoUnwind))
+ if (hasAttribute(Attribute::NoUnwind))
Result += "nounwind ";
- if (hasAttribute(Attributes::UWTable))
+ if (hasAttribute(Attribute::UWTable))
Result += "uwtable ";
- if (hasAttribute(Attributes::ReturnsTwice))
+ if (hasAttribute(Attribute::ReturnsTwice))
Result += "returns_twice ";
- if (hasAttribute(Attributes::InReg))
+ if (hasAttribute(Attribute::InReg))
Result += "inreg ";
- if (hasAttribute(Attributes::NoAlias))
+ if (hasAttribute(Attribute::NoAlias))
Result += "noalias ";
- if (hasAttribute(Attributes::NoCapture))
+ if (hasAttribute(Attribute::NoCapture))
Result += "nocapture ";
- if (hasAttribute(Attributes::StructRet))
+ if (hasAttribute(Attribute::StructRet))
Result += "sret ";
- if (hasAttribute(Attributes::ByVal))
+ if (hasAttribute(Attribute::ByVal))
Result += "byval ";
- if (hasAttribute(Attributes::Nest))
+ if (hasAttribute(Attribute::Nest))
Result += "nest ";
- if (hasAttribute(Attributes::ReadNone))
+ if (hasAttribute(Attribute::ReadNone))
Result += "readnone ";
- if (hasAttribute(Attributes::ReadOnly))
+ if (hasAttribute(Attribute::ReadOnly))
Result += "readonly ";
- if (hasAttribute(Attributes::OptimizeForSize))
+ if (hasAttribute(Attribute::OptimizeForSize))
Result += "optsize ";
- if (hasAttribute(Attributes::NoInline))
+ if (hasAttribute(Attribute::NoInline))
Result += "noinline ";
- if (hasAttribute(Attributes::InlineHint))
+ if (hasAttribute(Attribute::InlineHint))
Result += "inlinehint ";
- if (hasAttribute(Attributes::AlwaysInline))
+ if (hasAttribute(Attribute::AlwaysInline))
Result += "alwaysinline ";
- if (hasAttribute(Attributes::StackProtect))
+ if (hasAttribute(Attribute::StackProtect))
Result += "ssp ";
- if (hasAttribute(Attributes::StackProtectReq))
+ if (hasAttribute(Attribute::StackProtectReq))
Result += "sspreq ";
- if (hasAttribute(Attributes::NoRedZone))
+ if (hasAttribute(Attribute::NoRedZone))
Result += "noredzone ";
- if (hasAttribute(Attributes::NoImplicitFloat))
+ if (hasAttribute(Attribute::NoImplicitFloat))
Result += "noimplicitfloat ";
- if (hasAttribute(Attributes::Naked))
+ if (hasAttribute(Attribute::Naked))
Result += "naked ";
- if (hasAttribute(Attributes::NonLazyBind))
+ if (hasAttribute(Attribute::NonLazyBind))
Result += "nonlazybind ";
- if (hasAttribute(Attributes::AddressSafety))
+ if (hasAttribute(Attribute::AddressSafety))
Result += "address_safety ";
- if (hasAttribute(Attributes::MinSize))
+ if (hasAttribute(Attribute::MinSize))
Result += "minsize ";
- if (hasAttribute(Attributes::StackAlignment)) {
+ if (hasAttribute(Attribute::StackAlignment)) {
Result += "alignstack(";
Result += utostr(getStackAlignment());
Result += ") ";
}
- if (hasAttribute(Attributes::Alignment)) {
+ if (hasAttribute(Attribute::Alignment)) {
Result += "align ";
Result += utostr(getAlignment());
Result += " ";
// AttrBuilder Implementation
//===----------------------------------------------------------------------===//
-AttrBuilder &AttrBuilder::addAttribute(Attributes::AttrVal Val){
+AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrVal Val){
Bits |= AttributesImpl::getAttrMask(Val);
return *this;
}
return *this;
}
-AttrBuilder &AttrBuilder::removeAttribute(Attributes::AttrVal Val) {
+AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrVal Val) {
Bits &= ~AttributesImpl::getAttrMask(Val);
return *this;
}
-AttrBuilder &AttrBuilder::addAttributes(const Attributes &A) {
+AttrBuilder &AttrBuilder::addAttributes(const Attribute &A) {
Bits |= A.Raw();
return *this;
}
-AttrBuilder &AttrBuilder::removeAttributes(const Attributes &A){
+AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
Bits &= ~A.Raw();
return *this;
}
-bool AttrBuilder::hasAttribute(Attributes::AttrVal A) const {
+bool AttrBuilder::hasAttribute(Attribute::AttrVal A) const {
return Bits & AttributesImpl::getAttrMask(A);
}
bool AttrBuilder::hasAttributes() const {
return Bits != 0;
}
-bool AttrBuilder::hasAttributes(const Attributes &A) const {
+bool AttrBuilder::hasAttributes(const Attribute &A) const {
return Bits & A.Raw();
}
bool AttrBuilder::hasAlignmentAttr() const {
- return Bits & AttributesImpl::getAttrMask(Attributes::Alignment);
+ return Bits & AttributesImpl::getAttrMask(Attribute::Alignment);
}
uint64_t AttrBuilder::getAlignment() const {
if (!hasAlignmentAttr())
return 0;
return 1ULL <<
- (((Bits & AttributesImpl::getAttrMask(Attributes::Alignment)) >> 16) - 1);
+ (((Bits & AttributesImpl::getAttrMask(Attribute::Alignment)) >> 16) - 1);
}
uint64_t AttrBuilder::getStackAlignment() const {
if (!hasAlignmentAttr())
return 0;
return 1ULL <<
- (((Bits & AttributesImpl::getAttrMask(Attributes::StackAlignment))>>26)-1);
+ (((Bits & AttributesImpl::getAttrMask(Attribute::StackAlignment))>>26)-1);
}
//===----------------------------------------------------------------------===//
uint64_t AttributesImpl::getAttrMask(uint64_t Val) {
switch (Val) {
- case Attributes::None: return 0;
- case Attributes::ZExt: return 1 << 0;
- case Attributes::SExt: return 1 << 1;
- case Attributes::NoReturn: return 1 << 2;
- case Attributes::InReg: return 1 << 3;
- case Attributes::StructRet: return 1 << 4;
- case Attributes::NoUnwind: return 1 << 5;
- case Attributes::NoAlias: return 1 << 6;
- case Attributes::ByVal: return 1 << 7;
- case Attributes::Nest: return 1 << 8;
- case Attributes::ReadNone: return 1 << 9;
- case Attributes::ReadOnly: return 1 << 10;
- case Attributes::NoInline: return 1 << 11;
- case Attributes::AlwaysInline: return 1 << 12;
- case Attributes::OptimizeForSize: return 1 << 13;
- case Attributes::StackProtect: return 1 << 14;
- case Attributes::StackProtectReq: return 1 << 15;
- case Attributes::Alignment: return 31 << 16;
- case Attributes::NoCapture: return 1 << 21;
- case Attributes::NoRedZone: return 1 << 22;
- case Attributes::NoImplicitFloat: return 1 << 23;
- case Attributes::Naked: return 1 << 24;
- case Attributes::InlineHint: return 1 << 25;
- case Attributes::StackAlignment: return 7 << 26;
- case Attributes::ReturnsTwice: return 1 << 29;
- case Attributes::UWTable: return 1 << 30;
- case Attributes::NonLazyBind: return 1U << 31;
- case Attributes::AddressSafety: return 1ULL << 32;
- case Attributes::MinSize: return 1ULL << 33;
+ case Attribute::None: return 0;
+ case Attribute::ZExt: return 1 << 0;
+ case Attribute::SExt: return 1 << 1;
+ case Attribute::NoReturn: return 1 << 2;
+ case Attribute::InReg: return 1 << 3;
+ case Attribute::StructRet: return 1 << 4;
+ case Attribute::NoUnwind: return 1 << 5;
+ case Attribute::NoAlias: return 1 << 6;
+ case Attribute::ByVal: return 1 << 7;
+ case Attribute::Nest: return 1 << 8;
+ case Attribute::ReadNone: return 1 << 9;
+ case Attribute::ReadOnly: return 1 << 10;
+ case Attribute::NoInline: return 1 << 11;
+ case Attribute::AlwaysInline: return 1 << 12;
+ case Attribute::OptimizeForSize: return 1 << 13;
+ case Attribute::StackProtect: return 1 << 14;
+ case Attribute::StackProtectReq: return 1 << 15;
+ case Attribute::Alignment: return 31 << 16;
+ case Attribute::NoCapture: return 1 << 21;
+ case Attribute::NoRedZone: return 1 << 22;
+ case Attribute::NoImplicitFloat: return 1 << 23;
+ case Attribute::Naked: return 1 << 24;
+ case Attribute::InlineHint: return 1 << 25;
+ case Attribute::StackAlignment: return 7 << 26;
+ case Attribute::ReturnsTwice: return 1 << 29;
+ case Attribute::UWTable: return 1 << 30;
+ case Attribute::NonLazyBind: return 1U << 31;
+ case Attribute::AddressSafety: return 1ULL << 32;
+ case Attribute::MinSize: return 1ULL << 33;
}
llvm_unreachable("Unsupported attribute type");
}
return Bits != 0;
}
-bool AttributesImpl::hasAttributes(const Attributes &A) const {
+bool AttributesImpl::hasAttributes(const Attribute &A) const {
return Bits & A.Raw(); // FIXME: Raw() won't work here in the future.
}
uint64_t AttributesImpl::getAlignment() const {
- return Bits & getAttrMask(Attributes::Alignment);
+ return Bits & getAttrMask(Attribute::Alignment);
}
uint64_t AttributesImpl::getStackAlignment() const {
- return Bits & getAttrMask(Attributes::StackAlignment);
+ return Bits & getAttrMask(Attribute::StackAlignment);
}
//===----------------------------------------------------------------------===//
}
/// getAttributes - The attributes for the specified index are returned.
-/// Attributes for the result are denoted with Idx = 0. Function notes are
+/// Attribute for the result are denoted with Idx = 0. Function notes are
/// denoted with idx = ~0.
-Attributes AttributeSet::getAttributes(unsigned Idx) const {
- if (AttrList == 0) return Attributes();
+Attribute AttributeSet::getAttributes(unsigned Idx) const {
+ if (AttrList == 0) return Attribute();
const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
if (Attrs[i].Index == Idx)
return Attrs[i].Attrs;
- return Attributes();
+ return Attribute();
}
/// hasAttrSomewhere - Return true if the specified attribute is set for at
/// least one parameter or for the return value.
-bool AttributeSet::hasAttrSomewhere(Attributes::AttrVal Attr) const {
+bool AttributeSet::hasAttrSomewhere(Attribute::AttrVal Attr) const {
if (AttrList == 0) return false;
const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
return AttrList ? AttrList->Attrs.size() : 0;
}
-Attributes &AttributeSet::getAttributesAtIndex(unsigned i) const {
+Attribute &AttributeSet::getAttributesAtIndex(unsigned i) const {
assert(AttrList && "Trying to get an attribute from an empty list!");
assert(i < AttrList->Attrs.size() && "Index out of range!");
return AttrList->Attrs[i].Attrs;
}
AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
- Attributes Attrs) const {
- Attributes OldAttrs = getAttributes(Idx);
+ Attribute Attrs) const {
+ Attribute OldAttrs = getAttributes(Idx);
#ifndef NDEBUG
// FIXME it is not obvious how this should work for alignment.
// For now, say we can't change a known alignment.
// If there are attributes already at this index, merge them in.
if (i != e && OldAttrList[i].Index == Idx) {
Attrs =
- Attributes::get(C, AttrBuilder(Attrs).
+ Attribute::get(C, AttrBuilder(Attrs).
addAttributes(OldAttrList[i].Attrs));
++i;
}
}
AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
- Attributes Attrs) const {
+ Attribute Attrs) const {
#ifndef NDEBUG
// FIXME it is not obvious how this should work for alignment.
// For now, say we can't pass in alignment, which no current use does.
- assert(!Attrs.hasAttribute(Attributes::Alignment) &&
+ assert(!Attrs.hasAttribute(Attribute::Alignment) &&
"Attempt to exclude alignment!");
#endif
if (AttrList == 0) return AttributeSet();
- Attributes OldAttrs = getAttributes(Idx);
+ Attribute OldAttrs = getAttributes(Idx);
AttrBuilder NewAttrs =
AttrBuilder(OldAttrs).removeAttributes(Attrs);
if (NewAttrs == AttrBuilder(OldAttrs))
// If there are attributes already at this index, merge them in.
assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
- Attrs = Attributes::get(C, AttrBuilder(OldAttrList[i].Attrs).
+ Attrs = Attribute::get(C, AttrBuilder(OldAttrList[i].Attrs).
removeAttributes(Attrs));
++i;
if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
-//===-- AttributesImpl.h - Attributes Internals -----------------*- C++ -*-===//
+//===-- AttributesImpl.h - Attribute Internals -----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
bool hasAttribute(uint64_t A) const;
bool hasAttributes() const;
- bool hasAttributes(const Attributes &A) const;
+ bool hasAttributes(const Attribute &A) const;
uint64_t getAlignment() const;
uint64_t getStackAlignment() const;
AttrBuilder B(PA);
const AttributeSet PALnew =
PAL.addAttr(Func->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(Func->getContext(), B));
+ Attribute::get(Func->getContext(), B));
Func->setAttributes(PALnew);
}
AttrBuilder B(PA);
const AttributeSet PALnew =
PAL.removeAttr(Func->getContext(), AttributeSet::FunctionIndex,
- Attributes::get(Func->getContext(), B));
+ Attribute::get(Func->getContext(), B));
Func->setAttributes(PALnew);
}
LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn) {
Function *Func = unwrap<Function>(Fn);
const AttributeSet PAL = Func->getAttributes();
- Attributes attr = PAL.getFnAttributes();
+ Attribute attr = PAL.getFnAttributes();
return (LLVMAttribute)attr.Raw();
}
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
Argument *A = unwrap<Argument>(Arg);
AttrBuilder B(PA);
- A->addAttr(Attributes::get(A->getContext(), B));
+ A->addAttr(Attribute::get(A->getContext(), B));
}
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
Argument *A = unwrap<Argument>(Arg);
AttrBuilder B(PA);
- A->removeAttr(Attributes::get(A->getContext(), B));
+ A->removeAttr(Attribute::get(A->getContext(), B));
}
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
Argument *A = unwrap<Argument>(Arg);
- Attributes attr = A->getParent()->getAttributes().getParamAttributes(
+ Attribute attr = A->getParent()->getAttributes().getParamAttributes(
A->getArgNo()+1);
return (LLVMAttribute)attr.Raw();
}
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
AttrBuilder B;
B.addAlignmentAttr(align);
- unwrap<Argument>(Arg)->addAttr(Attributes::
+ unwrap<Argument>(Arg)->addAttr(Attribute::
get(unwrap<Argument>(Arg)->getContext(), B));
}
AttrBuilder B(PA);
Call.setAttributes(
Call.getAttributes().addAttr(Call->getContext(), index,
- Attributes::get(Call->getContext(), B)));
+ Attribute::get(Call->getContext(), B)));
}
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
AttrBuilder B(PA);
Call.setAttributes(
Call.getAttributes().removeAttr(Call->getContext(), index,
- Attributes::get(Call->getContext(), B)));
+ Attribute::get(Call->getContext(), B)));
}
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
AttrBuilder B;
B.addAlignmentAttr(align);
Call.setAttributes(Call.getAttributes().addAttr(Call->getContext(), index,
- Attributes::get(Call->getContext(), B)));
+ Attribute::get(Call->getContext(), B)));
}
/*--.. Operations on call instructions (only) ..............................--*/
bool Argument::hasByValAttr() const {
if (!getType()->isPointerTy()) return false;
return getParent()->getParamAttributes(getArgNo()+1).
- hasAttribute(Attributes::ByVal);
+ hasAttribute(Attribute::ByVal);
}
unsigned Argument::getParamAlignment() const {
bool Argument::hasNestAttr() const {
if (!getType()->isPointerTy()) return false;
return getParent()->getParamAttributes(getArgNo()+1).
- hasAttribute(Attributes::Nest);
+ hasAttribute(Attribute::Nest);
}
/// hasNoAliasAttr - Return true if this argument has the noalias attribute on
bool Argument::hasNoAliasAttr() const {
if (!getType()->isPointerTy()) return false;
return getParent()->getParamAttributes(getArgNo()+1).
- hasAttribute(Attributes::NoAlias);
+ hasAttribute(Attribute::NoAlias);
}
/// hasNoCaptureAttr - Return true if this argument has the nocapture attribute
bool Argument::hasNoCaptureAttr() const {
if (!getType()->isPointerTy()) return false;
return getParent()->getParamAttributes(getArgNo()+1).
- hasAttribute(Attributes::NoCapture);
+ hasAttribute(Attribute::NoCapture);
}
/// hasSRetAttr - Return true if this argument has the sret attribute on
if (this != getParent()->arg_begin())
return false; // StructRet param must be first param
return getParent()->getParamAttributes(1).
- hasAttribute(Attributes::StructRet);
+ hasAttribute(Attribute::StructRet);
}
/// addAttr - Add a Attribute to an argument
-void Argument::addAttr(Attributes attr) {
+void Argument::addAttr(Attribute attr) {
getParent()->addAttribute(getArgNo() + 1, attr);
}
/// removeAttr - Remove a Attribute from an argument
-void Argument::removeAttr(Attributes attr) {
+void Argument::removeAttr(Attribute attr) {
getParent()->removeAttribute(getArgNo() + 1, attr);
}
BasicBlocks.begin()->eraseFromParent();
}
-void Function::addAttribute(unsigned i, Attributes attr) {
+void Function::addAttribute(unsigned i, Attribute attr) {
AttributeSet PAL = getAttributes();
PAL = PAL.addAttr(getContext(), i, attr);
setAttributes(PAL);
}
-void Function::removeAttribute(unsigned i, Attributes attr) {
+void Function::removeAttribute(unsigned i, Attribute attr) {
AttributeSet PAL = getAttributes();
PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL);
SubclassOptionalData = CI.SubclassOptionalData;
}
-void CallInst::addAttribute(unsigned i, Attributes attr) {
+void CallInst::addAttribute(unsigned i, Attribute attr) {
AttributeSet PAL = getAttributes();
PAL = PAL.addAttr(getContext(), i, attr);
setAttributes(PAL);
}
-void CallInst::removeAttribute(unsigned i, Attributes attr) {
+void CallInst::removeAttribute(unsigned i, Attribute attr) {
AttributeSet PAL = getAttributes();
PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL);
}
-bool CallInst::hasFnAttr(Attributes::AttrVal A) const {
+bool CallInst::hasFnAttr(Attribute::AttrVal A) const {
if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex)
.hasAttribute(A))
return true;
return false;
}
-bool CallInst::paramHasAttr(unsigned i, Attributes::AttrVal A) const {
+bool CallInst::paramHasAttr(unsigned i, Attribute::AttrVal A) const {
if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
return setSuccessor(idx, B);
}
-bool InvokeInst::hasFnAttr(Attributes::AttrVal A) const {
+bool InvokeInst::hasFnAttr(Attribute::AttrVal A) const {
if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex).
hasAttribute(A))
return true;
return false;
}
-bool InvokeInst::paramHasAttr(unsigned i, Attributes::AttrVal A) const {
+bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrVal A) const {
if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
return false;
}
-void InvokeInst::addAttribute(unsigned i, Attributes attr) {
+void InvokeInst::addAttribute(unsigned i, Attribute attr) {
AttributeSet PAL = getAttributes();
PAL = PAL.addAttr(getContext(), i, attr);
setAttributes(PAL);
}
-void InvokeInst::removeAttribute(unsigned i, Attributes attr) {
+void InvokeInst::removeAttribute(unsigned i, Attribute attr) {
AttributeSet PAL = getAttributes();
PAL = PAL.removeAttr(getContext(), i, attr);
setAttributes(PAL);
bool VerifyIntrinsicType(Type *Ty,
ArrayRef<Intrinsic::IITDescriptor> &Infos,
SmallVectorImpl<Type*> &ArgTys);
- void VerifyParameterAttrs(Attributes Attrs, Type *Ty,
+ void VerifyParameterAttrs(Attribute Attrs, Type *Ty,
bool isReturnValue, const Value *V);
void VerifyFunctionAttrs(FunctionType *FT, const AttributeSet &Attrs,
const Value *V);
// VerifyParameterAttrs - Check the given attributes for an argument or return
// value of the specified type. The value V is printed in error messages.
-void Verifier::VerifyParameterAttrs(Attributes Attrs, Type *Ty,
+void Verifier::VerifyParameterAttrs(Attribute Attrs, Type *Ty,
bool isReturnValue, const Value *V) {
if (!Attrs.hasAttributes())
return;
if (isReturnValue)
Assert1(!Attrs.hasParameterOnlyAttrs(),
- "Attributes 'byval', 'nest', 'sret', and 'nocapture' "
+ "Attribute 'byval', 'nest', 'sret', and 'nocapture' "
"do not apply to return values!", V);
// Check for mutually incompatible attributes.
- Assert1(!((Attrs.hasAttribute(Attributes::ByVal) &&
- Attrs.hasAttribute(Attributes::Nest)) ||
- (Attrs.hasAttribute(Attributes::ByVal) &&
- Attrs.hasAttribute(Attributes::StructRet)) ||
- (Attrs.hasAttribute(Attributes::Nest) &&
- Attrs.hasAttribute(Attributes::StructRet))), "Attributes "
+ Assert1(!((Attrs.hasAttribute(Attribute::ByVal) &&
+ Attrs.hasAttribute(Attribute::Nest)) ||
+ (Attrs.hasAttribute(Attribute::ByVal) &&
+ Attrs.hasAttribute(Attribute::StructRet)) ||
+ (Attrs.hasAttribute(Attribute::Nest) &&
+ Attrs.hasAttribute(Attribute::StructRet))), "Attributes "
"'byval, nest, and sret' are incompatible!", V);
- Assert1(!((Attrs.hasAttribute(Attributes::ByVal) &&
- Attrs.hasAttribute(Attributes::Nest)) ||
- (Attrs.hasAttribute(Attributes::ByVal) &&
- Attrs.hasAttribute(Attributes::InReg)) ||
- (Attrs.hasAttribute(Attributes::Nest) &&
- Attrs.hasAttribute(Attributes::InReg))), "Attributes "
+ Assert1(!((Attrs.hasAttribute(Attribute::ByVal) &&
+ Attrs.hasAttribute(Attribute::Nest)) ||
+ (Attrs.hasAttribute(Attribute::ByVal) &&
+ Attrs.hasAttribute(Attribute::InReg)) ||
+ (Attrs.hasAttribute(Attribute::Nest) &&
+ Attrs.hasAttribute(Attribute::InReg))), "Attributes "
"'byval, nest, and inreg' are incompatible!", V);
- Assert1(!(Attrs.hasAttribute(Attributes::ZExt) &&
- Attrs.hasAttribute(Attributes::SExt)), "Attributes "
+ Assert1(!(Attrs.hasAttribute(Attribute::ZExt) &&
+ Attrs.hasAttribute(Attribute::SExt)), "Attributes "
"'zeroext and signext' are incompatible!", V);
- Assert1(!(Attrs.hasAttribute(Attributes::ReadNone) &&
- Attrs.hasAttribute(Attributes::ReadOnly)), "Attributes "
+ Assert1(!(Attrs.hasAttribute(Attribute::ReadNone) &&
+ Attrs.hasAttribute(Attribute::ReadOnly)), "Attributes "
"'readnone and readonly' are incompatible!", V);
- Assert1(!(Attrs.hasAttribute(Attributes::NoInline) &&
- Attrs.hasAttribute(Attributes::AlwaysInline)), "Attributes "
+ Assert1(!(Attrs.hasAttribute(Attribute::NoInline) &&
+ Attrs.hasAttribute(Attribute::AlwaysInline)), "Attributes "
"'noinline and alwaysinline' are incompatible!", V);
Assert1(!AttrBuilder(Attrs).
- hasAttributes(Attributes::typeIncompatible(Ty)),
+ hasAttributes(Attribute::typeIncompatible(Ty)),
"Wrong types for attribute: " +
- Attributes::typeIncompatible(Ty).getAsString(), V);
+ Attribute::typeIncompatible(Ty).getAsString(), V);
if (PointerType *PTy = dyn_cast<PointerType>(Ty))
- Assert1(!Attrs.hasAttribute(Attributes::ByVal) ||
+ Assert1(!Attrs.hasAttribute(Attribute::ByVal) ||
PTy->getElementType()->isSized(),
"Attribute 'byval' does not support unsized types!", V);
else
- Assert1(!Attrs.hasAttribute(Attributes::ByVal),
+ Assert1(!Attrs.hasAttribute(Attribute::ByVal),
"Attribute 'byval' only applies to parameters with pointer type!",
V);
}
VerifyParameterAttrs(Attr.Attrs, Ty, Attr.Index == 0, V);
- if (Attr.Attrs.hasAttribute(Attributes::Nest)) {
+ if (Attr.Attrs.hasAttribute(Attribute::Nest)) {
Assert1(!SawNest, "More than one parameter has attribute nest!", V);
SawNest = true;
}
- if (Attr.Attrs.hasAttribute(Attributes::StructRet))
- Assert1(Attr.Index == 1, "Attribute sret not on first parameter!", V);
+ if (Attr.Attrs.hasAttribute(Attribute::StructRet))
+ Assert1(Attr.Index == 1, "Attribute sret is not on first parameter!", V);
}
- Attributes FAttrs = Attrs.getFnAttributes();
+ Attribute FAttrs = Attrs.getFnAttributes();
AttrBuilder NotFn(FAttrs);
NotFn.removeFunctionOnlyAttrs();
- Assert1(!NotFn.hasAttributes(), "Attributes '" +
- Attributes::get(V->getContext(), NotFn).getAsString() +
+ Assert1(!NotFn.hasAttributes(), "Attribute '" +
+ Attribute::get(V->getContext(), NotFn).getAsString() +
"' do not apply to the function!", V);
// Check for mutually incompatible attributes.
- Assert1(!((FAttrs.hasAttribute(Attributes::ByVal) &&
- FAttrs.hasAttribute(Attributes::Nest)) ||
- (FAttrs.hasAttribute(Attributes::ByVal) &&
- FAttrs.hasAttribute(Attributes::StructRet)) ||
- (FAttrs.hasAttribute(Attributes::Nest) &&
- FAttrs.hasAttribute(Attributes::StructRet))), "Attributes "
+ Assert1(!((FAttrs.hasAttribute(Attribute::ByVal) &&
+ FAttrs.hasAttribute(Attribute::Nest)) ||
+ (FAttrs.hasAttribute(Attribute::ByVal) &&
+ FAttrs.hasAttribute(Attribute::StructRet)) ||
+ (FAttrs.hasAttribute(Attribute::Nest) &&
+ FAttrs.hasAttribute(Attribute::StructRet))), "Attributes "
"'byval, nest, and sret' are incompatible!", V);
- Assert1(!((FAttrs.hasAttribute(Attributes::ByVal) &&
- FAttrs.hasAttribute(Attributes::Nest)) ||
- (FAttrs.hasAttribute(Attributes::ByVal) &&
- FAttrs.hasAttribute(Attributes::InReg)) ||
- (FAttrs.hasAttribute(Attributes::Nest) &&
- FAttrs.hasAttribute(Attributes::InReg))), "Attributes "
+ Assert1(!((FAttrs.hasAttribute(Attribute::ByVal) &&
+ FAttrs.hasAttribute(Attribute::Nest)) ||
+ (FAttrs.hasAttribute(Attribute::ByVal) &&
+ FAttrs.hasAttribute(Attribute::InReg)) ||
+ (FAttrs.hasAttribute(Attribute::Nest) &&
+ FAttrs.hasAttribute(Attribute::InReg))), "Attributes "
"'byval, nest, and inreg' are incompatible!", V);
- Assert1(!(FAttrs.hasAttribute(Attributes::ZExt) &&
- FAttrs.hasAttribute(Attributes::SExt)), "Attributes "
+ Assert1(!(FAttrs.hasAttribute(Attribute::ZExt) &&
+ FAttrs.hasAttribute(Attribute::SExt)), "Attributes "
"'zeroext and signext' are incompatible!", V);
- Assert1(!(FAttrs.hasAttribute(Attributes::ReadNone) &&
- FAttrs.hasAttribute(Attributes::ReadOnly)), "Attributes "
+ Assert1(!(FAttrs.hasAttribute(Attribute::ReadNone) &&
+ FAttrs.hasAttribute(Attribute::ReadOnly)), "Attributes "
"'readnone and readonly' are incompatible!", V);
- Assert1(!(FAttrs.hasAttribute(Attributes::NoInline) &&
- FAttrs.hasAttribute(Attributes::AlwaysInline)), "Attributes "
+ Assert1(!(FAttrs.hasAttribute(Attribute::NoInline) &&
+ FAttrs.hasAttribute(Attribute::AlwaysInline)), "Attributes "
"'noinline and alwaysinline' are incompatible!", V);
}
const AttributeSet &Attrs = F.getAttributes();
Assert1(VerifyAttributeCount(Attrs, FT->getNumParams()),
- "Attributes after last parameter!", &F);
+ "Attribute after last parameter!", &F);
// Check function attributes.
VerifyFunctionAttrs(FT, Attrs, &F);
const AttributeSet &Attrs = CS.getAttributes();
Assert1(VerifyAttributeCount(Attrs, CS.arg_size()),
- "Attributes after last parameter!", I);
+ "Attribute after last parameter!", I);
// Verify call attributes.
VerifyFunctionAttrs(FTy, Attrs, I);
if (FTy->isVarArg())
// Check attributes on the varargs part.
for (unsigned Idx = 1 + FTy->getNumParams(); Idx <= CS.arg_size(); ++Idx) {
- Attributes Attr = Attrs.getParamAttributes(Idx);
+ Attribute Attr = Attrs.getParamAttributes(Idx);
VerifyParameterAttrs(Attr, CS.getArgument(Idx-1)->getType(), false, I);
OS << " AttributeWithIndex AWI[" << maxArgAttrs+1 << "];\n";
OS << " unsigned NumAttrs = 0;\n";
OS << " if (id != 0) {\n";
- OS << " SmallVector<Attributes::AttrVal, 8> AttrVec;\n";
+ OS << " SmallVector<Attribute::AttrVal, 8> AttrVec;\n";
OS << " switch(IntrinsicsToAttributesMap[id - ";
if (TargetOnly)
OS << "Intrinsic::num_intrinsics";
do {
switch (intrinsic.ArgumentAttributes[ai].second) {
case CodeGenIntrinsic::NoCapture:
- OS << " AttrVec.push_back(Attributes::NoCapture);\n";
+ OS << " AttrVec.push_back(Attribute::NoCapture);\n";
break;
}
OS << " AttrVec.clear();\n";
if (!intrinsic.canThrow)
- OS << " AttrVec.push_back(Attributes::NoUnwind);\n";
+ OS << " AttrVec.push_back(Attribute::NoUnwind);\n";
if (intrinsic.isNoReturn)
- OS << " AttrVec.push_back(Attributes::NoReturn);\n";
+ OS << " AttrVec.push_back(Attribute::NoReturn);\n";
switch (modRef) {
case MRK_none: break;
case MRK_readonly:
- OS << " AttrVec.push_back(Attributes::ReadOnly);\n";
+ OS << " AttrVec.push_back(Attribute::ReadOnly);\n";
break;
case MRK_readnone:
- OS << " AttrVec.push_back(Attributes::ReadNone);\n";
+ OS << " AttrVec.push_back(Attribute::ReadNone);\n";
break;
}
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, "