From 9dab91247d5c40607617f13b8fe5056111dd3045 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 16 Jul 2024 13:27:41 +0200 Subject: [PATCH] Fix bolt for #98905 --- bolt/lib/Core/DIEBuilder.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bolt/lib/Core/DIEBuilder.cpp b/bolt/lib/Core/DIEBuilder.cpp index 6633eaa9574216..7815a305c05182 100644 --- a/bolt/lib/Core/DIEBuilder.cpp +++ b/bolt/lib/Core/DIEBuilder.cpp @@ -556,7 +556,17 @@ DWARFDie DIEBuilder::resolveDIEReference( const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec, DWARFUnit *&RefCU, DWARFDebugInfoEntry &DwarfDebugInfoEntry) { assert(RefValue.isFormClass(DWARFFormValue::FC_Reference)); - uint64_t RefOffset = *RefValue.getAsReference(); + uint64_t RefOffset; + if (std::optional Off = RefValue.getAsRelativeReference()) { + RefOffset = RefValue.getUnit()->getOffset() + *Off; + } else if (Off = RefValue.getAsDebugInfoReference(); Off) { + RefOffset = *Off; + } else { + BC.errs() + << "BOLT-WARNING: [internal-dwarf-error]: unsupported reference type: " + << FormEncodingString(RefValue.getForm()) << ".\n"; + return DWARFDie(); + } return resolveDIEReference(AttrSpec, RefOffset, RefCU, DwarfDebugInfoEntry); } @@ -607,7 +617,13 @@ void DIEBuilder::cloneDieReferenceAttribute( DIE &Die, const DWARFUnit &U, const DWARFDie &InputDIE, const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec, const DWARFFormValue &Val) { - const uint64_t Ref = *Val.getAsReference(); + uint64_t Ref; + if (std::optional Off = Val.getAsRelativeReference()) + Ref = Val.getUnit()->getOffset() + *Off; + else if (Off = Val.getAsDebugInfoReference(); Off) + Ref = *Off; + else + return; DIE *NewRefDie = nullptr; DWARFUnit *RefUnit = nullptr;