MCPcopy Create free account
hub / github.com/GANGE666/xVMP / parseModuleStringTable

Method parseModuleStringTable

src/lib/Bitcode/Reader/BitcodeReader.cpp:5620–5678  ·  view source on GitHub ↗

Parse the module string table block into the Index. This populates the ModulePathStringTable map in the index.

Source from the content-addressed store, hash-verified

5618// Parse the module string table block into the Index.
5619// This populates the ModulePathStringTable map in the index.
5620Error ModuleSummaryIndexBitcodeReader::parseModuleStringTable() {
5621 if (Stream.EnterSubBlock(bitc::MODULE_STRTAB_BLOCK_ID))
5622 return error("Invalid record");
5623
5624 SmallVector<uint64_t, 64> Record;
5625
5626 SmallString<128> ModulePath;
5627 ModuleSummaryIndex::ModuleInfo *LastSeenModule = nullptr;
5628
5629 while (true) {
5630 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
5631
5632 switch (Entry.Kind) {
5633 case BitstreamEntry::SubBlock: // Handled for us already.
5634 case BitstreamEntry::Error:
5635 return error("Malformed block");
5636 case BitstreamEntry::EndBlock:
5637 return Error::success();
5638 case BitstreamEntry::Record:
5639 // The interesting case.
5640 break;
5641 }
5642
5643 Record.clear();
5644 switch (Stream.readRecord(Entry.ID, Record)) {
5645 default: // Default behavior: ignore.
5646 break;
5647 case bitc::MST_CODE_ENTRY: {
5648 // MST_ENTRY: [modid, namechar x N]
5649 uint64_t ModuleId = Record[0];
5650
5651 if (convertToString(Record, 1, ModulePath))
5652 return error("Invalid record");
5653
5654 LastSeenModule = TheIndex.addModule(ModulePath, ModuleId);
5655 ModuleIdMap[ModuleId] = LastSeenModule->first();
5656
5657 ModulePath.clear();
5658 break;
5659 }
5660 /// MST_CODE_HASH: [5*i32]
5661 case bitc::MST_CODE_HASH: {
5662 if (Record.size() != 5)
5663 return error("Invalid hash length " + Twine(Record.size()).str());
5664 if (!LastSeenModule)
5665 return error("Invalid hash that does not follow a module path");
5666 int Pos = 0;
5667 for (auto &Val : Record) {
5668 assert(!(Val >> 32) && "Unexpected high bits set");
5669 LastSeenModule->second.second[Pos++] = Val;
5670 }
5671 // Reset LastSeenModule to avoid overriding the hash unexpectedly.
5672 LastSeenModule = nullptr;
5673 break;
5674 }
5675 }
5676 }
5677 llvm_unreachable("Exit infinite loop");

Callers

nothing calls this directly

Calls 13

successFunction · 0.85
EnterSubBlockMethod · 0.80
errorFunction · 0.70
convertToStringFunction · 0.70
TwineClass · 0.50
assertFunction · 0.50
clearMethod · 0.45
readRecordMethod · 0.45
addModuleMethod · 0.45
firstMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected