Skip to content

Commit 640e781

Browse files
authored
[BOLT][DWARF][NFC] Use SkeletonCU in place of IsDWO check (#82540)
Changed isDWO to a function that checks Skeleton CU that is passed in. This is for preparation for #81062.
1 parent 9ea9e93 commit 640e781

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DIEBuilder {
124124
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
125125
BinaryContext &BC;
126126
DWARFContext *DwarfContext{nullptr};
127-
bool IsDWO{false};
127+
DWARFUnit *SkeletonCU{nullptr};
128128
uint64_t UnitSize{0};
129129
llvm::DenseSet<uint64_t> AllProcessed;
130130

@@ -264,8 +264,12 @@ class DIEBuilder {
264264
/// current Section.
265265
DIE *constructDIEFast(DWARFDie &DDie, DWARFUnit &U, uint32_t UnitId);
266266

267+
/// Returns true if this DIEBUilder is for DWO Unit.
268+
bool isDWO() const { return SkeletonCU != nullptr; }
269+
267270
public:
268-
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);
271+
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
272+
DWARFUnit *SkeletonCU = nullptr);
269273

270274
/// Returns enum to what we are currently processing.
271275
ProcessingType getCurrentProcessingState() { return getState().Type; }

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ void DIEBuilder::constructFromUnit(DWARFUnit &DU) {
179179
}
180180

181181
DIEBuilder::DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
182-
bool IsDWO)
183-
: BC(BC), DwarfContext(DwarfContext), IsDWO(IsDWO) {}
182+
DWARFUnit *SkeletonCU)
183+
: BC(BC), DwarfContext(DwarfContext), SkeletonCU(SkeletonCU) {}
184184

185185
static unsigned int getCUNum(DWARFContext *DwarfContext, bool IsDWO) {
186186
unsigned int CUNum = IsDWO ? DwarfContext->getNumDWOCompileUnits()
@@ -204,11 +204,11 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
204204
true);
205205
}
206206
}
207-
const unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
207+
const unsigned int CUNum = getCUNum(DwarfContext, isDWO());
208208
getState().CloneUnitCtxMap.resize(CUNum);
209209
DWARFContext::unit_iterator_range CU4TURanges =
210-
IsDWO ? DwarfContext->dwo_types_section_units()
211-
: DwarfContext->types_section_units();
210+
isDWO() ? DwarfContext->dwo_types_section_units()
211+
: DwarfContext->types_section_units();
212212

213213
getState().Type = ProcessingType::DWARF4TUs;
214214
for (std::unique_ptr<DWARFUnit> &DU : CU4TURanges)
@@ -218,8 +218,8 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
218218
constructFromUnit(*DU.get());
219219

220220
DWARFContext::unit_iterator_range CURanges =
221-
IsDWO ? DwarfContext->dwo_info_section_units()
222-
: DwarfContext->info_section_units();
221+
isDWO() ? DwarfContext->dwo_info_section_units()
222+
: DwarfContext->info_section_units();
223223

224224
// This handles DWARF4 CUs and DWARF5 CU/TUs.
225225
// Creating a vector so that for reference handling only DWARF5 CU/TUs are
@@ -242,11 +242,11 @@ void DIEBuilder::buildCompileUnits(const bool Init) {
242242
if (Init)
243243
BuilderState.reset(new State());
244244

245-
unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
245+
unsigned int CUNum = getCUNum(DwarfContext, isDWO());
246246
getState().CloneUnitCtxMap.resize(CUNum);
247247
DWARFContext::unit_iterator_range CURanges =
248-
IsDWO ? DwarfContext->dwo_info_section_units()
249-
: DwarfContext->info_section_units();
248+
isDWO() ? DwarfContext->dwo_info_section_units()
249+
: DwarfContext->info_section_units();
250250

251251
// This handles DWARF4 CUs and DWARF5 CU/TUs.
252252
// Creating a vector so that for reference handling only DWARF5 CU/TUs are

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void DWARFRewriter::updateDebugInfo() {
709709
: LegacyRangesSectionWriter.get();
710710
// Skipping CUs that failed to load.
711711
if (SplitCU) {
712-
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), true);
712+
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), Unit);
713713
DWODIEBuilder.buildDWOUnit(**SplitCU);
714714
std::string DWOName = updateDWONameCompDir(
715715
*Unit, *DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));

0 commit comments

Comments
 (0)