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

Method getLTOInfo

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

Check if the given bitcode buffer contains a global value summary block.

Source from the content-addressed store, hash-verified

5971
5972// Check if the given bitcode buffer contains a global value summary block.
5973Expected<BitcodeLTOInfo> BitcodeModule::getLTOInfo() {
5974 BitstreamCursor Stream(Buffer);
5975 Stream.JumpToBit(ModuleBit);
5976
5977 if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
5978 return error("Invalid record");
5979
5980 while (true) {
5981 BitstreamEntry Entry = Stream.advance();
5982
5983 switch (Entry.Kind) {
5984 case BitstreamEntry::Error:
5985 return error("Malformed block");
5986 case BitstreamEntry::EndBlock:
5987 return BitcodeLTOInfo{/*IsThinLTO=*/false, /*HasSummary=*/false,
5988 /*EnableSplitLTOUnit=*/false};
5989
5990 case BitstreamEntry::SubBlock:
5991 if (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID) {
5992 Expected<bool> EnableSplitLTOUnit =
5993 getEnableSplitLTOUnitFlag(Stream, Entry.ID);
5994 if (!EnableSplitLTOUnit)
5995 return EnableSplitLTOUnit.takeError();
5996 return BitcodeLTOInfo{/*IsThinLTO=*/true, /*HasSummary=*/true,
5997 *EnableSplitLTOUnit};
5998 }
5999
6000 if (Entry.ID == bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID) {
6001 Expected<bool> EnableSplitLTOUnit =
6002 getEnableSplitLTOUnitFlag(Stream, Entry.ID);
6003 if (!EnableSplitLTOUnit)
6004 return EnableSplitLTOUnit.takeError();
6005 return BitcodeLTOInfo{/*IsThinLTO=*/false, /*HasSummary=*/true,
6006 *EnableSplitLTOUnit};
6007 }
6008
6009 // Ignore other sub-blocks.
6010 if (Stream.SkipBlock())
6011 return error("Malformed block");
6012 continue;
6013
6014 case BitstreamEntry::Record:
6015 Stream.skipRecord(Entry.ID);
6016 continue;
6017 }
6018 }
6019}
6020
6021static Expected<BitcodeModule> getSingleModule(MemoryBufferRef Buffer) {
6022 Expected<std::vector<BitcodeModule>> MsOrErr = getBitcodeModuleList(Buffer);

Callers 3

FindThinLTOModuleMethod · 0.80
addModuleMethod · 0.80
getBitcodeLTOInfoMethod · 0.80

Calls 8

JumpToBitMethod · 0.80
EnterSubBlockMethod · 0.80
SkipBlockMethod · 0.80
skipRecordMethod · 0.80
errorFunction · 0.70
advanceMethod · 0.45
takeErrorMethod · 0.45

Tested by

no test coverage detected