Attributes noinline alwaysinline are incompatible
authorDevang Patel <dpatel@apple.com>
Wed, 1 Oct 2008 23:41:25 +0000 (23:41 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 1 Oct 2008 23:41:25 +0000 (23:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56939 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Attributes.h
lib/VMCore/Verifier.cpp
test/Assembler/2008-09-02-FunctionNotes2.ll

index 1e54ddfc87f4ff85461febaf8a12a6a16d2c611b..d8f6cf6f09552844287f00459f361f50de9f96e7 100644 (file)
@@ -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.
index 42d76ef4a19b92ebbcb528a01107bf8083fca301..527b1da87e2452d330697843dbafe0a4f4b25598 100644 (file)
@@ -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) {
index 966e0f87ba278c2a181860d80164bf701e652fd9..dbe75be700b7e7abe9d8f4d4b908bef68918fe98 100644 (file)
@@ -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
 }