summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-22 00:12:35 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-22 00:12:35 +0000
commit143d46476cdcf5b88b9ee18ebd799e5820a2db0e (patch)
tree8b99f1da4df8777771cf9355beeefc3660950465 /lib/IR
parenta931a12e04b856421977c86d94789cd8b47d6ad3 (diff)
downloadllvm-143d46476cdcf5b88b9ee18ebd799e5820a2db0e.tar.gz
llvm-143d46476cdcf5b88b9ee18ebd799e5820a2db0e.tar.bz2
llvm-143d46476cdcf5b88b9ee18ebd799e5820a2db0e.tar.xz
Implement the NoBuiltin attribute.
The 'nobuiltin' attribute is applied to call sites to indicate that LLVM should not treat the callee function as a built-in function. I.e., it shouldn't try to replace that function with different code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175835 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/Attributes.cpp32
-rw-r--r--lib/IR/Verifier.cpp3
2 files changed, 33 insertions, 2 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index d89ebc503a..96b17c31e5 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -171,6 +171,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
return "nest";
if (hasAttribute(Attribute::NoAlias))
return "noalias";
+ if (hasAttribute(Attribute::NoBuiltin))
+ return "nobuiltin";
if (hasAttribute(Attribute::NoCapture))
return "nocapture";
if (hasAttribute(Attribute::NoDuplicate))
@@ -354,6 +356,8 @@ bool AttributeImpl::operator<(const AttributeImpl &AI) const {
uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
// FIXME: Remove this.
switch (Val) {
+ default:
+ llvm_unreachable("Unsupported attribute type");
case Attribute::EndAttrKinds:
llvm_unreachable("Synthetic enumerators which should never get here");
@@ -391,7 +395,6 @@ uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
case Attribute::ThreadSafety: return 1ULL << 36;
case Attribute::UninitializedChecks: return 1ULL << 37;
}
- llvm_unreachable("Unsupported attribute type");
}
//===----------------------------------------------------------------------===//
@@ -1097,6 +1100,33 @@ bool AttrBuilder::operator==(const AttrBuilder &B) {
return Alignment == B.Alignment && StackAlignment == B.StackAlignment;
}
+void AttrBuilder::removeFunctionOnlyAttrs() {
+ 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::StackProtectStrong)
+ .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::ThreadSafety)
+ .removeAttribute(Attribute::UninitializedChecks)
+ .removeAttribute(Attribute::MinSize)
+ .removeAttribute(Attribute::NoDuplicate)
+ .removeAttribute(Attribute::NoBuiltin);
+}
+
AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
// FIXME: Remove this in 4.0.
if (!Val) return *this;
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index 02c209660b..33e8ec651d 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -653,7 +653,8 @@ void Verifier::VerifyParameterAttrs(AttributeSet Attrs, uint64_t Idx, Type *Ty,
!Attrs.hasAttribute(Idx, Attribute::AddressSafety) &&
!Attrs.hasAttribute(Idx, Attribute::ThreadSafety) &&
!Attrs.hasAttribute(Idx, Attribute::UninitializedChecks) &&
- !Attrs.hasAttribute(Idx, Attribute::MinSize),
+ !Attrs.hasAttribute(Idx, Attribute::MinSize) &&
+ !Attrs.hasAttribute(Idx, Attribute::NoBuiltin),
"Some attributes in '" + Attrs.getAsString(Idx) +
"' only apply to functions!", V);