[llvm-commits] [llvm] r44250 - in /llvm/trunk/lib: Bitcode/Reader/BitcodeReader.cpp VMCore/Function.cpp

Duncan Sands baldrick at free.fr
Tue Nov 20 06:09:30 PST 2007


Author: baldrick
Date: Tue Nov 20 08:09:29 2007
New Revision: 44250

URL: http://llvm.org/viewvc/llvm-project?rev=44250&view=rev
Log:
In order for parameter attribute uniquing to make
any sense it is important that ParamAttr::None gets
treated the same as not supplying an attribute at
all.  Rather than stripping ParamAttr::None out of
the list of attributes, assert if ParamAttr::None
is seen.  Fix up the bitcode reader which liked to
insert ParamAttr::None all over the place.  Patch
based on one by Török Edwin.

Modified:
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/VMCore/Function.cpp

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

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Nov 20 08:09:29 2007
@@ -232,17 +232,15 @@
       if (Record.size() & 1)
         return Error("Invalid ENTRY record");
 
-      ParamAttrsWithIndex PAWI;
       for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
-        PAWI.index = Record[i];
-        PAWI.attrs = Record[i+1];
-        Attrs.push_back(PAWI);
+        if (Record[i+1] != ParamAttr::None)
+          Attrs.push_back(ParamAttrsWithIndex::get(Record[i], Record[i+1]));
       }
-      ParamAttrs.push_back(ParamAttrsList::get(Attrs));
+      ParamAttrs.push_back(Attrs.empty() ? NULL : ParamAttrsList::get(Attrs));
       Attrs.clear();
       break;
     }
-    }    
+    }
   }
 }
 

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

==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Tue Nov 20 08:09:29 2007
@@ -129,8 +129,12 @@
 ParamAttrsList::get(const ParamAttrsVector &attrVec) {
   assert(!attrVec.empty() && "Illegal to create empty ParamAttrsList");
 #ifndef NDEBUG
-  for (unsigned i = 1, e = attrVec.size(); i < e; ++i)
-    assert(attrVec[i-1].index < attrVec[i].index && "Misordered ParamAttrsList!");
+  for (unsigned i = 0, e = attrVec.size(); i < e; ++i) {
+    assert(attrVec[i].attrs != ParamAttr::None
+           && "Pointless parameter attribute!");
+    assert((!i || attrVec[i-1].index < attrVec[i].index)
+           && "Misordered ParamAttrsList!");
+  }
 #endif
   ParamAttrsList key(attrVec);
   FoldingSetNodeID ID;





More information about the llvm-commits mailing list