Skip to content

Commit 18c950e

Browse files
labathyuxuanchen1997
authored andcommitted
Fix bolt for #98905
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251577
1 parent 071acd9 commit 18c950e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,17 @@ DWARFDie DIEBuilder::resolveDIEReference(
556556
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
557557
DWARFUnit *&RefCU, DWARFDebugInfoEntry &DwarfDebugInfoEntry) {
558558
assert(RefValue.isFormClass(DWARFFormValue::FC_Reference));
559-
uint64_t RefOffset = *RefValue.getAsReference();
559+
uint64_t RefOffset;
560+
if (std::optional<uint64_t> Off = RefValue.getAsRelativeReference()) {
561+
RefOffset = RefValue.getUnit()->getOffset() + *Off;
562+
} else if (Off = RefValue.getAsDebugInfoReference(); Off) {
563+
RefOffset = *Off;
564+
} else {
565+
BC.errs()
566+
<< "BOLT-WARNING: [internal-dwarf-error]: unsupported reference type: "
567+
<< FormEncodingString(RefValue.getForm()) << ".\n";
568+
return DWARFDie();
569+
}
560570
return resolveDIEReference(AttrSpec, RefOffset, RefCU, DwarfDebugInfoEntry);
561571
}
562572

@@ -607,7 +617,13 @@ void DIEBuilder::cloneDieReferenceAttribute(
607617
DIE &Die, const DWARFUnit &U, const DWARFDie &InputDIE,
608618
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
609619
const DWARFFormValue &Val) {
610-
const uint64_t Ref = *Val.getAsReference();
620+
uint64_t Ref;
621+
if (std::optional<uint64_t> Off = Val.getAsRelativeReference())
622+
Ref = Val.getUnit()->getOffset() + *Off;
623+
else if (Off = Val.getAsDebugInfoReference(); Off)
624+
Ref = *Off;
625+
else
626+
return;
611627

612628
DIE *NewRefDie = nullptr;
613629
DWARFUnit *RefUnit = nullptr;

0 commit comments

Comments
 (0)