[llvm] r174910 - Use a std::map so that we record the group ID.

Bill Wendling isanbard at gmail.com
Mon Feb 11 14:32:30 PST 2013


Author: void
Date: Mon Feb 11 16:32:29 2013
New Revision: 174910

URL: http://llvm.org/viewvc/llvm-project?rev=174910&view=rev
Log:
Use a std::map so that we record the group ID.

Modified:
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=174910&r1=174909&r2=174910&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Feb 11 16:32:29 2013
@@ -531,8 +531,7 @@ bool BitcodeReader::ParseAttributeGroupB
       if (Record.size() < 3)
         return Error("Invalid ENTRY record");
 
-      // FIXME: Record[0] is the 'group ID'. What should we do with it here?
-
+      uint64_t GrpID = Record[0];
       uint64_t Idx = Record[1]; // Index of the object this attribute refers to.
 
       AttrBuilder B;
@@ -545,27 +544,29 @@ bool BitcodeReader::ParseAttributeGroupB
           else
             B.addStackAlignmentAttr(Record[++i]);
         } else {                     // String attribute
+          assert((Record[i] == 3 || Record[i] == 4) &&
+                 "Invalid attribute group entry");
           bool HasValue = (Record[i++] == 4);
           SmallString<64> KindStr;
           SmallString<64> ValStr;
 
           while (Record[i] != 0 && i != e)
             KindStr += Record[i++];
-          assert(Record[i] == 0 && "Kind string not terminated with 0");
+          assert(Record[i] == 0 && "Kind string not null terminated");
 
           if (HasValue) {
             // Has a value associated with it.
-            ++i; // Skip the '0' that terminates the kind string.
+            ++i; // Skip the '0' that terminates the "kind" string.
             while (Record[i] != 0 && i != e)
               ValStr += Record[i++];
-            assert(Record[i] == 0 && "Value string not terminated with 0");
+            assert(Record[i] == 0 && "Value string not null terminated");
           }
 
           B.addAttribute(KindStr.str(), ValStr.str());
         }
       }
 
-      MAttributeGroups.push_back(AttributeSet::get(Context, Idx, B));
+      MAttributeGroups[GrpID] = AttributeSet::get(Context, Idx, B);
       break;
     }
     }

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h?rev=174910&r1=174909&r2=174910&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h Mon Feb 11 16:32:29 2013
@@ -149,7 +149,7 @@ class BitcodeReader : public GVMateriali
   std::vector<AttributeSet> MAttributes;
 
   /// \brief The set of attribute groups.
-  std::vector<AttributeSet> MAttributeGroups;
+  std::map<unsigned, AttributeSet> MAttributeGroups;
 
   /// FunctionBBs - While parsing a function body, this is a list of the basic
   /// blocks for the function.





More information about the llvm-commits mailing list