[llvm-bcanalyzer] Dump bitcode wrapper header

This patch enables llvm-bcanalyzer to print the bitcode wrapper header
if the file has one, which is needed to test the changes made in
r258627 (bitcode-wrapper-header-armv7m.ll is the test case for r258627).

Differential Revision: http://reviews.llvm.org/D16642

llvm-svn: 259162
This commit is contained in:
Akira Hatanaka
2016-01-29 05:55:09 +00:00
parent f2bb710da5
commit 4f472a8867
5 changed files with 47 additions and 19 deletions

View File

@@ -2966,10 +2966,6 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream,
/// uint32_t CPUType; // CPU specifier.
/// ... potentially more later ...
/// };
enum {
DarwinBCSizeFieldOffset = 3*4, // Offset to bitcode_size.
DarwinBCHeaderSize = 5*4
};
static void WriteInt32ToBuffer(uint32_t Value, SmallVectorImpl<char> &Buffer,
uint32_t &Position) {
@@ -3005,10 +3001,10 @@ static void EmitDarwinBCHeaderAndTrailer(SmallVectorImpl<char> &Buffer,
CPUType = DARWIN_CPU_TYPE_ARM;
// Traditional Bitcode starts after header.
assert(Buffer.size() >= DarwinBCHeaderSize &&
assert(Buffer.size() >= BWH_HeaderSize &&
"Expected header size to be reserved");
unsigned BCOffset = DarwinBCHeaderSize;
unsigned BCSize = Buffer.size()-DarwinBCHeaderSize;
unsigned BCOffset = BWH_HeaderSize;
unsigned BCSize = Buffer.size() - BWH_HeaderSize;
// Write the magic and version.
unsigned Position = 0;
@@ -3046,7 +3042,7 @@ void llvm::WriteBitcodeToFile(const Module *M, raw_ostream &Out,
// header.
Triple TT(M->getTargetTriple());
if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
Buffer.insert(Buffer.begin(), DarwinBCHeaderSize, 0);
Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0);
// Emit the module into the buffer.
{