diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-12-07 21:44:12 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-12-07 21:44:12 +0000 |
commit | ca2567b8613a448569842fed39dd60177cbd3510 (patch) | |
tree | 3cfb70c40c079cfffddfce18b1ce244e07c3b75b /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | d63851eb93891ffd8e13a3cefbffb07dc6b78377 (diff) | |
download | bcm5719-llvm-ca2567b8613a448569842fed39dd60177cbd3510.tar.gz bcm5719-llvm-ca2567b8613a448569842fed39dd60177cbd3510.zip |
Begin adding experimental support for preserving use-list ordering of bitcode
files. First, add a new block USELIST_BLOCK to the bitcode format. This is
where USELIST_CODE_ENTRYs will be stored. The format of the USELIST_CODE_ENTRYs
have not yet been defined. Add support in the BitcodeReader for parsing the
USELIST_BLOCK.
Part of rdar://9860654 and PR5680.
llvm-svn: 146078
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index e758f944947..48f60bc3c57 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -23,6 +23,7 @@ #include "llvm/Operator.h" #include "llvm/ValueSymbolTable.h" #include "llvm/ADT/Triple.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" @@ -31,6 +32,12 @@ #include <map> using namespace llvm; +static cl::opt<bool> +EnablePreserveUseListOrdering("enable-bc-uselist-preserve", + cl::desc("Turn on experimental support for " + "use-list order preservation."), + cl::init(false), cl::Hidden); + /// These are manifest constants used by the bitcode writer. They do not need to /// be kept in sync with the reader, but need to be consistent within this file. enum { @@ -1571,6 +1578,20 @@ static void WriteBlockInfo(const ValueEnumerator &VE, BitstreamWriter &Stream) { Stream.ExitBlock(); } +// Emit use-lists. +static void WriteModuleUseLists(const Module *M, ValueEnumerator &VE, + BitstreamWriter &Stream) { + Stream.EnterSubblock(bitc::USELIST_BLOCK_ID, 3); + + // Emit a bogus record for testing purposes. + SmallVector<uint64_t, 64> Record; + Record.push_back(0); + Stream.EmitRecord(bitc::USELIST_CODE_ENTRY, Record); + + // TODO: Tons. + + Stream.ExitBlock(); +} /// WriteModule - Emit the specified module to the bitstream. static void WriteModule(const Module *M, BitstreamWriter &Stream) { @@ -1616,6 +1637,10 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream) { // Emit names for globals/functions etc. WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream); + // Emit use-lists. + if (EnablePreserveUseListOrdering) + WriteModuleUseLists(M, VE, Stream); + Stream.ExitBlock(); } |