[llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp WriterInternals.h

Chris Lattner lattner at cs.uiuc.edu
Mon Dec 1 01:06:04 PST 2003


Changes in directory llvm/lib/Bytecode/Writer:

Writer.cpp updated: 1.45 -> 1.46
WriterInternals.h updated: 1.14 -> 1.15

---
Log message:

Emit & read more compressed bytecode by not emitting a bytecodeblock for
each basic block in function.  Instead, just emit a stream of instructions,
chopping up basic blocks based on when we find terminator instructions.  This
saves a fairly substantial chunk of bytecode space.  In stripped, sample 
cases, for example, we get this reduction in size:

197.parser: 163036 -> 137180:  18.8% reduction
254.gap   : 844936 -> 689392:  22.6%
255.vortex: 621724 -> 528444:  17.7%

...

Not bad for something this simple.  :)  Note that this doesn't require a new
bytecode version number at all, though version 1.1 should not need to support 
the old format.



---
Diffs of the changes:  (+7 -12)

Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.45 llvm/lib/Bytecode/Writer/Writer.cpp:1.46
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.45	Tue Nov 11 16:41:32 2003
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Mon Dec  1 01:05:30 2003
@@ -225,23 +225,19 @@
     // Output information about the constants in the function...
     outputConstants(true);
 
-    // Output basic block nodes...
-    for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I)
-      processBasicBlock(*I);
+    {  // Output all of the instructions in the body of the function
+      BytecodeBlock ILBlock(BytecodeFormat::InstructionList, Out);
+
+      for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E;++BB)
+        for(BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I)
+          processInstruction(*I);
+    }
     
     // If needed, output the symbol table for the function...
     outputSymbolTable(F->getSymbolTable());
     
     Table.purgeFunction();
   }
-}
-
-
-void BytecodeWriter::processBasicBlock(const BasicBlock &BB) {
-  BytecodeBlock FunctionBlock(BytecodeFormat::BasicBlock, Out);
-  // Process all the instructions in the bb...
-  for(BasicBlock::const_iterator I = BB.begin(), E = BB.end(); I != E; ++I)
-    processInstruction(*I);
 }
 
 void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {


Index: llvm/lib/Bytecode/Writer/WriterInternals.h
diff -u llvm/lib/Bytecode/Writer/WriterInternals.h:1.14 llvm/lib/Bytecode/Writer/WriterInternals.h:1.15
--- llvm/lib/Bytecode/Writer/WriterInternals.h:1.14	Tue Nov 11 16:41:32 2003
+++ llvm/lib/Bytecode/Writer/WriterInternals.h	Mon Dec  1 01:05:31 2003
@@ -36,7 +36,6 @@
 protected:
   void outputConstants(bool isFunction);
   void outputFunction(const Function *F);
-  void processBasicBlock(const BasicBlock &BB);
   void processInstruction(const Instruction &I);
 
 private :





More information about the llvm-commits mailing list