diff options
author | Chris Lattner <sabre@nondot.org> | 2007-05-01 02:14:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-05-01 02:14:57 +0000 |
commit | be1f993f2d1d064de4451cb6d049304a3314d5c6 (patch) | |
tree | e599f9a12dea9e446d52d4569f9c07364d288c44 /lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | d309c75b7d9513e04824c6630328e0ace3e6446c (diff) |
write the symbol table for function bodies
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36610 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | lib/Bitcode/Writer/BitcodeWriter.cpp | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index ad2534c75e..437ef91fd1 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -683,6 +683,36 @@ static void WriteInstruction(const Instruction &I, ValueEnumerator &VE, 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 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE, 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 @@ static void WriteTypeSymbolTable(const TypeSymbolTable &TST, 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) { |