[llvm-commits] CVS: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Chris Lattner sabre at nondot.org
Sat May 5 00:45:07 PDT 2007



Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.40 -> 1.41
---
Log message:

add an abbrev for loads.  This shrinks the function block about 50K, from:

  Block ID #12 (FUNCTION_BLOCK):
      Num Instances: 2344
         Total Size: 8.8434e+06b/1.10542e+06B/276356W
          % of file: 35.6726
       Average Size: 3772.78b/471.598B/117.899W
  Tot/Avg SubBlocks: 4065/1.73422
    Tot/Avg Abbrevs: 0/0
    Tot/Avg Records: 128487/54.8153
      % Abbrev Recs: 0

to:

 Block ID #12 (FUNCTION_BLOCK):
      Num Instances: 2344
         Total Size: 8.44518e+06b/1.05565e+06B/263912W
          % of file: 34.6203
       Average Size: 3602.89b/450.362B/112.59W
  Tot/Avg SubBlocks: 4065/1.73422
    Tot/Avg Abbrevs: 0/0
    Tot/Avg Records: 128487/54.8153
      % Abbrev Recs: 22.2077



---
Diffs of the changes:  (+22 -1)

 BitcodeWriter.cpp |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.40 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.41
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.40	Sat May  5 02:36:14 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp	Sat May  5 02:44:49 2007
@@ -40,7 +40,10 @@
   CONSTANTS_SETTYPE_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
   CONSTANTS_INTEGER_ABBREV,
   CONSTANTS_CE_CAST_Abbrev,
-  CONSTANTS_NULL_Abbrev
+  CONSTANTS_NULL_Abbrev,
+  
+  // FUNCTION_BLOCK abbrev id's.
+  FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV
 };
 
 
@@ -722,6 +725,7 @@
     Vals.push_back(VE.getValueID(I.getOperand(0))); // ptr.
     Vals.push_back(Log2_32(cast<LoadInst>(I).getAlignment())+1);
     Vals.push_back(cast<LoadInst>(I).isVolatile());
+    AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
     break;
   case Instruction::Store:
     Code = bitc::FUNC_CODE_INST_STORE;
@@ -947,6 +951,8 @@
       assert(0 && "Unexpected abbrev ordering!");
   }
   
+  
+  
   { // SETTYPE abbrev for CONSTANTS_BLOCK.
     BitCodeAbbrev *Abbv = new BitCodeAbbrev();
     Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_SETTYPE));
@@ -986,6 +992,21 @@
       assert(0 && "Unexpected abbrev ordering!");
   }
   
+  // FIXME: This should only use space for first class types!
+ 
+  { // INST_LOAD abbrev for FUNCTION_BLOCK.
+    BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+    Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_LOAD));
+    Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,       // typeid
+                              Log2_32_Ceil(VE.getTypes().size()+1)));
+    Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Ptr
+    Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // Align
+    Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // volatile
+    if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
+                                   Abbv) != FUNCTION_INST_LOAD_ABBREV)
+      assert(0 && "Unexpected abbrev ordering!");
+  }
+  
   Stream.ExitBlock();
 }
 






More information about the llvm-commits mailing list