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

Method parseUseLists

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

Source from the content-addressed store, hash-verified

2642}
2643
2644Error BitcodeReader::parseUseLists() {
2645 if (Stream.EnterSubBlock(bitc::USELIST_BLOCK_ID))
2646 return error("Invalid record");
2647
2648 // Read all the records.
2649 SmallVector<uint64_t, 64> Record;
2650
2651 while (true) {
2652 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
2653
2654 switch (Entry.Kind) {
2655 case BitstreamEntry::SubBlock: // Handled for us already.
2656 case BitstreamEntry::Error:
2657 return error("Malformed block");
2658 case BitstreamEntry::EndBlock:
2659 return Error::success();
2660 case BitstreamEntry::Record:
2661 // The interesting case.
2662 break;
2663 }
2664
2665 // Read a use list record.
2666 Record.clear();
2667 bool IsBB = false;
2668 switch (Stream.readRecord(Entry.ID, Record)) {
2669 default: // Default behavior: unknown type.
2670 break;
2671 case bitc::USELIST_CODE_BB:
2672 IsBB = true;
2673 LLVM_FALLTHROUGH;
2674 case bitc::USELIST_CODE_DEFAULT: {
2675 unsigned RecordLength = Record.size();
2676 if (RecordLength < 3)
2677 // Records should have at least an ID and two indexes.
2678 return error("Invalid record");
2679 unsigned ID = Record.back();
2680 Record.pop_back();
2681
2682 Value *V;
2683 if (IsBB) {
2684 assert(ID < FunctionBBs.size() && "Basic block not found");
2685 V = FunctionBBs[ID];
2686 } else
2687 V = ValueList[ID];
2688 unsigned NumUses = 0;
2689 SmallDenseMap<const Use *, unsigned, 16> Order;
2690 for (const Use &U : V->materialized_uses()) {
2691 if (++NumUses > Record.size())
2692 break;
2693 Order[&U] = Record[NumUses - 1];
2694 }
2695 if (Order.size() != Record.size() || NumUses > Record.size())
2696 // Mismatches can happen if the functions are being materialized lazily
2697 // (out-of-order), or a value has been upgraded.
2698 break;
2699
2700 V->sortUseList([&](const Use &L, const Use &R) {
2701 return Order.lookup(&L) < Order.lookup(&R);

Callers

nothing calls this directly

Calls 13

successFunction · 0.85
EnterSubBlockMethod · 0.80
materialized_usesMethod · 0.80
sortUseListMethod · 0.80
errorFunction · 0.70
assertFunction · 0.50
clearMethod · 0.45
readRecordMethod · 0.45
sizeMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected