Skip to content

Commit ab487b6

Browse files
authored
[BitcodeReader][NFC] Tidy getEnableSplitLTOUnitAndUnifiedFlag (#165732)
1 parent 0cae0af commit ab487b6

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8566,16 +8566,13 @@ Expected<std::unique_ptr<ModuleSummaryIndex>> BitcodeModule::getSummary() {
85668566
}
85678567

85688568
static Expected<std::pair<bool, bool>>
8569-
getEnableSplitLTOUnitAndUnifiedFlag(BitstreamCursor &Stream,
8570-
unsigned ID,
8571-
BitcodeLTOInfo &LTOInfo) {
8569+
getEnableSplitLTOUnitAndUnifiedFlag(BitstreamCursor &Stream, unsigned ID) {
85728570
if (Error Err = Stream.EnterSubBlock(ID))
85738571
return std::move(Err);
8574-
SmallVector<uint64_t, 64> Record;
85758572

8573+
SmallVector<uint64_t, 64> Record;
85768574
while (true) {
85778575
BitstreamEntry Entry;
8578-
std::pair<bool, bool> Result = {false,false};
85798576
if (Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
85808577
return std::move(E);
85818578

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

86088605
bool EnableSplitLTOUnit = Flags & 0x8;
86098606
bool UnifiedLTO = Flags & 0x200;
8610-
Result = {EnableSplitLTOUnit, UnifiedLTO};
8611-
8612-
return Result;
8607+
return std::make_pair(EnableSplitLTOUnit, UnifiedLTO);
86138608
}
86148609
}
86158610
}
@@ -8638,26 +8633,15 @@ Expected<BitcodeLTOInfo> BitcodeModule::getLTOInfo() {
86388633
/*EnableSplitLTOUnit=*/false, /*UnifiedLTO=*/false};
86398634

86408635
case BitstreamEntry::SubBlock:
8641-
if (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID) {
8642-
BitcodeLTOInfo LTOInfo;
8636+
if (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID ||
8637+
Entry.ID == bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID) {
86438638
Expected<std::pair<bool, bool>> Flags =
8644-
getEnableSplitLTOUnitAndUnifiedFlag(Stream, Entry.ID, LTOInfo);
8639+
getEnableSplitLTOUnitAndUnifiedFlag(Stream, Entry.ID);
86458640
if (!Flags)
86468641
return Flags.takeError();
8647-
std::tie(LTOInfo.EnableSplitLTOUnit, LTOInfo.UnifiedLTO) = Flags.get();
8648-
LTOInfo.IsThinLTO = true;
8649-
LTOInfo.HasSummary = true;
8650-
return LTOInfo;
8651-
}
8652-
8653-
if (Entry.ID == bitc::FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID) {
86548642
BitcodeLTOInfo LTOInfo;
8655-
Expected<std::pair<bool, bool>> Flags =
8656-
getEnableSplitLTOUnitAndUnifiedFlag(Stream, Entry.ID, LTOInfo);
8657-
if (!Flags)
8658-
return Flags.takeError();
86598643
std::tie(LTOInfo.EnableSplitLTOUnit, LTOInfo.UnifiedLTO) = Flags.get();
8660-
LTOInfo.IsThinLTO = false;
8644+
LTOInfo.IsThinLTO = (Entry.ID == bitc::GLOBALVAL_SUMMARY_BLOCK_ID);
86618645
LTOInfo.HasSummary = true;
86628646
return LTOInfo;
86638647
}

0 commit comments

Comments
 (0)