summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-12-28 19:44:19 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-12-28 19:44:19 +0000
commit32ca14819848b362af9e1879f3811e68427f5279 (patch)
treea3e908a27535a53a4ba4b72c4a30d49baba0af65 /llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
parent26dada79ffeba8237f50827da884111809633c7e (diff)
downloadbcm5719-llvm-32ca14819848b362af9e1879f3811e68427f5279.tar.gz
bcm5719-llvm-32ca14819848b362af9e1879f3811e68427f5279.zip
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 llvm-svn: 290684
Diffstat (limited to 'llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp')
-rw-r--r--llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index e494343bf87..3220063275b 100644
--- a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/llvm/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)
OpenPOWER on IntegriCloud