[llvm-commits] [llvm] r56511 - in /llvm/trunk: include/llvm/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/Target/X86/AsmPrinter/ lib/Transforms/IPO/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/

Devang Patel dpatel at apple.com
Tue Sep 23 15:35:17 PDT 2008


Author: dpatel
Date: Tue Sep 23 17:35:17 2008
New Revision: 56511

URL: http://llvm.org/viewvc/llvm-project?rev=56511&view=rev
Log:
Use parameter attribute store (soon to be renamed) for
Function Notes also. Function notes are stored at index ~0.


Modified:
    llvm/trunk/include/llvm/Function.h
    llvm/trunk/include/llvm/ParameterAttributes.h
    llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs
    llvm/trunk/lib/AsmParser/llvmAsmParser.y
    llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
    llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
    llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
    llvm/trunk/lib/Transforms/IPO/Inliner.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
    llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
    llvm/trunk/lib/VMCore/AsmWriter.cpp
    llvm/trunk/lib/VMCore/Function.cpp
    llvm/trunk/lib/VMCore/ParameterAttributes.cpp
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Tue Sep 23 17:35:17 2008
@@ -51,12 +51,6 @@
   static int getListOffset();
 };
 
-typedef unsigned FunctionNotes;
-const FunctionNotes FN_NOTE_None            = 0;   
-const FunctionNotes FN_NOTE_NoInline        = 1<<0;
-const FunctionNotes FN_NOTE_AlwaysInline    = 1<<1;
-const FunctionNotes FN_NOTE_OptimizeForSize = 1<<2;
-
 class Function : public GlobalValue, public Annotable,
                  public ilist_node<Function> {
 public:
@@ -76,7 +70,6 @@
   mutable ArgumentListType ArgumentList;  ///< The formal arguments
   ValueSymbolTable *SymTab;               ///< Symbol table of args/instructions
   PAListPtr ParamAttrs;                   ///< Parameter attributes
-  FunctionNotes Notes;                    ///< Function properties
 
   // The Calling Convention is stored in Value::SubclassData.
   /*unsigned CallingConvention;*/
@@ -155,18 +148,19 @@
   ///
   void setParamAttrs(const PAListPtr &attrs) { ParamAttrs = attrs; }
 
-  /// getNotes - Return function notes
-  ///
-  const FunctionNotes &getNotes() const { return Notes; }
 
   /// hasNote - Return true if this function has given note.
-  bool hasNote(FunctionNotes N) const {
-    return (!isDeclaration() && (Notes & N));
+  bool hasNote(ParameterAttributes N) const {
+  	// Notes are stored at ~0 index in parameter attribute list
+    return (!isDeclaration() && paramHasAttr(~0, N));
   }
 
   /// setNotes - Set notes for this function
   ///
-  void setNotes(const FunctionNotes P) { Notes = Notes | P;}
+  void setNotes(const ParameterAttributes N) { 
+  	// Notes are stored at ~0 index in parameter attribute list
+  	addParamAttr(~0, N);
+  }
 
   /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
   ///                             to use during code generation.

Modified: llvm/trunk/include/llvm/ParameterAttributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ParameterAttributes.h?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ParameterAttributes.h (original)
+++ llvm/trunk/include/llvm/ParameterAttributes.h Tue Sep 23 17:35:17 2008
@@ -46,6 +46,13 @@
 const Attributes ReadOnly  = 1<<10; ///< Function only reads from memory
 const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter (16 bits)
                                     // 0 = unknown, else in clear (not log)
+                                    
+/// Function notes are implemented as attributes stored at index ~0 in 
+/// parameter attribute list.
+const Attributes FN_NOTE_None            = 0;    
+const Attributes FN_NOTE_NoInline        = 1<<0; // inline=never 
+const Attributes FN_NOTE_AlwaysInline    = 1<<1; // inline=always
+const Attributes FN_NOTE_OptimizeForSize = 1<<2; // opt_size
 
 /// @brief Attributes that only apply to function parameters.
 const Attributes ParameterOnly = ByVal | Nest | StructRet;

Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs Tue Sep 23 17:35:17 2008
@@ -366,7 +366,7 @@
 
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-#line 970 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 970 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
 {
   llvm::Module                           *ModuleVal;
   llvm::Function                         *FunctionVal;
@@ -395,7 +395,7 @@
   llvm::GlobalValue::LinkageTypes         Linkage;
   llvm::GlobalValue::VisibilityTypes      Visibility;
   llvm::ParameterAttributes         ParamAttrs;
-  llvm::FunctionNotes               FunctionNotes;
+  llvm::ParameterAttributes         FunctionNotes;
   llvm::APInt                       *APIntVal;
   int64_t                           SInt64Val;
   uint64_t                          UInt64Val;

Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Tue Sep 23 17:35:17 2008
@@ -995,7 +995,7 @@
   llvm::GlobalValue::LinkageTypes         Linkage;
   llvm::GlobalValue::VisibilityTypes      Visibility;
   llvm::ParameterAttributes         ParamAttrs;
-  llvm::FunctionNotes               FunctionNotes;
+  llvm::ParameterAttributes         FunctionNotes;
   llvm::APInt                       *APIntVal;
   int64_t                           SInt64Val;
   uint64_t                          UInt64Val;
@@ -1091,8 +1091,8 @@
 %type <UIntVal> OptCallingConv LocalNumber
 %type <ParamAttrs> OptParamAttrs ParamAttr 
 %type <ParamAttrs> OptFuncAttrs  FuncAttr
-%type <FunctionNotes> OptFuncNotes FuncNote 
-%type <FunctionNotes> FuncNoteList
+%type <ParamAttrs> OptFuncNotes FuncNote 
+%type <ParamAttrs> FuncNoteList
 
 // Basic Block Terminating Operators
 %token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
@@ -1297,22 +1297,24 @@
 
 FuncNoteList  : FuncNote { $$ = $1; }
               | FuncNoteList ',' FuncNote { 
-                FunctionNotes tmp = $1 | $3;
-                if ($3 == FN_NOTE_NoInline && ($1 & FN_NOTE_AlwaysInline))
+                unsigned tmp = $1 | $3;
+                if ($3 == ParamAttr::FN_NOTE_NoInline 
+                    && ($1 & ParamAttr::FN_NOTE_AlwaysInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
-                if ($3 == FN_NOTE_AlwaysInline && ($1 & FN_NOTE_NoInline))
+                    if ($3 == ParamAttr::FN_NOTE_AlwaysInline 
+                        && ($1 & ParamAttr::FN_NOTE_NoInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 $$ = tmp;
                 CHECK_FOR_ERROR 
               }
               ;
 
-FuncNote      : INLINE '=' NEVER { $$ = FN_NOTE_NoInline; }
-              | INLINE '=' ALWAYS { $$ = FN_NOTE_AlwaysInline; }
-              | OPTIMIZEFORSIZE { $$ = FN_NOTE_OptimizeForSize; }
+FuncNote      : INLINE '=' NEVER { $$ = ParamAttr::FN_NOTE_NoInline; }
+              | INLINE '=' ALWAYS { $$ = ParamAttr::FN_NOTE_AlwaysInline; }
+              | OPTIMIZEFORSIZE { $$ = ParamAttr::FN_NOTE_OptimizeForSize; }
               ;
 
-OptFuncNotes  : /* empty */ { $$ = FN_NOTE_None; }
+OptFuncNotes  : /* empty */ { $$ = ParamAttr::FN_NOTE_None; }
               | FNNOTE '(' FuncNoteList  ')' {
                 $$ =  $3;
               }

Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs Tue Sep 23 17:35:17 2008
@@ -995,7 +995,7 @@
   llvm::GlobalValue::LinkageTypes         Linkage;
   llvm::GlobalValue::VisibilityTypes      Visibility;
   llvm::ParameterAttributes         ParamAttrs;
-  llvm::FunctionNotes               FunctionNotes;
+  llvm::ParameterAttributes         FunctionNotes;
   llvm::APInt                       *APIntVal;
   int64_t                           SInt64Val;
   uint64_t                          UInt64Val;
@@ -1091,8 +1091,8 @@
 %type <UIntVal> OptCallingConv LocalNumber
 %type <ParamAttrs> OptParamAttrs ParamAttr 
 %type <ParamAttrs> OptFuncAttrs  FuncAttr
-%type <FunctionNotes> OptFuncNotes FuncNote 
-%type <FunctionNotes> FuncNoteList
+%type <ParamAttrs> OptFuncNotes FuncNote 
+%type <ParamAttrs> FuncNoteList
 
 // Basic Block Terminating Operators
 %token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
@@ -1297,22 +1297,24 @@
 
 FuncNoteList  : FuncNote { $$ = $1; }
               | FuncNoteList ',' FuncNote { 
-                FunctionNotes tmp = $1 | $3;
-                if ($3 == FN_NOTE_NoInline && ($1 & FN_NOTE_AlwaysInline))
+                unsigned tmp = $1 | $3;
+                if ($3 == ParamAttr::FN_NOTE_NoInline 
+                    && ($1 & ParamAttr::FN_NOTE_AlwaysInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
-                if ($3 == FN_NOTE_AlwaysInline && ($1 & FN_NOTE_NoInline))
+                    if ($3 == ParamAttr::FN_NOTE_AlwaysInline 
+                        && ($1 & ParamAttr::FN_NOTE_NoInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 $$ = tmp;
                 CHECK_FOR_ERROR 
               }
               ;
 
-FuncNote      : INLINE '=' NEVER { $$ = FN_NOTE_NoInline; }
-              | INLINE '=' ALWAYS { $$ = FN_NOTE_AlwaysInline; }
-              | OPTIMIZEFORSIZE { $$ = FN_NOTE_OptimizeForSize; }
+FuncNote      : INLINE '=' NEVER { $$ = ParamAttr::FN_NOTE_NoInline; }
+              | INLINE '=' ALWAYS { $$ = ParamAttr::FN_NOTE_AlwaysInline; }
+              | OPTIMIZEFORSIZE { $$ = ParamAttr::FN_NOTE_OptimizeForSize; }
               ;
 
-OptFuncNotes  : /* empty */ { $$ = FN_NOTE_None; }
+OptFuncNotes  : /* empty */ { $$ = ParamAttr::FN_NOTE_None; }
               | FNNOTE '(' FuncNoteList  ')' {
                 $$ =  $3;
               }

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Sep 23 17:35:17 2008
@@ -1197,10 +1197,6 @@
           return Error("Invalid GC ID");
         Func->setGC(GCTable[Record[8]-1].c_str());
       }
-      if (!isProto && Record.size() > 9 && Record[9]) {
-        Func->setNotes(Record[9]);
-      }
-      
       ValueList.push_back(Func);
       
       // If this is a function with a body, remember the prototype we are

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Sep 23 17:35:17 2008
@@ -412,7 +412,6 @@
     Vals.push_back(F->hasSection() ? SectionMap[F->getSection()] : 0);
     Vals.push_back(getEncodedVisibility(F));
     Vals.push_back(F->hasGC() ? GCMap[F->getGC()] : 0);
-    Vals.push_back(F->getNotes());
     
     unsigned AbbrevToUse = 0;
     Stream.EmitRecord(bitc::MODULE_CODE_FUNCTION, Vals, AbbrevToUse);

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Sep 23 17:35:17 2008
@@ -160,7 +160,7 @@
   SwitchToTextSection(SectionName.c_str());
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (F->hasNote(FN_NOTE_OptimizeForSize))
+  if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Tue Sep 23 17:35:17 2008
@@ -147,7 +147,7 @@
   SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (F->hasNote(FN_NOTE_OptimizeForSize))
+  if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unsupported linkage type!");

Modified: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp Tue Sep 23 17:35:17 2008
@@ -63,7 +63,7 @@
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
-    if (!I->isDeclaration() && !I->hasNote(FN_NOTE_AlwaysInline))
+    if (!I->isDeclaration() && !I->hasNote(ParamAttr::FN_NOTE_AlwaysInline))
       NeverInline.insert(I);
 
   return false;

Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Tue Sep 23 17:35:17 2008
@@ -65,7 +65,7 @@
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
-    if (I->hasNote(FN_NOTE_NoInline))
+    if (I->hasNote(ParamAttr::FN_NOTE_NoInline))
       NeverInline.insert(I);
 
   // Get llvm.noinline

Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Tue Sep 23 17:35:17 2008
@@ -141,7 +141,7 @@
         
         int CurrentThreshold = InlineThreshold;
         Function *Fn = CS.getCaller();
-        if (Fn && Fn->hasNote(FN_NOTE_OptimizeForSize)
+        if (Fn && Fn->hasNote(ParamAttr::FN_NOTE_OptimizeForSize)
             && InlineThreshold != 50) {
           CurrentThreshold = 50;
         }

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Sep 23 17:35:17 2008
@@ -430,7 +430,7 @@
   Function *F = loopHeader->getParent();
 
   // Do not unswitch if the function is optimized for size.
-  if (F->hasNote(FN_NOTE_OptimizeForSize))
+  if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize))
     return false;
 
   // Check to see if it would be profitable to unswitch current loop.

Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Tue Sep 23 17:35:17 2008
@@ -222,7 +222,7 @@
   if (CalleeFI.NeverInline)
     return 2000000000;
 
-  if (Callee->hasNote(FN_NOTE_AlwaysInline))
+  if (Callee->hasNote(ParamAttr::FN_NOTE_AlwaysInline))
     return -2000000000;
     
   // Add to the inline quality for properties that make the call valuable to

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Sep 23 17:35:17 2008
@@ -1412,12 +1412,12 @@
   } else {
 
     bool insideNotes = false;
-    if (F->hasNote(FN_NOTE_AlwaysInline)) {
+    if (F->hasNote(ParamAttr::FN_NOTE_AlwaysInline)) {
       Out << "notes(";
       insideNotes = true;
       Out << "inline=always";
     }
-    if (F->hasNote(FN_NOTE_NoInline)) {
+    if (F->hasNote(ParamAttr::FN_NOTE_NoInline)) {
       if (insideNotes) 
         Out << ",";
       else {
@@ -1426,7 +1426,7 @@
       }
       Out << "inline=never";
     }
-    if (F->hasNote(FN_NOTE_OptimizeForSize)) {
+    if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize)) {
       if (insideNotes) 
         Out << ",";
       else {

Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Tue Sep 23 17:35:17 2008
@@ -174,7 +174,6 @@
   if (unsigned IID = getIntrinsicID(true))
     setParamAttrs(Intrinsic::getParamAttrs(Intrinsic::ID(IID)));
 
-  Notes = 0;
 }
 
 Function::~Function() {

Modified: llvm/trunk/lib/VMCore/ParameterAttributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ParameterAttributes.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/ParameterAttributes.cpp (original)
+++ llvm/trunk/lib/VMCore/ParameterAttributes.cpp Tue Sep 23 17:35:17 2008
@@ -186,6 +186,7 @@
 
 /// getParamAttrs - The parameter attributes for the specified parameter are
 /// returned.  Parameters for the result are denoted with Idx = 0.
+/// Function notes are denoted with idx = ~0.
 ParameterAttributes PAListPtr::getParamAttrs(unsigned Idx) const {
   if (PAList == 0) return ParamAttr::None;
   

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=56511&r1=56510&r2=56511&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Tue Sep 23 17:35:17 2008
@@ -477,6 +477,19 @@
   }
 }
 
+static bool VerifyAttributeCount(const PAListPtr &Attrs, unsigned Params) {
+  if (Attrs.isEmpty())
+    return true;
+    
+  unsigned LastSlot = Attrs.getNumSlots() - 1;
+  unsigned LastIndex = Attrs.getSlot(LastSlot).Index;
+  if (LastIndex <= Params
+      || (LastIndex == (unsigned)~0
+          && (LastSlot == 0 || Attrs.getSlot(LastSlot - 1).Index <= Params)))  
+    return true;
+    
+  return false;
+}
 // visitFunction - Verify that a function is ok.
 //
 void Verifier::visitFunction(Function &F) {
@@ -497,8 +510,7 @@
 
   const PAListPtr &Attrs = F.getParamAttrs();
 
-  Assert1(Attrs.isEmpty() ||
-          Attrs.getSlot(Attrs.getNumSlots()-1).Index <= FT->getNumParams(),
+  Assert1(VerifyAttributeCount(Attrs, FT->getNumParams()),
           "Attributes after last parameter!", &F);
 
   // Check function attributes.
@@ -955,8 +967,7 @@
 
   const PAListPtr &Attrs = CS.getParamAttrs();
 
-  Assert1(Attrs.isEmpty() ||
-          Attrs.getSlot(Attrs.getNumSlots()-1).Index <= CS.arg_size(),
+  Assert1(VerifyAttributeCount(Attrs, CS.arg_size()),
           "Attributes after last parameter!", I);
 
   // Verify call attributes.





More information about the llvm-commits mailing list