[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Chris Lattner sabre at nondot.org
Fri May 4 17:17:24 PDT 2007



Changes in directory llvm/lib/Bitcode/Reader:

BitcodeReader.cpp updated: 1.37 -> 1.38
---
Log message:

Implement support for globally associating abbrevs with block IDs, which
relieves us from having to emit the abbrevs into each instance of the block.
This shrinks kc.bit from 3368K to 3333K, but will be a more significant win
once instructions are abbreviated.

The VST went from:

  Block ID #14 (VALUE_SYMTAB):
      Num Instances: 2345
         Total Size: 1.29508e+07b/1.61885e+06B/404713W
       Average Size: 5522.73b/690.342B/172.585W
          % of file: 48.0645
  Tot/Avg SubBlocks: 0/0
    Tot/Avg Abbrevs: 7035/3
    Tot/Avg Records: 120924/51.5667
      % Abbrev Recs: 100

to:

  Block ID #14 (VALUE_SYMTAB):
      Num Instances: 2345
         Total Size: 1.26713e+07b/1.58391e+06B/395978W
       Average Size: 5403.53b/675.442B/168.86W
          % of file: 47.5198
  Tot/Avg SubBlocks: 0/0
    Tot/Avg Abbrevs: 0/0
    Tot/Avg Records: 120924/51.5667
      % Abbrev Recs: 100

because we didn't emit the same 3 abbrevs 2345 times :)



---
Diffs of the changes:  (+18 -10)

 BitcodeReader.cpp |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)


Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.37 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.38
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.37	Fri May  4 14:11:41 2007
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp	Fri May  4 19:17:00 2007
@@ -182,7 +182,7 @@
 //===----------------------------------------------------------------------===//
 
 bool BitcodeReader::ParseParamAttrBlock() {
-  if (Stream.EnterSubBlock())
+  if (Stream.EnterSubBlock(bitc::PARAMATTR_BLOCK_ID))
     return Error("Malformed block record");
   
   if (!ParamAttrs.empty())
@@ -239,7 +239,7 @@
 
 
 bool BitcodeReader::ParseTypeTable() {
-  if (Stream.EnterSubBlock())
+  if (Stream.EnterSubBlock(bitc::TYPE_BLOCK_ID))
     return Error("Malformed block record");
   
   if (!TypeList.empty())
@@ -378,7 +378,7 @@
 
 
 bool BitcodeReader::ParseTypeSymbolTable() {
-  if (Stream.EnterSubBlock())
+  if (Stream.EnterSubBlock(bitc::TYPE_SYMTAB_BLOCK_ID))
     return Error("Malformed block record");
   
   SmallVector<uint64_t, 64> Record;
@@ -426,7 +426,7 @@
 }
 
 bool BitcodeReader::ParseValueSymbolTable() {
-  if (Stream.EnterSubBlock())
+  if (Stream.EnterSubBlock(bitc::VALUE_SYMTAB_BLOCK_ID))
     return Error("Malformed block record");
 
   SmallVector<uint64_t, 64> Record;
@@ -536,7 +536,7 @@
 
 
 bool BitcodeReader::ParseConstants() {
-  if (Stream.EnterSubBlock())
+  if (Stream.EnterSubBlock(bitc::CONSTANTS_BLOCK_ID))
     return Error("Malformed block record");
 
   SmallVector<uint64_t, 64> Record;
@@ -768,7 +768,7 @@
   if (TheModule)
     return Error("Multiple MODULE_BLOCKs in same stream");
   
-  if (Stream.EnterSubBlock())
+  if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
     return Error("Malformed block record");
 
   // Otherwise, create the module.
@@ -1022,11 +1022,19 @@
     unsigned BlockID = Stream.ReadSubBlockID();
     
     // We only know the MODULE subblock ID.
-    if (BlockID == bitc::MODULE_BLOCK_ID) {
+    switch (BlockID) {
+    case bitc::BLOCKINFO_BLOCK_ID:
+      if (Stream.ReadBlockInfoBlock())
+        return Error("Malformed BlockInfoBlock");
+      break;
+    case bitc::MODULE_BLOCK_ID:
       if (ParseModule(Buffer->getBufferIdentifier()))
         return true;
-    } else if (Stream.SkipBlock()) {
-      return Error("Malformed block record");
+      break;
+    default:
+      if (Stream.SkipBlock())
+        return Error("Malformed block record");
+      break;
     }
   }
   
@@ -1072,7 +1080,7 @@
 
 /// ParseFunctionBody - Lazily parse the specified function body block.
 bool BitcodeReader::ParseFunctionBody(Function *F) {
-  if (Stream.EnterSubBlock())
+  if (Stream.EnterSubBlock(bitc::FUNCTION_BLOCK_ID))
     return Error("Malformed block record");
   
   unsigned ModuleValueListSize = ValueList.size();






More information about the llvm-commits mailing list