Skip to content

Commit b754e60

Browse files
committed
Updates and formatting changes
1 parent e39928e commit b754e60

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,9 @@ void DWARFRewriter::updateDebugInfo() {
631631
uint32_t CUIndex = 0;
632632
std::mutex AccessMutex;
633633
// Needs to be invoked in the same order as CUs are processed.
634+
llvm::DenseMap<uint64_t, uint64_t> LocListWritersIndexByCU;
634635
auto createRangeLocListAddressWriters =
635-
[&](DWARFUnit &CU,
636-
llvm::DenseMap<uint64_t, uint64_t> &LocListWritersIndexByCU) {
636+
[&](DWARFUnit &CU) {
637637
std::lock_guard<std::mutex> Lock(AccessMutex);
638638

639639
const uint16_t DwarfVersion = CU.getVersion();
@@ -679,18 +679,13 @@ void DWARFRewriter::updateDebugInfo() {
679679
DWPState State;
680680
if (opts::WriteDWP)
681681
initDWPState(State);
682-
auto processSplitCU = [&](DWARFUnit &Unit, DIEBuilder &DIEBlder) {
683-
std::optional<DWARFUnit *> SplitCU;
684-
std::optional<uint64_t> DWOId = Unit.getDWOId();
685-
if (DWOId)
686-
SplitCU = BC.getDWOCU(*DWOId);
687-
if (!SplitCU)
688-
return;
689-
DebugAddrWriter &AddressWriter =
690-
*AddressWritersByCU[Unit.getOffset()].get();
691-
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), DebugNamesTable,
682+
auto processSplitCU = [&](DWARFUnit &Unit, DWARFUnit &SplitCU,
683+
DIEBuilder &DIEBlder,
684+
DebugRangesSectionWriter &TempRangesSectionWriter,
685+
DebugAddrWriter &AddressWriter) {
686+
DIEBuilder DWODIEBuilder(BC, &(SplitCU).getContext(), DebugNamesTable,
692687
&Unit);
693-
DWODIEBuilder.buildDWOUnit(**SplitCU);
688+
DWODIEBuilder.buildDWOUnit(SplitCU);
694689
std::string DWOName = "";
695690
std::optional<std::string> DwarfOutputPath =
696691
opts::DwarfOutputPath.empty()
@@ -702,33 +697,31 @@ void DWARFRewriter::updateDebugInfo() {
702697
*StrOffstsWriter, *StrWriter, Unit, DwarfOutputPath, std::nullopt);
703698
}
704699
DebugStrOffsetsWriter DWOStrOffstsWriter(BC);
705-
DebugStrWriter DWOStrWriter((*SplitCU)->getContext(), true);
700+
DebugStrWriter DWOStrWriter((SplitCU).getContext(), true);
706701
DWODIEBuilder.updateDWONameCompDirForTypes(
707-
DWOStrOffstsWriter, DWOStrWriter, **SplitCU, DwarfOutputPath, DWOName);
702+
DWOStrOffstsWriter, DWOStrWriter, SplitCU, DwarfOutputPath, DWOName);
708703
DebugLoclistWriter DebugLocDWoWriter(Unit, Unit.getVersion(), true,
709704
AddressWriter);
710-
DebugRangesSectionWriter *TempRangesSectionWriter =
711-
Unit.getVersion() >= 5 ? RangeListsWritersByCU[*DWOId].get()
712-
: LegacyRangesWritersByCU[*DWOId].get();
713705

714-
updateUnitDebugInfo(*(*SplitCU), DWODIEBuilder, DebugLocDWoWriter,
715-
*TempRangesSectionWriter, AddressWriter);
706+
updateUnitDebugInfo(SplitCU, DWODIEBuilder, DebugLocDWoWriter,
707+
TempRangesSectionWriter, AddressWriter);
716708
DebugLocDWoWriter.finalize(DWODIEBuilder,
717-
*DWODIEBuilder.getUnitDIEbyUnit(**SplitCU));
709+
*DWODIEBuilder.getUnitDIEbyUnit(SplitCU));
718710
if (Unit.getVersion() >= 5)
719-
TempRangesSectionWriter->finalizeSection();
711+
TempRangesSectionWriter.finalizeSection();
720712

721-
emitDWOBuilder(DWOName, DWODIEBuilder, *this, **SplitCU, Unit, State,
713+
emitDWOBuilder(DWOName, DWODIEBuilder, *this, SplitCU, Unit, State,
722714
DebugLocDWoWriter, DWOStrOffstsWriter, DWOStrWriter,
723715
GDBIndexSection);
724716
};
725-
auto processMainBinaryCU = [&](DWARFUnit &Unit, DIEBuilder &DIEBlder,
726-
DebugLocWriter &DebugLocWriter) {
717+
auto processMainBinaryCU = [&](DWARFUnit &Unit, DIEBuilder &DIEBlder) {
727718
DebugAddrWriter &AddressWriter =
728719
*AddressWritersByCU[Unit.getOffset()].get();
729720
DebugRangesSectionWriter &RangesSectionWriter =
730721
Unit.getVersion() >= 5 ? *RangeListsSectionWriter.get()
731722
: *LegacyRangesSectionWriter.get();
723+
DebugLocWriter &DebugLocWriter =
724+
*LocListWritersByCU[LocListWritersIndexByCU[Unit.getOffset()]].get();
732725
std::optional<uint64_t> RangesBase;
733726
std::optional<DWARFUnit *> SplitCU;
734727
std::optional<uint64_t> DWOId = Unit.getDWOId();
@@ -765,15 +758,24 @@ void DWARFRewriter::updateDebugInfo() {
765758
CUPartitionVector PartVec = partitionCUs(*BC.DwCtx);
766759
for (std::vector<DWARFUnit *> &Vec : PartVec) {
767760
DIEBlder.buildCompileUnits(Vec);
768-
llvm::DenseMap<uint64_t, uint64_t> LocListWritersIndexByCU;
769761
for (DWARFUnit *CU : DIEBlder.getProcessedCUs()) {
770-
createRangeLocListAddressWriters(*CU, LocListWritersIndexByCU);
771-
processSplitCU(*CU, DIEBlder);
762+
createRangeLocListAddressWriters(*CU);
763+
std::optional<DWARFUnit *> SplitCU;
764+
std::optional<uint64_t> DWOId = CU->getDWOId();
765+
if (DWOId)
766+
SplitCU = BC.getDWOCU(*DWOId);
767+
if (!SplitCU)
768+
continue;
769+
DebugAddrWriter &AddressWriter =
770+
*AddressWritersByCU[CU->getOffset()].get();
771+
DebugRangesSectionWriter *TempRangesSectionWriter =
772+
CU->getVersion() >= 5 ? RangeListsWritersByCU[*DWOId].get()
773+
: LegacyRangesWritersByCU[*DWOId].get();
774+
processSplitCU(*CU, **SplitCU, DIEBlder, *TempRangesSectionWriter,
775+
AddressWriter);
772776
}
773777
for (DWARFUnit *CU : DIEBlder.getProcessedCUs()) {
774-
DebugLocWriter *DebugLocWriter =
775-
LocListWritersByCU[LocListWritersIndexByCU[CU->getOffset()]].get();
776-
processMainBinaryCU(*CU, DIEBlder, *DebugLocWriter);
778+
processMainBinaryCU(*CU, DIEBlder);
777779
}
778780
finalizeCompileUnits(DIEBlder, *Streamer, OffsetMap,
779781
DIEBlder.getProcessedCUs(), *FinalAddrWriter);

0 commit comments

Comments
 (0)