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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146078 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chad Rosier
2011-12-07 21:44:12 +00:00
parent e77ae2d692
commit cbbb09687f
4 changed files with 85 additions and 1 deletions

View File

@@ -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();
}