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

Chris Lattner sabre at nondot.org
Mon Apr 30 19:15:15 PDT 2007



Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.17 -> 1.18
---
Log message:

write the symbol table for function bodies


---
Diffs of the changes:  (+33 -30)

 BitcodeWriter.cpp |   63 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 33 insertions(+), 30 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.17 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.18
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.17	Mon Apr 30 21:13:26 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp	Mon Apr 30 21:14:57 2007
@@ -683,6 +683,36 @@
   Vals.clear();
 }
 
+// Emit names for globals/functions etc.
+static void WriteValueSymbolTable(const ValueSymbolTable &VST,
+                                  const ValueEnumerator &VE,
+                                  BitstreamWriter &Stream) {
+  if (VST.empty()) return;
+  Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
+  
+  // FIXME: Set up the abbrev, we know how many values there are!
+  // FIXME: We know if the type names can use 7-bit ascii.
+  SmallVector<unsigned, 64> NameVals;
+  
+  for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
+       SI != SE; ++SI) {
+    unsigned AbbrevToUse = 0;
+    
+    // VST_ENTRY: [valueid, namelen, namechar x N]
+    NameVals.push_back(VE.getValueID(SI->getValue()));
+    
+    NameVals.push_back(SI->getKeyLength());
+    for (const char *P = SI->getKeyData(),
+         *E = SI->getKeyData()+SI->getKeyLength(); P != E; ++P)
+      NameVals.push_back((unsigned char)*P);
+    
+    // Emit the finished record.
+    Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse);
+    NameVals.clear();
+  }
+  Stream.ExitBlock();
+}
+
 /// WriteFunction - Emit a function body to the module stream.
 static void WriteFunction(const Function &F, ValueEnumerator &VE, 
                           BitstreamWriter &Stream) {
@@ -709,6 +739,9 @@
     for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
       WriteInstruction(*I, VE, Stream, Vals);
   
+  // Emit names for all the instructions etc.
+  WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream);
+    
   VE.purgeFunction();
   Stream.ExitBlock();
 }
@@ -746,36 +779,6 @@
   Stream.ExitBlock();
 }
 
-// Emit names for globals/functions etc.
-static void WriteValueSymbolTable(const ValueSymbolTable &VST,
-                                  const ValueEnumerator &VE,
-                                  BitstreamWriter &Stream) {
-  if (VST.empty()) return;
-  Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
-  
-  // FIXME: Set up the abbrev, we know how many values there are!
-  // FIXME: We know if the type names can use 7-bit ascii.
-  SmallVector<unsigned, 64> NameVals;
-  
-  for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
-       SI != SE; ++SI) {
-    unsigned AbbrevToUse = 0;
-    
-    // VST_ENTRY: [valueid, namelen, namechar x N]
-    NameVals.push_back(VE.getValueID(SI->getValue()));
-    
-    NameVals.push_back(SI->getKeyLength());
-    for (const char *P = SI->getKeyData(),
-         *E = SI->getKeyData()+SI->getKeyLength(); P != E; ++P)
-      NameVals.push_back((unsigned char)*P);
-    
-    // Emit the finished record.
-    Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse);
-    NameVals.clear();
-  }
-  Stream.ExitBlock();
-}
-
 
 /// WriteModule - Emit the specified module to the bitstream.
 static void WriteModule(const Module *M, BitstreamWriter &Stream) {






More information about the llvm-commits mailing list