diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-12-28 19:44:19 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-12-28 19:44:19 +0000 |
commit | a0ca6ae2d38339e4ede0dfa588086fc23d87e836 (patch) | |
tree | 69eeaec4f009161e0599a451df8ab33e0fd873fc /tools/llvm-bcanalyzer | |
parent | 25a09f14f34eb015f0f2b9c2bf8d95f94204c32b (diff) |
Add an index for Module Metadata record in the bitcode
Summary:
This index record the position for each metadata record in
the bitcode, so that the reader will be able to lazy-load
on demand each individual record.
We also make sure that every abbrev is emitted upfront so
that the block can be skipped while reading.
I don't plan to commit this before having the reader
counterpart, but I figured this can be reviewed mostly
independently.
Reviewers: pcc, tejohnson
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D28083
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-bcanalyzer')
-rw-r--r-- | tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index e494343bf87..3220063275b 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -353,6 +353,8 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, STRINGIFY_CODE(METADATA, OBJC_PROPERTY) STRINGIFY_CODE(METADATA, IMPORTED_ENTITY) STRINGIFY_CODE(METADATA, MODULE) + STRINGIFY_CODE(METADATA, INDEX_OFFSET) + STRINGIFY_CODE(METADATA, INDEX) } case bitc::METADATA_KIND_BLOCK_ID: switch (CodeID) { @@ -514,6 +516,9 @@ static bool ParseBlock(BitstreamCursor &Stream, BitstreamBlockInfo &BlockInfo, SmallVector<uint64_t, 64> Record; + // Keep the offset to the metadata index if seen. + uint64_t MetadataIndexOffset = 0; + // Read all the records for this block. while (1) { if (Stream.AtEndOfStream()) @@ -600,6 +605,22 @@ static bool ParseBlock(BitstreamCursor &Stream, BitstreamBlockInfo &BlockInfo, for (unsigned i = 0, e = Record.size(); i != e; ++i) outs() << " op" << i << "=" << (int64_t)Record[i]; + // If we found a metadata index, let's verify that we had an offset before + // and validate its forward reference offset was correct! + if (BlockID == bitc::METADATA_BLOCK_ID) { + if (Code == bitc::METADATA_INDEX_OFFSET) { + MetadataIndexOffset = Stream.GetCurrentBitNo() + Record[0]; + } + if (Code == bitc::METADATA_INDEX) { + outs() << " (offset "; + if (MetadataIndexOffset == RecordStartBit) + outs() << "match)"; + else + outs() << "mismatch: " << MetadataIndexOffset << " vs " + << RecordStartBit << ")"; + } + } + // If we found a module hash, let's verify that it matches! if (BlockID == bitc::MODULE_BLOCK_ID && Code == bitc::MODULE_CODE_HASH) { if (Record.size() != 5) |