-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LLVM[NFC] Refactor to allow debug_names entries to conatain DIE offset #69399
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
Changes from 1 commit
103d7fd
06ae74e
b3b4cb1
b1c90e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,20 +252,27 @@ class DWARF5AccelTableData : public AccelTableData { | |
public: | ||
static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); } | ||
|
||
DWARF5AccelTableData(const DIE &Die) : Die(Die) {} | ||
DWARF5AccelTableData(const DIE &Die, const DwarfCompileUnit &CU); | ||
|
||
#ifndef NDEBUG | ||
void print(raw_ostream &OS) const override; | ||
#endif | ||
|
||
const DIE &getDie() const { return Die; } | ||
uint64_t getDieOffset() const { return Die.getOffset(); } | ||
unsigned getDieTag() const { return Die.getTag(); } | ||
uint64_t getDieOffset() const { | ||
if (const DIE *const *TDie = std::get_if<const DIE *>(&OffsetVal)) | ||
return (*TDie)->getOffset(); | ||
return std::get<uint64_t>(OffsetVal); | ||
} | ||
unsigned getDieTag() const { return Tag; } | ||
unsigned getUnitID() const { return UnitID; } | ||
void normalizeDIEToOffset() { OffsetVal = getDieOffset(); } | ||
|
||
protected: | ||
const DIE &Die; | ||
std::variant<const DIE *, uint64_t> OffsetVal; | ||
dwarf::Tag Tag; | ||
unsigned UnitID; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to end up increasing the size of the struct from 8 bytes to ((8(pointer/uint64)+8(discriminator and padding))+2(Tag)+2(padding)+4(uintID) == 24 bytes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's a blocker I can redesign, but personally I think trying to squeeze most bits out just leads to a more fragile implementation. Plus cool c++ features. :D Running llc on sema bitcode: main
Seems like these changes fall under noise? |
||
|
||
uint64_t order() const override { return Die.getOffset(); } | ||
uint64_t order() const override { return getDieOffset(); } | ||
}; | ||
|
||
class DWARF5AccelTableStaticData : public AccelTableData { | ||
|
@@ -283,6 +290,8 @@ class DWARF5AccelTableStaticData : public AccelTableData { | |
uint64_t getDieOffset() const { return DieOffset; } | ||
unsigned getDieTag() const { return DieTag; } | ||
unsigned getCUIndex() const { return CUIndex; } | ||
void normalizeDIEToOffset() { /* Not needed since DIE is not used. */ | ||
} | ||
|
||
protected: | ||
uint64_t DieOffset; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3547,9 +3547,11 @@ void DwarfDebug::addAccelNameImpl(const DICompileUnit &CU, | |
case AccelTableKind::Apple: | ||
AppleAccel.addName(Ref, Die); | ||
break; | ||
case AccelTableKind::Dwarf: | ||
AccelDebugNames.addName(Ref, Die); | ||
case AccelTableKind::Dwarf: { | ||
DwarfCompileUnit *CU = lookupCU(Die.getUnitDie()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well input there is DICompileUnit, which doesn't have uniqueID set yet, I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I'd have thought it would - the DICompileUnit doesn't carry it directly, which is fair. But I think it's more efficient to use the CUMap to go from DICompileUnit -> DwarfCompileUnit, rather than going from DIE->unit DIE-> DwarfCompileUnit? |
||
AccelDebugNames.addName(Ref, Die, *CU); | ||
break; | ||
} | ||
case AccelTableKind::Default: | ||
llvm_unreachable("Default should have already been resolved."); | ||
case AccelTableKind::None: | ||
|
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.
Might be better to make this assert-fail if it's stil in DIE mode, rather than offset mode? (to make it clear that that transformation is intended - I mean, if someone queries it before the DIEs have been laid out, DIE::getOffset will assert - but still, this seems like excess API surface area that could lead to more confusion later that'd be avoided by a hard stop here)
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.
I was thinking about assert, but there are release builds that have asserts turned off.... So will result in "weird" crash.
Also getDieOffset is used in order() from ccelTableBase::finalize which is invoked before normalization happens.
One of the unit tests was failing because of it.
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.
Sure, though better than untested code being unidentifiable.
Ah, OK - so at the moment this code is actually load bearing.
Could that be fixed/changed? Could normalizing happen before finalize?
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.
It can be moved to llvm::emitDWARF5AccelTable before Contents.finalize is invoked?
My original thought was to do normalization close to use, in context where it matters. In Dwarf5AccelTableWriter.
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.
I think it'd be a somewhat simpler conceptual model if all uses of the DIE offsets in the accelerator tables came in the offset mode, after the DIE mode, if possible. Like after the DIE tree is finalized, we could finalize the accelerator in a similar way?
Like just after the
computeSizeAndOffsets
call inDwarfDebug::finalizeModuleInfo()
we could do something similar to the accelerator tables? (call some function then take the sizes and offsets so computed, and bake them in/discard the DIE references)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.
Sure, let me take a look there.
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.
something like fixup?
I went with path of least resistance of exposing Entries. Umm probably not ideal.
Alternative is for AccelTableBase to have some kind of member function that takes in a lambda to peform stuff on Entries. Although with all the templated code not sure how easy that will be.
Issue is that buckets are not available until AccelTableBase::finalize is called.
Overall I kind of feel weird calling some normalize/finalize thing after offsets are computed, that is just applicable to one thing.