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

Reid Spencer reid at x10sys.com
Tue Aug 17 00:45:24 PDT 2004



Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.123 -> 1.124
Reader.h updated: 1.11 -> 1.12
---
Log message:

Bytecode File Format Changes:
- File format version number bumped to 4
- Writer will now align nothing
- Reader now only expects alignment for version 3 or earlier


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

Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.123 llvm/lib/Bytecode/Reader/Reader.cpp:1.124
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.123	Wed Aug  4 17:56:46 2004
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Tue Aug 17 02:45:14 2004
@@ -72,12 +72,14 @@
 
 /// Align the buffer position to a 32 bit boundary
 inline void BytecodeReader::align32() {
-  BufPtr Save = At;
-  At = (const unsigned char *)((unsigned long)(At+3) & (~3UL));
-  if (At > Save) 
-    if (Handler) Handler->handleAlignment(At - Save);
-  if (At > BlockEnd) 
-    error("Ran out of data while aligning!");
+  if (hasAlignment) {
+    BufPtr Save = At;
+    At = (const unsigned char *)((unsigned long)(At+3) & (~3UL));
+    if (At > Save) 
+      if (Handler) Handler->handleAlignment(At - Save);
+    if (At > BlockEnd) 
+      error("Ran out of data while aligning!");
+  }
 }
 
 /// Read a whole unsigned integer
@@ -1886,6 +1888,7 @@
   hasLongBlockHeaders = false;
   has32BitTypes = false;
   hasNoDependentLibraries = false;
+  hasAlignment = false;
 
   switch (RevisionNum) {
   case 0:               //  LLVM 1.0, 1.1 release version
@@ -1937,6 +1940,14 @@
 
     // FALL THROUGH
   case 3:               // LLVM 1.3 release version
+    /// LLVM 1.3 and earlier caused alignment bytes to be written on some block
+    /// boundaries and at the end of some strings. In extreme cases (e.g. lots 
+    /// of GEP references to a constant array), this can increase the file size
+    /// by 30% or more. In version 1.4 alignment is done away with completely.
+    hasAlignment = true;
+
+    // FALL THROUGH
+  case 4:
     break;
 
   default:


Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.11 llvm/lib/Bytecode/Reader/Reader.h:1.12
--- llvm/lib/Bytecode/Reader/Reader.h:1.11	Tue Aug  3 19:19:23 2004
+++ llvm/lib/Bytecode/Reader/Reader.h	Tue Aug 17 02:45:14 2004
@@ -293,8 +293,11 @@
   /// features, for use in future versions of LLVM.
   bool hasNoDependentLibraries;
 
-  /// LLVM 1.2 and earlier encoded the file version as part of the module block
-  /// but this information may be needed to
+  /// LLVM 1.3 and earlier caused blocks and other fields to start on 32-bit
+  /// aligned boundaries. This can lead to as much as 30% bytecode size overhead
+  /// in various corner cases (lots of long instructions). In LLVM 1.4,
+  /// alignment of bytecode fields was done away with completely.
+  bool hasAlignment;
 
   /// CompactionTypes - If a compaction table is active in the current function,
   /// this is the mapping that it contains.  We keep track of what resolved type






More information about the llvm-commits mailing list