aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/IR
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-06-27 00:25:01 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-06-27 00:25:01 +0000
commit2253a2f52f3c46ae75cd05f5885acb987bd1d6b6 (patch)
tree483f06fa8a9b2981c441c49dde73b45eb724c03d /include/llvm/IR
parent9367c79e62307421f28ba92174f3792a6360f37b (diff)
downloadexternal_llvm-2253a2f52f3c46ae75cd05f5885acb987bd1d6b6.zip
external_llvm-2253a2f52f3c46ae75cd05f5885acb987bd1d6b6.tar.gz
external_llvm-2253a2f52f3c46ae75cd05f5885acb987bd1d6b6.tar.bz2
Added support for the Builtin attribute.
The Builtin attribute is an attribute that can be placed on function call site that signal that even though a function is declared as being a builtin, rdar://problem/13727199 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/IR')
-rw-r--r--include/llvm/IR/Attributes.h2
-rw-r--r--include/llvm/IR/Instructions.h33
2 files changed, 33 insertions, 2 deletions
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h
index 0d14709..0bf59cf 100644
--- a/include/llvm/IR/Attributes.h
+++ b/include/llvm/IR/Attributes.h
@@ -67,6 +67,8 @@ public:
///< stored as log2 of alignment with +1 bias
///< 0 means unaligned (different from align(1))
AlwaysInline, ///< inline=always
+ Builtin, ///< Callee is recognized as a builtin, despite
+ ///< nobuiltin attribute on its declaration.
ByVal, ///< Pass structure by value
Cold, ///< Marks function as being in a cold path.
InlineHint, ///< Source said inlining was desirable
diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h
index 3a8738f..e05c3a8 100644
--- a/include/llvm/IR/Instructions.h
+++ b/include/llvm/IR/Instructions.h
@@ -1278,7 +1278,11 @@ public:
void removeAttribute(unsigned i, Attribute attr);
/// \brief Determine whether this call has the given attribute.
- bool hasFnAttr(Attribute::AttrKind A) const;
+ bool hasFnAttr(Attribute::AttrKind A) const {
+ assert(A != Attribute::NoBuiltin &&
+ "Use CallInst::isNoBuiltin() to check for Attribute::NoBuiltin");
+ return hasFnAttrImpl(A);
+ }
/// \brief Determine whether the call or the callee has the given attributes.
bool paramHasAttr(unsigned i, Attribute::AttrKind A) const;
@@ -1288,6 +1292,13 @@ public:
return AttributeList.getParamAlignment(i);
}
+ /// \brief Return true if the call should not be treated as a call to a
+ /// builtin.
+ bool isNoBuiltin() const {
+ return hasFnAttrImpl(Attribute::NoBuiltin) &&
+ !hasFnAttrImpl(Attribute::Builtin);
+ }
+
/// \brief Return true if the call should not be inlined.
bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
void setIsNoInline() {
@@ -1378,6 +1389,9 @@ public:
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
+
+ bool hasFnAttrImpl(Attribute::AttrKind A) const;
+
// Shadow Instruction::setInstructionSubclassData with a private forwarding
// method so that subclasses cannot accidentally use it.
void setInstructionSubclassData(unsigned short D) {
@@ -3021,7 +3035,11 @@ public:
void removeAttribute(unsigned i, Attribute attr);
/// \brief Determine whether this call has the NoAlias attribute.
- bool hasFnAttr(Attribute::AttrKind A) const;
+ bool hasFnAttr(Attribute::AttrKind A) const {
+ assert(A != Attribute::NoBuiltin &&
+ "Use CallInst::isNoBuiltin() to check for Attribute::NoBuiltin");
+ return hasFnAttrImpl(A);
+ }
/// \brief Determine whether the call or the callee has the given attributes.
bool paramHasAttr(unsigned i, Attribute::AttrKind A) const;
@@ -3031,6 +3049,15 @@ public:
return AttributeList.getParamAlignment(i);
}
+ /// \brief Return true if the call should not be treated as a call to a
+ /// builtin.
+ bool isNoBuiltin() const {
+ // We assert in hasFnAttr if one passes in Attribute::NoBuiltin, so we have
+ // to check it by hand.
+ return hasFnAttrImpl(Attribute::NoBuiltin) &&
+ !hasFnAttrImpl(Attribute::Builtin);
+ }
+
/// \brief Return true if the call should not be inlined.
bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
void setIsNoInline() {
@@ -3137,6 +3164,8 @@ private:
virtual unsigned getNumSuccessorsV() const;
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
+ bool hasFnAttrImpl(Attribute::AttrKind A) const;
+
// Shadow Instruction::setInstructionSubclassData with a private forwarding
// method so that subclasses cannot accidentally use it.
void setInstructionSubclassData(unsigned short D) {