[llvm] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70515)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 16:40:09 PST 2023
================
@@ -267,28 +277,66 @@ class DWARF5AccelTableData : public AccelTableData {
}
unsigned getDieTag() const { return DieTag; }
unsigned getUnitID() const { return UnitID; }
+ bool isTU() const { return IsTU; }
void normalizeDIEToOffset() {
assert(std::holds_alternative<const DIE *>(OffsetVal) &&
"Accessing offset after normalizing.");
OffsetVal = std::get<const DIE *>(OffsetVal)->getOffset();
}
+ bool isNormalized() const {
+ return std::holds_alternative<uint64_t>(OffsetVal);
+ }
protected:
std::variant<const DIE *, uint64_t> OffsetVal;
- unsigned DieTag;
- unsigned UnitID;
+ uint32_t DieTag : 16;
+ uint32_t UnitID : 15;
+ uint32_t IsTU : 1;
uint64_t order() const override { return getDieOffset(); }
};
+struct TypeUnitMetaInfo {
+ // Symbol for start of the TU section.
+ MCSymbol *Label;
+ // Unique ID of Type Unit.
+ unsigned UniqueID;
+};
+using TUVectorTy = SmallVector<TypeUnitMetaInfo, 1>;
class DWARF5AccelTable : public AccelTable<DWARF5AccelTableData> {
+ // Symbols to start of all the TU sections that were generated.
+ TUVectorTy TUSymbols;
+
public:
+ struct UnitIndexAndEncoding {
+ unsigned Index;
+ DWARF5AccelTableData::AttributeEncoding Endoding;
+ };
+ /// Returns type units that were constructed.
+ const TUVectorTy &getTypeUnitsSymbols() { return TUSymbols; }
+ /// Add a type unit start symbol.
+ void addTypeUnitSymbol(DwarfTypeUnit &U);
/// Convert DIE entries to explicit offset.
/// Needs to be called after DIE offsets are computed.
void convertDieToOffset() {
for (auto &Entry : Entries) {
for (AccelTableData *Value : Entry.second.Values) {
- static_cast<DWARF5AccelTableData *>(Value)->normalizeDIEToOffset();
+ DWARF5AccelTableData *Data = static_cast<DWARF5AccelTableData *>(Value);
+ // For TU we normalize as each Unit is emitted.
+ // So when this is invoked after CU construction we will be in mixed
+ // state.
+ if (!Data->isNormalized())
----------------
ayermolo wrote:
Not sure I follow. This function is invoked when we write out finished type units on AccelTypeUnitsDebugNames. Which only has not-normalized TUs. It is also invoked in ::finalizeModuleInfo. At which point it will have normalized TU entries and not-normalized CU entries.
Are you saying we should expose IsTU() and check that?
https://github.com/llvm/llvm-project/pull/70515
More information about the llvm-commits
mailing list