Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 9 additions & 25 deletions llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8566,16 +8566,13 @@ Expected<std::unique_ptr<ModuleSummaryIndex>> BitcodeModule::getSummary() {
}

static Expected<std::pair<bool, bool>>
getEnableSplitLTOUnitAndUnifiedFlag(BitstreamCursor &Stream,
unsigned ID,
BitcodeLTOInfo &LTOInfo) {
getEnableSplitLTOUnitAndUnifiedFlag(BitstreamCursor &Stream, unsigned ID) {
if (Error Err = Stream.EnterSubBlock(ID))
return std::move(Err);
SmallVector<uint64_t, 64> Record;

SmallVector<uint64_t, 64> Record;
while (true) {
BitstreamEntry Entry;
std::pair<bool, bool> Result = {false,false};
if (Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
return std::move(E);

Expand All @@ -8584,8 +8581,8 @@ getEnableSplitLTOUnitAndUnifiedFlag(BitstreamCursor &Stream,
case BitstreamEntry::Error:
return error("Malformed block");
case BitstreamEntry::EndBlock: {
// If no flags record found, set both flags to false.
return Result;
// If no flags record found, return both flags as false.
return std::make_pair(false, false);
}
case BitstreamEntry::Record:
// The interesting case.
Expand All @@ -8607,9 +8604,7 @@ getEnableSplitLTOUnitAndUnifiedFlag(BitstreamCursor &Stream,

bool EnableSplitLTOUnit = Flags & 0x8;
bool UnifiedLTO = Flags & 0x200;
Result = {EnableSplitLTOUnit, UnifiedLTO};

return Result;
return std::make_pair(EnableSplitLTOUnit, UnifiedLTO);
}
}
}
Expand Down Expand Up @@ -8638,26 +8633,15 @@ Expected<BitcodeLTOInfo> BitcodeModule::getLTOInfo() {
/*EnableSplitLTOUnit=*/false, /*UnifiedLTO=*/false};

case BitstreamEntry::SubBlock:
if (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID) {
BitcodeLTOInfo LTOInfo;
if (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID ||
Entry.ID == bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID) {
Expected<std::pair<bool, bool>> Flags =
getEnableSplitLTOUnitAndUnifiedFlag(Stream, Entry.ID, LTOInfo);
getEnableSplitLTOUnitAndUnifiedFlag(Stream, Entry.ID);
if (!Flags)
return Flags.takeError();
std::tie(LTOInfo.EnableSplitLTOUnit, LTOInfo.UnifiedLTO) = Flags.get();
LTOInfo.IsThinLTO = true;
LTOInfo.HasSummary = true;
return LTOInfo;
}

if (Entry.ID == bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID) {
BitcodeLTOInfo LTOInfo;
Expected<std::pair<bool, bool>> Flags =
getEnableSplitLTOUnitAndUnifiedFlag(Stream, Entry.ID, LTOInfo);
if (!Flags)
return Flags.takeError();
std::tie(LTOInfo.EnableSplitLTOUnit, LTOInfo.UnifiedLTO) = Flags.get();
LTOInfo.IsThinLTO = false;
LTOInfo.IsThinLTO = (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID);
LTOInfo.HasSummary = true;
return LTOInfo;
}
Expand Down