[llvm] [LLVM[NFC] Refactor to allow debug_names entries to conatain DIE offset (PR #69399)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 15:28:08 PDT 2023


================
@@ -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);
----------------
dwblaikie wrote:

> I was thinking about assert, but there are release builds that have asserts turned off.... So will result in "weird" crash.

Sure, though better than untested code being unidentifiable.

> 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.

Ah, OK - so at the moment this code is actually load bearing.

Could that be fixed/changed? Could normalizing happen before finalize?

https://github.com/llvm/llvm-project/pull/69399


More information about the llvm-commits mailing list