[llvm] [BOLT][DWARF][NFC] Split processUnitDIE into two lambdas (PR #99225)
Sayhaan Siddiqui via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 09:51:04 PDT 2024
https://github.com/sayhaan updated https://github.com/llvm/llvm-project/pull/99225
>From 446d927e97262aa709cd9e7cb311be739619d391 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Tue, 16 Jul 2024 11:25:48 -0700
Subject: [PATCH 1/7] Split processUnitDIE into two lambdas
Summary:
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: https://phabricator.intern.facebook.com/D59822423
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 216 ++++++++++++++++-------------
1 file changed, 119 insertions(+), 97 deletions(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 4ba6344925856..2b757eb71a05c 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -632,44 +632,47 @@ void DWARFRewriter::updateDebugInfo() {
std::mutex AccessMutex;
// Needs to be invoked in the same order as CUs are processed.
auto createRangeLocListAddressWriters =
- [&](DWARFUnit &CU) -> DebugLocWriter * {
- std::lock_guard<std::mutex> Lock(AccessMutex);
- const uint16_t DwarfVersion = CU.getVersion();
- if (DwarfVersion >= 5) {
- auto AddrW = std::make_unique<DebugAddrWriterDwarf5>(
- &BC, CU.getAddressByteSize(), CU.getAddrOffsetSectionBase());
- RangeListsSectionWriter->setAddressWriter(AddrW.get());
- LocListWritersByCU[CUIndex] =
- std::make_unique<DebugLoclistWriter>(CU, DwarfVersion, false, *AddrW);
-
- if (std::optional<uint64_t> DWOId = CU.getDWOId()) {
- assert(RangeListsWritersByCU.count(*DWOId) == 0 &&
- "RangeLists writer for DWO unit already exists.");
- auto DWORangeListsSectionWriter =
- std::make_unique<DebugRangeListsSectionWriter>();
- DWORangeListsSectionWriter->initSection(CU);
- DWORangeListsSectionWriter->setAddressWriter(AddrW.get());
- RangeListsWritersByCU[*DWOId] = std::move(DWORangeListsSectionWriter);
- }
- AddressWritersByCU[CU.getOffset()] = std::move(AddrW);
+ [&](DWARFUnit &CU,
+ llvm::DenseMap<uint64_t, uint64_t> &LocListWritersIndexByCU) {
+ std::lock_guard<std::mutex> Lock(AccessMutex);
- } else {
- auto AddrW =
- std::make_unique<DebugAddrWriter>(&BC, CU.getAddressByteSize());
- AddressWritersByCU[CU.getOffset()] = std::move(AddrW);
- LocListWritersByCU[CUIndex] = std::make_unique<DebugLocWriter>();
- if (std::optional<uint64_t> DWOId = CU.getDWOId()) {
- assert(LegacyRangesWritersByCU.count(*DWOId) == 0 &&
- "LegacyRangeLists writer for DWO unit already exists.");
- auto LegacyRangesSectionWriterByCU =
- std::make_unique<DebugRangesSectionWriter>();
- LegacyRangesSectionWriterByCU->initSection(CU);
- LegacyRangesWritersByCU[*DWOId] =
- std::move(LegacyRangesSectionWriterByCU);
- }
- }
- return LocListWritersByCU[CUIndex++].get();
- };
+ const uint16_t DwarfVersion = CU.getVersion();
+ if (DwarfVersion >= 5) {
+ auto AddrW = std::make_unique<DebugAddrWriterDwarf5>(
+ &BC, CU.getAddressByteSize(), CU.getAddrOffsetSectionBase());
+ RangeListsSectionWriter->setAddressWriter(AddrW.get());
+ LocListWritersByCU[CUIndex] = std::make_unique<DebugLoclistWriter>(
+ CU, DwarfVersion, false, *AddrW);
+
+ if (std::optional<uint64_t> DWOId = CU.getDWOId()) {
+ assert(RangeListsWritersByCU.count(*DWOId) == 0 &&
+ "RangeLists writer for DWO unit already exists.");
+ auto DWORangeListsSectionWriter =
+ std::make_unique<DebugRangeListsSectionWriter>();
+ DWORangeListsSectionWriter->initSection(CU);
+ DWORangeListsSectionWriter->setAddressWriter(AddrW.get());
+ RangeListsWritersByCU[*DWOId] =
+ std::move(DWORangeListsSectionWriter);
+ }
+ AddressWritersByCU[CU.getOffset()] = std::move(AddrW);
+
+ } else {
+ auto AddrW =
+ std::make_unique<DebugAddrWriter>(&BC, CU.getAddressByteSize());
+ AddressWritersByCU[CU.getOffset()] = std::move(AddrW);
+ LocListWritersByCU[CUIndex] = std::make_unique<DebugLocWriter>();
+ if (std::optional<uint64_t> DWOId = CU.getDWOId()) {
+ assert(LegacyRangesWritersByCU.count(*DWOId) == 0 &&
+ "LegacyRangeLists writer for DWO unit already exists.");
+ auto LegacyRangesSectionWriterByCU =
+ std::make_unique<DebugRangesSectionWriter>();
+ LegacyRangesSectionWriterByCU->initSection(CU);
+ LegacyRangesWritersByCU[*DWOId] =
+ std::move(LegacyRangesSectionWriterByCU);
+ }
+ }
+ LocListWritersIndexByCU[CU.getOffset()] = CUIndex++;
+ };
DWARF5AcceleratorTable DebugNamesTable(opts::CreateDebugNames, BC,
*StrWriter);
@@ -677,74 +680,75 @@ void DWARFRewriter::updateDebugInfo() {
DWPState State;
if (opts::WriteDWP)
initDWPState(State);
- auto processUnitDIE = [&](DWARFUnit *Unit, DIEBuilder *DIEBlder) {
- // Check if the unit is a skeleton and we need special updates for it and
- // its matching split/DWO CU.
+ auto processSplitCU = [&](DWARFUnit *Unit, DIEBuilder *DIEBlder,
+ std::optional<uint64_t> &RangesBase) {
std::optional<DWARFUnit *> SplitCU;
- std::optional<uint64_t> RangesBase;
std::optional<uint64_t> DWOId = Unit->getDWOId();
if (DWOId)
SplitCU = BC.getDWOCU(*DWOId);
- DebugLocWriter *DebugLocWriter = createRangeLocListAddressWriters(*Unit);
- DebugRangesSectionWriter *RangesSectionWriter =
- Unit->getVersion() >= 5 ? RangeListsSectionWriter.get()
- : LegacyRangesSectionWriter.get();
- DebugAddrWriter *AddressWriter =
- AddressWritersByCU[Unit->getOffset()].get();
- // Skipping CUs that failed to load.
- if (SplitCU) {
- DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), DebugNamesTable,
- Unit);
- DWODIEBuilder.buildDWOUnit(**SplitCU);
- std::string DWOName = "";
- std::optional<std::string> DwarfOutputPath =
- opts::DwarfOutputPath.empty()
- ? std::nullopt
- : std::optional<std::string>(opts::DwarfOutputPath.c_str());
- {
- std::lock_guard<std::mutex> Lock(AccessMutex);
- DWOName = DIEBlder->updateDWONameCompDir(
- *StrOffstsWriter, *StrWriter, *Unit, DwarfOutputPath, std::nullopt);
- }
- DebugStrOffsetsWriter DWOStrOffstsWriter(BC);
- DebugStrWriter DWOStrWriter((*SplitCU)->getContext(), true);
- DWODIEBuilder.updateDWONameCompDirForTypes(DWOStrOffstsWriter,
- DWOStrWriter, **SplitCU,
- DwarfOutputPath, DWOName);
- DebugLoclistWriter DebugLocDWoWriter(*Unit, Unit->getVersion(), true,
- *AddressWriter);
- DebugRangesSectionWriter *TempRangesSectionWriter = RangesSectionWriter;
- if (Unit->getVersion() >= 5) {
- TempRangesSectionWriter = RangeListsWritersByCU[*DWOId].get();
- } else {
- TempRangesSectionWriter = LegacyRangesWritersByCU[*DWOId].get();
- RangesBase = RangesSectionWriter->getSectionOffset();
- }
-
- updateUnitDebugInfo(*(*SplitCU), DWODIEBuilder, DebugLocDWoWriter,
- *TempRangesSectionWriter, *AddressWriter);
- DebugLocDWoWriter.finalize(DWODIEBuilder,
- *DWODIEBuilder.getUnitDIEbyUnit(**SplitCU));
- if (Unit->getVersion() >= 5)
- TempRangesSectionWriter->finalizeSection();
-
- emitDWOBuilder(DWOName, DWODIEBuilder, *this, **SplitCU, *Unit, State,
- DebugLocDWoWriter, DWOStrOffstsWriter, DWOStrWriter,
- GDBIndexSection);
+ if (!SplitCU)
+ return;
+ DebugAddrWriter &AddressWriter =
+ *AddressWritersByCU[Unit->getOffset()].get();
+ DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), DebugNamesTable,
+ Unit);
+ DWODIEBuilder.buildDWOUnit(**SplitCU);
+ std::string DWOName = "";
+ std::optional<std::string> DwarfOutputPath =
+ opts::DwarfOutputPath.empty()
+ ? std::nullopt
+ : std::optional<std::string>(opts::DwarfOutputPath.c_str());
+ {
+ DWOName = DIEBlder->updateDWONameCompDir(
+ *StrOffstsWriter, *StrWriter, *Unit, DwarfOutputPath, std::nullopt);
}
+ DebugStrOffsetsWriter DWOStrOffstsWriter(BC);
+ DebugStrWriter DWOStrWriter((*SplitCU)->getContext(), true);
+ DWODIEBuilder.updateDWONameCompDirForTypes(
+ DWOStrOffstsWriter, DWOStrWriter, **SplitCU, DwarfOutputPath, DWOName);
+ DebugLoclistWriter DebugLocDWoWriter(*Unit, Unit->getVersion(), true,
+ AddressWriter);
+ DebugRangesSectionWriter *TempRangesSectionWriter;
+ if (Unit->getVersion() >= 5) {
+ TempRangesSectionWriter = RangeListsWritersByCU[*DWOId].get();
+ } else {
+ TempRangesSectionWriter = LegacyRangesWritersByCU[*DWOId].get();
+ RangesBase = Unit->getVersion() >= 5
+ ? RangeListsSectionWriter.get()->getSectionOffset()
+ : LegacyRangesSectionWriter.get()->getSectionOffset();
+ }
+
+ updateUnitDebugInfo(*(*SplitCU), DWODIEBuilder, DebugLocDWoWriter,
+ *TempRangesSectionWriter, AddressWriter);
+ DebugLocDWoWriter.finalize(DWODIEBuilder,
+ *DWODIEBuilder.getUnitDIEbyUnit(**SplitCU));
+ if (Unit->getVersion() >= 5)
+ TempRangesSectionWriter->finalizeSection();
+ emitDWOBuilder(DWOName, DWODIEBuilder, *this, **SplitCU, *Unit, State,
+ DebugLocDWoWriter, DWOStrOffstsWriter, DWOStrWriter,
+ GDBIndexSection);
+ };
+ auto processMainBinaryCU = [&](DWARFUnit *Unit, DIEBuilder *DIEBlder,
+ DebugLocWriter *DebugLocWriter,
+ std::optional<uint64_t> &RangesBase) {
+ DebugAddrWriter &AddressWriter =
+ *AddressWritersByCU[Unit->getOffset()].get();
+ DebugRangesSectionWriter &RangesSectionWriter =
+ Unit->getVersion() >= 5 ? *RangeListsSectionWriter.get()
+ : *LegacyRangesSectionWriter.get();
if (Unit->getVersion() >= 5) {
- RangesBase = RangesSectionWriter->getSectionOffset() +
+ RangesBase = RangesSectionWriter.getSectionOffset() +
getDWARF5RngListLocListHeaderSize();
- RangesSectionWriter->initSection(*Unit);
+ RangesSectionWriter.initSection(*Unit);
StrOffstsWriter->finalizeSection(*Unit, *DIEBlder);
}
- updateUnitDebugInfo(*Unit, *DIEBlder, *DebugLocWriter, *RangesSectionWriter,
- *AddressWriter, RangesBase);
+ updateUnitDebugInfo(*Unit, *DIEBlder, *DebugLocWriter, RangesSectionWriter,
+ AddressWriter, RangesBase);
DebugLocWriter->finalize(*DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));
if (Unit->getVersion() >= 5)
- RangesSectionWriter->finalizeSection();
+ RangesSectionWriter.finalizeSection();
};
DIEBuilder DIEBlder(BC, BC.DwCtx.get(), DebugNamesTable);
@@ -767,17 +771,35 @@ void DWARFRewriter::updateDebugInfo() {
CUPartitionVector PartVec = partitionCUs(*BC.DwCtx);
for (std::vector<DWARFUnit *> &Vec : PartVec) {
DIEBlder.buildCompileUnits(Vec);
- for (DWARFUnit *CU : DIEBlder.getProcessedCUs())
- processUnitDIE(CU, &DIEBlder);
+ llvm::SmallVector<DWARFUnit *> CompileUnits(
+ std::begin(DIEBlder.getProcessedCUs()),
+ std::end(DIEBlder.getProcessedCUs()));
+ llvm::DenseMap<uint64_t, uint64_t> RangesBaseByCU;
+ llvm::DenseMap<uint64_t, uint64_t> LocListWritersIndexByCU;
+ for (DWARFUnit *CU : CompileUnits) {
+ createRangeLocListAddressWriters(*CU, LocListWritersIndexByCU);
+ std::optional<uint64_t> RangesBase;
+ processSplitCU(CU, &DIEBlder, RangesBase);
+ if (RangesBase)
+ RangesBaseByCU[CU->getOffset()] = *RangesBase;
+ }
+ for (DWARFUnit *CU : CompileUnits) {
+ std::optional<uint64_t> RangesBase;
+ if (RangesBaseByCU.count(CU->getOffset()))
+ RangesBase = RangesBaseByCU[CU->getOffset()];
+ DebugLocWriter *DebugLocWriter =
+ LocListWritersByCU[LocListWritersIndexByCU[CU->getOffset()]].get();
+ processMainBinaryCU(CU, &DIEBlder, DebugLocWriter, RangesBase);
+ }
finalizeCompileUnits(DIEBlder, *Streamer, OffsetMap,
- DIEBlder.getProcessedCUs(), *FinalAddrWriter);
+ DIEBlder.getProcessedCUs(), *FinalAddrWriter);
}
} else {
// Update unit debug info in parallel
ThreadPoolInterface &ThreadPool = ParallelUtilities::getThreadPool();
for (std::unique_ptr<DWARFUnit> &CU : BC.DwCtx->compile_units())
- ThreadPool.async(processUnitDIE, CU.get(), &DIEBlder);
- ThreadPool.wait();
+ // ThreadPool.async(processUnitDIE, CU.get(), &DIEBlder);
+ ThreadPool.wait();
}
DebugNamesTable.emitAccelTable();
>From 507c4577a3ba87e6bac6cc9cde2ff4821c45a7dc Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Tue, 16 Jul 2024 13:22:29 -0700
Subject: [PATCH 2/7] Formatting change
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 2b757eb71a05c..39f838fddd5c2 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -792,7 +792,7 @@ void DWARFRewriter::updateDebugInfo() {
processMainBinaryCU(CU, &DIEBlder, DebugLocWriter, RangesBase);
}
finalizeCompileUnits(DIEBlder, *Streamer, OffsetMap,
- DIEBlder.getProcessedCUs(), *FinalAddrWriter);
+ DIEBlder.getProcessedCUs(), *FinalAddrWriter);
}
} else {
// Update unit debug info in parallel
>From 63c3b4a9f19a19aae500c08695e93bebce37e223 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Tue, 16 Jul 2024 13:23:21 -0700
Subject: [PATCH 3/7] Formatting change
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 39f838fddd5c2..ebf085645d675 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -699,6 +699,7 @@ void DWARFRewriter::updateDebugInfo() {
? std::nullopt
: std::optional<std::string>(opts::DwarfOutputPath.c_str());
{
+ std::lock_guard<std::mutex> Lock(AccessMutex);
DWOName = DIEBlder->updateDWONameCompDir(
*StrOffstsWriter, *StrWriter, *Unit, DwarfOutputPath, std::nullopt);
}
>From 8e79abfefbad6bd5e7da852700fc41399bb642be Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Tue, 16 Jul 2024 13:26:47 -0700
Subject: [PATCH 4/7] Formatting change
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index ebf085645d675..d03a299fceaf0 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -793,7 +793,7 @@ void DWARFRewriter::updateDebugInfo() {
processMainBinaryCU(CU, &DIEBlder, DebugLocWriter, RangesBase);
}
finalizeCompileUnits(DIEBlder, *Streamer, OffsetMap,
- DIEBlder.getProcessedCUs(), *FinalAddrWriter);
+ DIEBlder.getProcessedCUs(), *FinalAddrWriter);
}
} else {
// Update unit debug info in parallel
>From 26cf724ae59088d991215bba9d5015b5e1cf7399 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Tue, 16 Jul 2024 13:31:29 -0700
Subject: [PATCH 5/7] Formatting change
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index d03a299fceaf0..ebf085645d675 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -793,7 +793,7 @@ void DWARFRewriter::updateDebugInfo() {
processMainBinaryCU(CU, &DIEBlder, DebugLocWriter, RangesBase);
}
finalizeCompileUnits(DIEBlder, *Streamer, OffsetMap,
- DIEBlder.getProcessedCUs(), *FinalAddrWriter);
+ DIEBlder.getProcessedCUs(), *FinalAddrWriter);
}
} else {
// Update unit debug info in parallel
>From 35506d10c1015b3548a4d97df9382bf0ebd1fcda Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Thu, 18 Jul 2024 09:48:42 -0700
Subject: [PATCH 6/7] Updates to change RangesBase initialization
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 36 +++++++++++++-----------------
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index ebf085645d675..db5d81dc096fd 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -680,8 +680,7 @@ void DWARFRewriter::updateDebugInfo() {
DWPState State;
if (opts::WriteDWP)
initDWPState(State);
- auto processSplitCU = [&](DWARFUnit *Unit, DIEBuilder *DIEBlder,
- std::optional<uint64_t> &RangesBase) {
+ auto processSplitCU = [&](DWARFUnit *Unit, DIEBuilder *DIEBlder) {
std::optional<DWARFUnit *> SplitCU;
std::optional<uint64_t> DWOId = Unit->getDWOId();
if (DWOId)
@@ -710,15 +709,11 @@ void DWARFRewriter::updateDebugInfo() {
DebugLoclistWriter DebugLocDWoWriter(*Unit, Unit->getVersion(), true,
AddressWriter);
DebugRangesSectionWriter *TempRangesSectionWriter;
- if (Unit->getVersion() >= 5) {
+ if (Unit->getVersion() >= 5)
TempRangesSectionWriter = RangeListsWritersByCU[*DWOId].get();
- } else {
+ else
TempRangesSectionWriter = LegacyRangesWritersByCU[*DWOId].get();
- RangesBase = Unit->getVersion() >= 5
- ? RangeListsSectionWriter.get()->getSectionOffset()
- : LegacyRangesSectionWriter.get()->getSectionOffset();
- }
-
+
updateUnitDebugInfo(*(*SplitCU), DWODIEBuilder, DebugLocDWoWriter,
*TempRangesSectionWriter, AddressWriter);
DebugLocDWoWriter.finalize(DWODIEBuilder,
@@ -731,20 +726,26 @@ void DWARFRewriter::updateDebugInfo() {
GDBIndexSection);
};
auto processMainBinaryCU = [&](DWARFUnit *Unit, DIEBuilder *DIEBlder,
- DebugLocWriter *DebugLocWriter,
- std::optional<uint64_t> &RangesBase) {
+ DebugLocWriter *DebugLocWriter) {
DebugAddrWriter &AddressWriter =
*AddressWritersByCU[Unit->getOffset()].get();
DebugRangesSectionWriter &RangesSectionWriter =
Unit->getVersion() >= 5 ? *RangeListsSectionWriter.get()
: *LegacyRangesSectionWriter.get();
+ std::optional<uint64_t> RangesBase;
+ std::optional<DWARFUnit *> SplitCU;
+ std::optional<uint64_t> DWOId = Unit->getDWOId();
+ if (DWOId)
+ SplitCU = BC.getDWOCU(*DWOId);
if (Unit->getVersion() >= 5) {
RangesBase = RangesSectionWriter.getSectionOffset() +
getDWARF5RngListLocListHeaderSize();
RangesSectionWriter.initSection(*Unit);
StrOffstsWriter->finalizeSection(*Unit, *DIEBlder);
+ } else if(SplitCU) {
+ RangesBase = LegacyRangesSectionWriter.get()->getSectionOffset();
}
-
+
updateUnitDebugInfo(*Unit, *DIEBlder, *DebugLocWriter, RangesSectionWriter,
AddressWriter, RangesBase);
DebugLocWriter->finalize(*DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));
@@ -775,22 +776,15 @@ void DWARFRewriter::updateDebugInfo() {
llvm::SmallVector<DWARFUnit *> CompileUnits(
std::begin(DIEBlder.getProcessedCUs()),
std::end(DIEBlder.getProcessedCUs()));
- llvm::DenseMap<uint64_t, uint64_t> RangesBaseByCU;
llvm::DenseMap<uint64_t, uint64_t> LocListWritersIndexByCU;
for (DWARFUnit *CU : CompileUnits) {
createRangeLocListAddressWriters(*CU, LocListWritersIndexByCU);
- std::optional<uint64_t> RangesBase;
- processSplitCU(CU, &DIEBlder, RangesBase);
- if (RangesBase)
- RangesBaseByCU[CU->getOffset()] = *RangesBase;
+ processSplitCU(CU, &DIEBlder);
}
for (DWARFUnit *CU : CompileUnits) {
- std::optional<uint64_t> RangesBase;
- if (RangesBaseByCU.count(CU->getOffset()))
- RangesBase = RangesBaseByCU[CU->getOffset()];
DebugLocWriter *DebugLocWriter =
LocListWritersByCU[LocListWritersIndexByCU[CU->getOffset()]].get();
- processMainBinaryCU(CU, &DIEBlder, DebugLocWriter, RangesBase);
+ processMainBinaryCU(CU, &DIEBlder, DebugLocWriter);
}
finalizeCompileUnits(DIEBlder, *Streamer, OffsetMap,
DIEBlder.getProcessedCUs(), *FinalAddrWriter);
>From e1962ce1cbd07b7542e062800d68f7f66bb52ba6 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Thu, 18 Jul 2024 09:50:46 -0700
Subject: [PATCH 7/7] Formatting changes
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index db5d81dc096fd..fab17021ce40c 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -713,7 +713,7 @@ void DWARFRewriter::updateDebugInfo() {
TempRangesSectionWriter = RangeListsWritersByCU[*DWOId].get();
else
TempRangesSectionWriter = LegacyRangesWritersByCU[*DWOId].get();
-
+
updateUnitDebugInfo(*(*SplitCU), DWODIEBuilder, DebugLocDWoWriter,
*TempRangesSectionWriter, AddressWriter);
DebugLocDWoWriter.finalize(DWODIEBuilder,
@@ -742,10 +742,10 @@ void DWARFRewriter::updateDebugInfo() {
getDWARF5RngListLocListHeaderSize();
RangesSectionWriter.initSection(*Unit);
StrOffstsWriter->finalizeSection(*Unit, *DIEBlder);
- } else if(SplitCU) {
+ } else if (SplitCU) {
RangesBase = LegacyRangesSectionWriter.get()->getSectionOffset();
}
-
+
updateUnitDebugInfo(*Unit, *DIEBlder, *DebugLocWriter, RangesSectionWriter,
AddressWriter, RangesBase);
DebugLocWriter->finalize(*DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));
More information about the llvm-commits
mailing list