-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split DWARFFormValue::getReference into four functions #98905
Conversation
The result of the function cannot be correctly interpreted without knowing the precise form type (a type signature needs to be looked up very differently from a supplementary debug info reference). The function sort of worked because the two reference types (unit-relative and section-relative) that can be handled uniformly are also the most common types of references, but this setup made it easy to write code which does not support other kinds of reference (and if one tried to support them, the result didn't look pretty -- https://github.com/llvm/llvm-project/pull/97423/files#r1676217081). The split is based on the reference type classification from DWARFv5 (Section 7.5.5 Classes and Forms), and it should enable uniform (if slightly more verbose) hadling. Note that this only affects users which want more control of how (or if) the references are resolved. Users which just want to access the referenced DIE can use the higher level API (DWARFDie::GetAttributeValueAsReferencedDie) which returns (or will return after llvm#97423 is merged) the correct die for all reference types (except for supplementary references, which we don't support right now).
@llvm/pr-subscribers-debuginfo Author: Pavel Labath (labath) ChangesThe result of the function cannot be correctly interpreted without knowing the precise form type (a type signature needs to be looked up very differently from a supplementary debug info reference). The function sort of worked because the two reference types (unit-relative and section-relative) that can be handled uniformly are also the most common types of references, but this setup made it easy to write code which does not support other kinds of reference (and if one tried to support them, the result didn't look pretty -- The split is based on the reference type classification from DWARFv5 (Section 7.5.5 Classes and Forms), and it should enable uniform (if slightly more verbose) hadling. Note that this only affects users which want more control of how (or if) the references are resolved. Users which just want to access the referenced DIE can use the higher level API (DWARFDie::GetAttributeValueAsReferencedDie) which returns (or will return after #97423 is merged) the correct die for all reference types (except for supplementary references, which we don't support right now). Patch is 36.91 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/98905.diff 8 Files Affected:
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
index dbb658940eef1..fb5712b855eed 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
@@ -107,12 +107,10 @@ class DWARFFormValue {
/// getAsFoo functions below return the extracted value as Foo if only
/// DWARFFormValue has form class is suitable for representing Foo.
- std::optional<uint64_t> getAsReference() const;
- struct UnitOffset {
- DWARFUnit *Unit;
- uint64_t Offset;
- };
- std::optional<UnitOffset> getAsRelativeReference() const;
+ std::optional<uint64_t> getAsRelativeReference() const;
+ std::optional<uint64_t> getAsDebugInfoReference() const;
+ std::optional<uint64_t> getAsSignatureReference() const;
+ std::optional<uint64_t> getAsSupplementaryReference() const;
std::optional<uint64_t> getAsUnsignedConstant() const;
std::optional<int64_t> getAsSignedConstant() const;
Expected<const char *> getAsCString() const;
@@ -242,27 +240,102 @@ inline uint64_t toUnsigned(const std::optional<DWARFFormValue> &V,
return toUnsigned(V).value_or(Default);
}
-/// Take an optional DWARFFormValue and try to extract an reference.
+/// Take an optional DWARFFormValue and try to extract a relative offset
+/// reference.
///
-/// \param V and optional DWARFFormValue to attempt to extract the value from.
+/// \param V an optional DWARFFormValue to attempt to extract the value from.
/// \returns an optional value that contains a value if the form value
-/// was valid and has a reference form.
+/// was valid and has a relative reference form.
inline std::optional<uint64_t>
-toReference(const std::optional<DWARFFormValue> &V) {
+toRelativeReference(const std::optional<DWARFFormValue> &V) {
if (V)
- return V->getAsReference();
+ return V->getAsRelativeReference();
return std::nullopt;
}
-/// Take an optional DWARFFormValue and extract a reference.
+/// Take an optional DWARFFormValue and extract a relative offset reference.
///
-/// \param V and optional DWARFFormValue to attempt to extract the value from.
+/// \param V an optional DWARFFormValue to attempt to extract the value from.
+/// \param Default the default value to return in case of failure.
+/// \returns the extracted reference value or Default if the V doesn't have a
+/// value or the form value's encoding wasn't a relative offset reference form.
+inline uint64_t toRelativeReference(const std::optional<DWARFFormValue> &V,
+ uint64_t Default) {
+ return toRelativeReference(V).value_or(Default);
+}
+
+/// Take an optional DWARFFormValue and try to extract an absolute debug info
+/// offset reference.
+///
+/// \param V an optional DWARFFormValue to attempt to extract the value from.
+/// \returns an optional value that contains a value if the form value
+/// was valid and has an (absolute) debug info offset reference form.
+inline std::optional<uint64_t>
+toDebugInfoReference(const std::optional<DWARFFormValue> &V) {
+ if (V)
+ return V->getAsDebugInfoReference();
+ return std::nullopt;
+}
+
+/// Take an optional DWARFFormValue and extract an absolute debug info offset
+/// reference.
+///
+/// \param V an optional DWARFFormValue to attempt to extract the value from.
+/// \param Default the default value to return in case of failure.
+/// \returns the extracted reference value or Default if the V doesn't have a
+/// value or the form value's encoding wasn't an absolute debug info offset
+/// reference form.
+inline uint64_t toDebugInfoReference(const std::optional<DWARFFormValue> &V,
+ uint64_t Default) {
+ return toDebugInfoReference(V).value_or(Default);
+}
+
+/// Take an optional DWARFFormValue and try to extract a signature reference.
+///
+/// \param V an optional DWARFFormValue to attempt to extract the value from.
+/// \returns an optional value that contains a value if the form value
+/// was valid and has a signature reference form.
+inline std::optional<uint64_t>
+toSignatureReference(const std::optional<DWARFFormValue> &V) {
+ if (V)
+ return V->getAsSignatureReference();
+ return std::nullopt;
+}
+
+/// Take an optional DWARFFormValue and extract a signature reference.
+///
+/// \param V an optional DWARFFormValue to attempt to extract the value from.
+/// \param Default the default value to return in case of failure.
+/// \returns the extracted reference value or Default if the V doesn't have a
+/// value or the form value's encoding wasn't a signature reference form.
+inline uint64_t toSignatureReference(const std::optional<DWARFFormValue> &V,
+ uint64_t Default) {
+ return toSignatureReference(V).value_or(Default);
+}
+
+/// Take an optional DWARFFormValue and try to extract a supplementary debug
+/// info reference.
+///
+/// \param V an optional DWARFFormValue to attempt to extract the value from.
+/// \returns an optional value that contains a value if the form value
+/// was valid and has a supplementary reference form.
+inline std::optional<uint64_t>
+toSupplementaryReference(const std::optional<DWARFFormValue> &V) {
+ if (V)
+ return V->getAsSupplementaryReference();
+ return std::nullopt;
+}
+
+/// Take an optional DWARFFormValue and extract a supplementary debug info
+/// reference.
+///
+/// \param V an optional DWARFFormValue to attempt to extract the value from.
/// \param Default the default value to return in case of failure.
/// \returns the extracted reference value or Default if the V doesn't have a
-/// value or the form value's encoding wasn't a reference form.
-inline uint64_t toReference(const std::optional<DWARFFormValue> &V,
+/// value or the form value's encoding wasn't a supplementary reference form.
+inline uint64_t toSupplementaryReference(const std::optional<DWARFFormValue> &V,
uint64_t Default) {
- return toReference(V).value_or(Default);
+ return toSupplementaryReference(V).value_or(Default);
}
/// Take an optional DWARFFormValue and try to extract an signed constant.
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index c6312c387744a..26bce1fd7b162 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -77,7 +77,15 @@ DWARFDie DWARFLinker::resolveDIEReference(const DWARFFile &File,
const DWARFDie &DIE,
CompileUnit *&RefCU) {
assert(RefValue.isFormClass(DWARFFormValue::FC_Reference));
- uint64_t RefOffset = *RefValue.getAsReference();
+ uint64_t RefOffset;
+ if (std::optional<uint64_t> Off = RefValue.getAsRelativeReference()) {
+ RefOffset = RefValue.getUnit()->getOffset() + *Off;
+ } else if (Off = RefValue.getAsDebugInfoReference(); Off) {
+ RefOffset = *Off;
+ } else {
+ reportWarning("Unsupported reference type", File, &DIE);
+ return DWARFDie();
+ }
if ((RefCU = getUnitForOffset(Units, RefOffset)))
if (const auto RefDie = RefCU->getOrigUnit().getDIEForOffset(RefOffset)) {
// In a file with broken references, an attribute might point to a NULL
@@ -1073,7 +1081,13 @@ unsigned DWARFLinker::DIECloner::cloneDieReferenceAttribute(
unsigned AttrSize, const DWARFFormValue &Val, const DWARFFile &File,
CompileUnit &Unit) {
const DWARFUnit &U = Unit.getOrigUnit();
- uint64_t Ref = *Val.getAsReference();
+ uint64_t Ref;
+ if (std::optional<uint64_t> Off = Val.getAsRelativeReference())
+ Ref = Val.getUnit()->getOffset() + *Off;
+ else if (Off = Val.getAsDebugInfoReference(); Off)
+ Ref = *Off;
+ else
+ return 0;
DIE *NewRefDie = nullptr;
CompileUnit *RefUnit = nullptr;
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
index 6f659eb8576b7..4daf781a2b53f 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
@@ -381,38 +381,36 @@ void CompileUnit::updateDieRefPatchesWithClonedOffsets() {
std::optional<UnitEntryPairTy> CompileUnit::resolveDIEReference(
const DWARFFormValue &RefValue,
ResolveInterCUReferencesMode CanResolveInterCUReferences) {
- if (std::optional<DWARFFormValue::UnitOffset> Ref =
- *RefValue.getAsRelativeReference()) {
- if (Ref->Unit == OrigUnit) {
- // Referenced DIE is in current compile unit.
- if (std::optional<uint32_t> RefDieIdx =
- getDIEIndexForOffset(OrigUnit->getOffset() + Ref->Offset))
- return UnitEntryPairTy{this, OrigUnit->getDebugInfoEntry(*RefDieIdx)};
- }
- uint64_t RefDIEOffset =
- Ref->Unit ? Ref->Unit->getOffset() + Ref->Offset : Ref->Offset;
- if (CompileUnit *RefCU = getUnitFromOffset(RefDIEOffset)) {
- if (RefCU == this) {
- // Referenced DIE is in current compile unit.
- if (std::optional<uint32_t> RefDieIdx =
- getDIEIndexForOffset(RefDIEOffset))
- return UnitEntryPairTy{this, getDebugInfoEntry(*RefDieIdx)};
- } else if (CanResolveInterCUReferences) {
- // Referenced DIE is in other compile unit.
-
- // Check whether DIEs are loaded for that compile unit.
- enum Stage ReferredCUStage = RefCU->getStage();
- if (ReferredCUStage < Stage::Loaded || ReferredCUStage > Stage::Cloned)
- return UnitEntryPairTy{RefCU, nullptr};
-
- if (std::optional<uint32_t> RefDieIdx =
- RefCU->getDIEIndexForOffset(RefDIEOffset))
- return UnitEntryPairTy{RefCU, RefCU->getDebugInfoEntry(*RefDieIdx)};
- } else
- return UnitEntryPairTy{RefCU, nullptr};
- }
+ CompileUnit *RefCU;
+ uint64_t RefDIEOffset;
+ if (std::optional<uint64_t> Offset = RefValue.getAsRelativeReference()) {
+ RefCU = this;
+ RefDIEOffset = RefValue.getUnit()->getOffset() + *Offset;
+ } else if (Offset = RefValue.getAsDebugInfoReference(); Offset) {
+ RefCU = getUnitFromOffset(*Offset);
+ RefDIEOffset = *Offset;
+ } else {
+ return std::nullopt;
}
+ if (RefCU == this) {
+ // Referenced DIE is in current compile unit.
+ if (std::optional<uint32_t> RefDieIdx = getDIEIndexForOffset(RefDIEOffset))
+ return UnitEntryPairTy{this, getDebugInfoEntry(*RefDieIdx)};
+ } else if (RefCU && CanResolveInterCUReferences) {
+ // Referenced DIE is in other compile unit.
+
+ // Check whether DIEs are loaded for that compile unit.
+ enum Stage ReferredCUStage = RefCU->getStage();
+ if (ReferredCUStage < Stage::Loaded || ReferredCUStage > Stage::Cloned)
+ return UnitEntryPairTy{RefCU, nullptr};
+
+ if (std::optional<uint32_t> RefDieIdx =
+ RefCU->getDIEIndexForOffset(RefDIEOffset))
+ return UnitEntryPairTy{RefCU, RefCU->getDebugInfoEntry(*RefDieIdx)};
+ } else {
+ return UnitEntryPairTy{RefCU, nullptr};
+ }
return std::nullopt;
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 410842a80b015..72e7464b68971 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -313,13 +313,12 @@ DWARFDie::getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const {
DWARFDie
DWARFDie::getAttributeValueAsReferencedDie(const DWARFFormValue &V) const {
DWARFDie Result;
- if (auto SpecRef = V.getAsRelativeReference()) {
- if (SpecRef->Unit)
- Result = SpecRef->Unit->getDIEForOffset(SpecRef->Unit->getOffset() +
- SpecRef->Offset);
- else if (auto SpecUnit =
- U->getUnitVector().getUnitForOffset(SpecRef->Offset))
- Result = SpecUnit->getDIEForOffset(SpecRef->Offset);
+ if (std::optional<uint64_t> Offset = V.getAsRelativeReference()) {
+ Result = const_cast<DWARFUnit *>(V.getUnit())
+ ->getDIEForOffset(V.getUnit()->getOffset() + *Offset);
+ } else if (Offset = V.getAsDebugInfoReference(); Offset) {
+ if (DWARFUnit *SpecUnit = U->getUnitVector().getUnitForOffset(*Offset))
+ Result = SpecUnit->getDIEForOffset(*Offset);
}
return Result;
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index b9cf7d22c80d4..e4d2d0c7e0423 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -665,16 +665,7 @@ DWARFFormValue::getAsSectionedAddress() const {
return getAsSectionedAddress(Value, Form, U);
}
-std::optional<uint64_t> DWARFFormValue::getAsReference() const {
- if (auto R = getAsRelativeReference())
- return R->Unit ? R->Unit->getOffset() + R->Offset : R->Offset;
- return std::nullopt;
-}
-
-std::optional<DWARFFormValue::UnitOffset>
-DWARFFormValue::getAsRelativeReference() const {
- if (!isFormClass(FC_Reference))
- return std::nullopt;
+std::optional<uint64_t> DWARFFormValue::getAsRelativeReference() const {
switch (Form) {
case DW_FORM_ref1:
case DW_FORM_ref2:
@@ -683,11 +674,31 @@ DWARFFormValue::getAsRelativeReference() const {
case DW_FORM_ref_udata:
if (!U)
return std::nullopt;
- return UnitOffset{const_cast<DWARFUnit*>(U), Value.uval};
- case DW_FORM_ref_addr:
- case DW_FORM_ref_sig8:
+ return Value.uval;
+ default:
+ return std::nullopt;
+ }
+}
+
+std::optional<uint64_t> DWARFFormValue::getAsDebugInfoReference() const {
+ if (Form == DW_FORM_ref_addr)
+ return Value.uval;
+ return std::nullopt;
+}
+
+
+std::optional<uint64_t> DWARFFormValue::getAsSignatureReference() const {
+ if (Form == DW_FORM_ref_sig8)
+ return Value.uval;
+ return std::nullopt;
+}
+
+std::optional<uint64_t> DWARFFormValue::getAsSupplementaryReference() const {
+ switch (Form) {
case DW_FORM_GNU_ref_alt:
- return UnitOffset{nullptr, Value.uval};
+ case DW_FORM_ref_sup4:
+ case DW_FORM_ref_sup8:
+ return Value.uval;
default:
return std::nullopt;
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 4ef6c80ed0289..a804deb446186 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -836,7 +836,7 @@ unsigned DWARFVerifier::verifyDebugInfoForm(const DWARFDie &Die,
case DW_FORM_ref8:
case DW_FORM_ref_udata: {
// Verify all CU relative references are valid CU offsets.
- std::optional<uint64_t> RefVal = AttrValue.Value.getAsReference();
+ std::optional<uint64_t> RefVal = AttrValue.Value.getAsRelativeReference();
assert(RefVal);
if (RefVal) {
auto CUSize = DieCU->getNextUnitOffset() - DieCU->getOffset();
@@ -854,7 +854,8 @@ unsigned DWARFVerifier::verifyDebugInfoForm(const DWARFDie &Die,
} else {
// Valid reference, but we will verify it points to an actual
// DIE later.
- LocalReferences[*RefVal].insert(Die.getOffset());
+ LocalReferences[AttrValue.Value.getUnit()->getOffset() + *RefVal]
+ .insert(Die.getOffset());
}
}
break;
@@ -862,7 +863,7 @@ unsigned DWARFVerifier::verifyDebugInfoForm(const DWARFDie &Die,
case DW_FORM_ref_addr: {
// Verify all absolute DIE references have valid offsets in the
// .debug_info section.
- std::optional<uint64_t> RefVal = AttrValue.Value.getAsReference();
+ std::optional<uint64_t> RefVal = AttrValue.Value.getAsDebugInfoReference();
assert(RefVal);
if (RefVal) {
if (*RefVal >= DieCU->getInfoSection().Data.size()) {
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
index 6a97bed9e3a83..68a14b8b0ad33 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
@@ -1082,10 +1082,17 @@ void LVDWARFReader::updateReference(dwarf::Attribute Attr,
// FIXME: We are assuming that at most one Reference (DW_AT_specification,
// DW_AT_abstract_origin, ...) and at most one Type (DW_AT_import, DW_AT_type)
// appear in any single DIE, but this may not be true.
- uint64_t Reference = *FormValue.getAsReference();
+ uint64_t Offset;
+ if (std::optional<uint64_t> Off = FormValue.getAsRelativeReference())
+ Offset = FormValue.getUnit()->getOffset() + *Off;
+ else if (Off = FormValue.getAsDebugInfoReference(); Off)
+ Offset = *Off;
+ else
+ llvm_unreachable("Unsupported reference type");
+
// Get target for the given reference, if already created.
LVElement *Target = getElementForOffset(
- Reference, CurrentElement,
+ Offset, CurrentElement,
/*IsType=*/Attr == dwarf::DW_AT_import || Attr == dwarf::DW_AT_type);
// Check if we are dealing with cross CU references.
if (FormValue.getForm() == dwarf::DW_FORM_ref_addr) {
@@ -1093,10 +1100,10 @@ void LVDWARFReader::updateReference(dwarf::Attribute Attr,
// The global reference is ready. Mark it as global.
Target->setIsGlobalReference();
// Remove global reference from the unseen list.
- removeGlobalOffset(Reference);
+ removeGlobalOffset(Offset);
} else
// Record the unseen cross CU reference.
- addGlobalOffset(Reference);
+ addGlobalOffset(Offset);
}
// At this point, 'Target' can be null, in the case of the target element
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 5cb0310c0ad09..32ab022380f02 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -384,15 +384,15 @@ void TestAllForms() {
//----------------------------------------------------------------------
// Test reference forms
//----------------------------------------------------------------------
- EXPECT_EQ(RefAddr, toReference(DieDG.find(Attr_DW_FORM_ref_addr), 0));
- EXPECT_EQ(Data1, toReference(DieDG.find(Attr_DW_FORM_ref1), 0));
- EXPECT_EQ(Data2, toReference(DieDG.find(Attr_DW_FORM_ref2), 0));
- EXPECT_EQ(Data4, toReference(DieDG.find(Attr_DW_FORM_ref4), 0));
- EXPECT_EQ(Data8, toReference(DieDG.find(Attr_DW_FORM_ref8), 0));
+ EXPECT_EQ(RefAddr, toDebugInfoReference(DieDG.find(Attr_DW_FORM_ref_addr), 0));
+ EXPECT_EQ(Data1, toRelativeReference(DieDG.find(Attr_DW_FORM_ref1), 0));
+ EXPECT_EQ(Data2, toRelativeReference(DieDG.find(Attr_DW_FORM_ref2), 0));
+ EXPECT_EQ(Data4, toRelativeReference(DieDG.find(Attr_DW_FORM_ref4), 0));
+ EXPECT_EQ(Data8, toRelativeReference(DieDG.find(Attr_DW_FORM_ref8), 0));
if (Version >= 4) {
- EXPECT_EQ(Data8_2, toReference(DieDG.find(Attr_DW_FORM_ref_sig8), 0));
+ EXPECT_EQ(Data8_2, toSignatureReference(DieDG.find(Attr_DW_FORM_ref_sig8), 0));
}
- EXPECT_EQ(UData[0], toReference(DieDG.find(Attr_DW_FORM_ref_udata), 0));
+ EXPECT_EQ(UData[0], toRelativeReference(DieDG.find(Attr_DW_FORM_ref_udata), 0));
//----------------------------------------------------------------------
// Test flag forms
@@ -420,7 +420,7 @@ void TestAllForms() {
// Test DWARF32/DWARF64 forms
//----------------------------------------------------------------------
EXPECT_EQ(Dwarf32Values[0],
- toReference(DieDG.find(Attr_DW_FORM_GNU_ref_alt), 0));
+ toSupplementaryReference(DieDG.find(Attr_DW_FORM_GNU_ref_alt), 0));
if (Version >= 4) {
EXPECT_EQ(Dwarf32Values[1],
toSectionOffset(DieDG.find(Attr_DW_FORM_sec_offset), 0));
@@ -761,14 +761,14 @@ template <uint16_t Version, class AddrType> void TestReferences() {
EXPECT_TRUE(CU1Ref1DieDG.isValid());
EXPECT_EQ(CU1Ref1DieDG.getTag(), DW_TAG_variable);
EXPECT_EQ(CU1TypeDieDG.getOffset(),
- toReference(CU1Ref1DieDG.find(DW_AT_type), -1ULL));
+ toRelativeReference(CU1Ref1DieDG.find(DW_AT_type), -1ULL));
// Verify the sibling is our Ref2 DIE and that its DW_AT_type points to our
// base type DIE in CU1.
auto CU1Ref2DieDG = CU1Ref1DieDG.getSibling();
EXPECT_TRUE(CU1Ref2DieDG.isValid());
EXPECT_EQ(CU1Ref2DieDG.getTag(), DW_TAG_variable);
EXPECT_EQ(CU1TypeDieDG.getOffset(),
- toReference(CU1Ref2DieDG.find(DW_AT_type), -1ULL));
+ toRelativeReference(CU1Ref2DieDG.find(DW_AT_type), -1ULL));
// Verify the sibling is our Ref4 DIE and that its DW_AT_type points to our
...
[truncated]
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome - thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/92/builds/1768 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/3089 Here is the relevant piece of the build log for the reference:
|
@labath seems that bolt needs some adaptation |
I see the problem. I'm testing a fix now. |
Summary: The result of the function cannot be correctly interpreted without knowing the precise form type (a type signature needs to be looked up very differently from a supplementary debug info reference). The function sort of worked because the two reference types (unit-relative and section-relative) that can be handled uniformly are also the most common types of references, but this setup made it easy to write code which does not support other kinds of reference (and if one tried to support them, the result didn't look pretty -- https://github.com/llvm/llvm-project/pull/97423/files#r1676217081). The split is based on the reference type classification from DWARFv5 (Section 7.5.5 Classes and Forms), and it should enable uniform (if slightly more verbose) hadling. Note that this only affects users which want more control of how (or if) the references are resolved. Users which just want to access the referenced DIE can use the higher level API (DWARFDie::GetAttributeValueAsReferencedDie) which returns (or will return after llvm#97423 is merged) the correct die for all reference types (except for supplementary references, which we don't support right now). Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D59822392
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D59822372
The caller (cloneAttribute) already switches on the reference type. By aligning the cases with the retrieval functions, we can avoid branching twice.
(#99324) The caller (cloneAttribute) already switches on the reference type. By aligning the cases with the retrieval functions, we can avoid branching twice.
…m#98905 (llvm#99324) The caller (cloneAttribute) already switches on the reference type. By aligning the cases with the retrieval functions, we can avoid branching twice.
…m#98905 (llvm#99324) The caller (cloneAttribute) already switches on the reference type. By aligning the cases with the retrieval functions, we can avoid branching twice.
Summary: The result of the function cannot be correctly interpreted without knowing the precise form type (a type signature needs to be looked up very differently from a supplementary debug info reference). The function sort of worked because the two reference types (unit-relative and section-relative) that can be handled uniformly are also the most common types of references, but this setup made it easy to write code which does not support other kinds of reference (and if one tried to support them, the result didn't look pretty -- https://github.com/llvm/llvm-project/pull/97423/files#r1676217081). The split is based on the reference type classification from DWARFv5 (Section 7.5.5 Classes and Forms), and it should enable uniform (if slightly more verbose) hadling. Note that this only affects users which want more control of how (or if) the references are resolved. Users which just want to access the referenced DIE can use the higher level API (DWARFDie::GetAttributeValueAsReferencedDie) which returns (or will return after #97423 is merged) the correct die for all reference types (except for supplementary references, which we don't support right now). Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251742
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251577
(#99324) Summary: The caller (cloneAttribute) already switches on the reference type. By aligning the cases with the retrieval functions, we can avoid branching twice. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250831
The result of the function cannot be correctly interpreted without knowing the precise form type (a type signature needs to be looked up very differently from a supplementary debug info reference). The function sort of worked because the two reference types (unit-relative and section-relative) that can be handled uniformly are also the most common types of references, but this setup made it easy to write code which does not support other kinds of reference (and if one tried to support them, the result didn't look pretty --
https://github.com/llvm/llvm-project/pull/97423/files#r1676217081).
The split is based on the reference type classification from DWARFv5 (Section 7.5.5 Classes and Forms), and it should enable uniform (if slightly more verbose) hadling. Note that this only affects users which want more control of how (or if) the references are resolved. Users which just want to access the referenced DIE can use the higher level API (DWARFDie::GetAttributeValueAsReferencedDie) which returns (or will return after #97423 is merged) the correct die for all reference types (except for supplementary references, which we don't support right now).