Prevent an empty compaction table from being written to the bytecode file.
authorReid Spencer <rspencer@reidspencer.com>
Fri, 27 Aug 2004 00:38:44 +0000 (00:38 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Fri, 27 Aug 2004 00:38:44 +0000 (00:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16063 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Writer/Writer.cpp

index 6654fd1b023bae8886d9e87593d3d99931c1223e..7db2148603404f5b2eca731f69e701bb30360ff4 100644 (file)
@@ -1034,15 +1034,19 @@ void BytecodeWriter::outputCompactionTypes(unsigned StartNo) {
 }
 
 void BytecodeWriter::outputCompactionTable() {
-  BytecodeBlock CTB(BytecodeFormat::CompactionTableBlockID, *this, 
-                    true/*ElideIfEmpty*/);
-  const std::vector<std::vector<const Value*> > &CT =Table.getCompactionTable();
-  
-  // First thing is first, emit the type compaction table if there is one.
-  outputCompactionTypes(Type::FirstDerivedTyID);
+  // Avoid writing the compaction table at all if there is no content.
+  if (Table.getCompactionTypes().size() >= Type::FirstDerivedTyID ||
+      (!Table.CompactionTableIsEmpty())) {
+    BytecodeBlock CTB(BytecodeFormat::CompactionTableBlockID, *this, 
+                      true/*ElideIfEmpty*/);
+    const std::vector<std::vector<const Value*> > &CT =Table.getCompactionTable();
+    
+    // First things first, emit the type compaction table if there is one.
+    outputCompactionTypes(Type::FirstDerivedTyID);
 
-  for (unsigned i = 0, e = CT.size(); i != e; ++i)
-    outputCompactionTablePlane(i, CT[i], 0);
+    for (unsigned i = 0, e = CT.size(); i != e; ++i)
+      outputCompactionTablePlane(i, CT[i], 0);
+  }
 }
 
 void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {