summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Attributes.h5
-rw-r--r--lib/VMCore/Verifier.cpp17
-rw-r--r--test/Assembler/2008-09-02-FunctionNotes2.ll3
3 files changed, 21 insertions, 4 deletions
diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h
index 1e54ddf..d8f6cf6 100644
--- a/include/llvm/Attributes.h
+++ b/include/llvm/Attributes.h
@@ -60,10 +60,11 @@ const Attributes ReturnOnly = NoReturn | NoUnwind | ReadNone | ReadOnly;
const Attributes VarArgsIncompatible = StructRet;
/// @brief Attributes that are mutually incompatible.
-const Attributes MutuallyIncompatible[3] = {
+const Attributes MutuallyIncompatible[4] = {
ByVal | InReg | Nest | StructRet,
ZExt | SExt,
- ReadNone | ReadOnly
+ ReadNone | ReadOnly,
+ NoInline | AlwaysInline
};
/// @brief Which attributes cannot be applied to a type.
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 42d76ef..527b1da 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -475,6 +475,23 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
if (Attr.Attrs & Attribute::StructRet)
Assert1(Attr.Index == 1, "Attribute sret not on first parameter!", V);
}
+
+ Attributes FAttrs = Attrs.getFnAttributes();
+ for (unsigned i = 0;
+ i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
+ Attributes MutI = FAttrs & Attribute::MutuallyIncompatible[i];
+ Assert1(!(MutI & (MutI - 1)), "Attributes " +
+ Attribute::getAsString(MutI) + " are incompatible!", V);
+ }
+
+ Attributes RAttrs = Attrs.getRetAttributes();
+ for (unsigned i = 0;
+ i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
+ Attributes MutI = RAttrs & Attribute::MutuallyIncompatible[i];
+ Assert1(!(MutI & (MutI - 1)), "Attributes " +
+ Attribute::getAsString(MutI) + " are incompatible!", V);
+ }
+
}
static bool VerifyAttributeCount(const AttrListPtr &Attrs, unsigned Params) {
diff --git a/test/Assembler/2008-09-02-FunctionNotes2.ll b/test/Assembler/2008-09-02-FunctionNotes2.ll
index 966e0f8..dbe75be 100644
--- a/test/Assembler/2008-09-02-FunctionNotes2.ll
+++ b/test/Assembler/2008-09-02-FunctionNotes2.ll
@@ -1,6 +1,5 @@
; Test function notes
-; RUN: not llvm-as %s -o /dev/null -f |& grep "only one inline note"
-; XFAIL: *
+; RUN: not llvm-as %s -o /dev/null -f |& grep "Attributes noinline alwaysinline are incompatible"
define void @fn1() alwaysinline noinline {
ret void
}