Fix function attribute verification check.
authorDevang Patel <dpatel@apple.com>
Fri, 3 Oct 2008 21:11:02 +0000 (21:11 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 3 Oct 2008 21:11:02 +0000 (21:11 +0000)
Thanks Duncan!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57029 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Attributes.h
lib/VMCore/Verifier.cpp

index 50a4cef9ea91d752bf2fba9f8d159bd70fa918f5..685ee2767b1440d9557bb74b9eaafa61970adc19 100644 (file)
@@ -54,7 +54,8 @@ const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter (16 bits)
 const Attributes ParameterOnly = ByVal | Nest | StructRet;
 
 /// @brief Attributes that only apply to function.
-const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly;
+const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly | 
+  NoInline | AlwaysInline | OptimizeForSize;
 
 /// @brief Parameter attributes that do not apply to vararg call arguments.
 const Attributes VarArgsIncompatible = StructRet;
index f8cd7780aefd0d894b5f7390c8a14d71c3cb5db9..820bf33bc932173860980864b5c22dc02f6b49da 100644 (file)
@@ -415,12 +415,11 @@ void Verifier::VerifyAttrs(Attributes Attrs, const Type *Ty,
     Attributes RetI = Attrs & Attribute::ParameterOnly;
     Assert1(!RetI, "Attribute " + Attribute::getAsString(RetI) +
             " does not apply to return values!", V);
-  } else {
-    Attributes ParmI = Attrs & Attribute::FunctionOnly;
-    Assert1(!ParmI, "Attribute " + Attribute::getAsString(ParmI) +
-            " only applies to return values!", V);
   }
-
+  Attributes FnCheckAttr = Attrs & Attribute::FunctionOnly;
+  Assert1(!FnCheckAttr, "Attribute " + Attribute::getAsString(FnCheckAttr) +
+          " only applies to return values!", V);
+  
   for (unsigned i = 0;
        i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
     Attributes MutI = Attrs & Attribute::MutuallyIncompatible[i];
@@ -477,7 +476,7 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
   }
 
   Attributes FAttrs = Attrs.getFnAttributes();
-  Assert1(!(FAttrs & (!Attribute::FunctionOnly)),
+  Assert1(!(FAttrs & (~Attribute::FunctionOnly)),
           "Attribute " + Attribute::getAsString(FAttrs) +
           " does not apply to function!", V);