[llvm] [AsmPrinter][DebugNames] Implement DW_IDX_parent entries (PR #77457)
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 12 08:10:38 PST 2024
================
@@ -282,19 +299,45 @@ class DWARF5AccelTableData : public AccelTableData {
assert(isNormalized() && "Accessing DIE Offset before normalizing.");
return std::get<uint64_t>(OffsetVal);
}
+
+ OffsetAndUnitID getDieOffsetAndUnitID() const {
+ return {getDieOffset(), UnitID};
+ }
+
unsigned getDieTag() const { return DieTag; }
unsigned getUnitID() const { return UnitID; }
bool isTU() const { return IsTU; }
void normalizeDIEToOffset() {
assert(!isNormalized() && "Accessing offset after normalizing.");
- OffsetVal = std::get<const DIE *>(OffsetVal)->getOffset();
+ const DIE *Entry = std::get<const DIE *>(OffsetVal);
+ ParentOffset = getDefiningParentDieOffset(*Entry);
+ OffsetVal = Entry->getOffset();
}
bool isNormalized() const {
return std::holds_alternative<uint64_t>(OffsetVal);
}
+ std::optional<uint64_t> getParentDieOffset() const {
+ auto OffsetAndId = getParentDieOffsetAndUnitID();
+ if (!OffsetAndId)
+ return {};
+ return OffsetAndId->offset();
----------------
JDevlieghere wrote:
Save one line? ;-)
```
if (auto OffsetAndId = getParentDieOffsetAndUnitID())
return OffsetAndId->offset();
return {};
```
https://github.com/llvm/llvm-project/pull/77457
More information about the llvm-commits
mailing list