[llvm] b05df02 - Revert "[DWARF] Fix PR51087 Extraneous enum record in DWARF with type units"
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 23 20:53:20 PST 2021
Author: David Blaikie
Date: 2021-12-23T20:50:30-08:00
New Revision: b05df0287bafff65723c3aacfc3a6b43183a9a26
URL: https://github.com/llvm/llvm-project/commit/b05df0287bafff65723c3aacfc3a6b43183a9a26
DIFF: https://github.com/llvm/llvm-project/commit/b05df0287bafff65723c3aacfc3a6b43183a9a26.diff
LOG: Revert "[DWARF] Fix PR51087 Extraneous enum record in DWARF with type units"
Causes invalid debug_gnu_pubnames (& I think non-gnu pubnames too) -
visible as 0 values for the offset in gnu pubnames. More details on the
original review in D115325.
This reverts commit 78d15a112cbd545fbb6e1aa37c221ef5aeffb3f2.
This reverts commit 54586582d3e17c0bba76258d2930486a6dfaaf2a.
Added:
llvm/test/DebugInfo/Generic/type-units-maybe-unused-types.ll
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
Removed:
llvm/test/DebugInfo/X86/type-units-maybe-unused-types.ll
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index b1c78f0faac4e..48134f1fd7747 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1141,21 +1141,6 @@ sortGlobalExprs(SmallVectorImpl<DwarfCompileUnit::GlobalExpr> &GVEs) {
return GVEs;
}
-/// Create a DIE for \p Ty if it doesn't already exist. If type units are
-/// enabled, try to emit a type unit without a CU skeleton DIE.
-static void createMaybeUnusedType(DwarfDebug &DD, DwarfCompileUnit &CU,
- DIType &Ty) {
- // Try to generate a type unit without creating a skeleton DIE in this CU.
- if (DICompositeType const *CTy = dyn_cast<DICompositeType>(&Ty)) {
- MDString const *TypeId = CTy->getRawIdentifier();
- if (DD.generateTypeUnits() && TypeId && !Ty.isForwardDecl())
- if (DD.getOrCreateDwarfTypeUnit(CU, TypeId->getString(), CTy))
- return;
- }
- // We couldn't or shouldn't add a type unit so create the DIE normally.
- CU.getOrCreateTypeDIE(&Ty);
-}
-
// Emit all Dwarf sections that should come prior to the content. Create
// global DIEs and emit initial debug info sections. This is invoked by
// the target AsmPrinter.
@@ -1239,17 +1224,15 @@ void DwarfDebug::beginModule(Module *M) {
CU.getOrCreateGlobalVariableDIE(GV, sortGlobalExprs(GVMap[GV]));
}
- for (auto *Ty : CUNode->getEnumTypes()) {
- // The enum types array by design contains pointers to
- // MDNodes rather than DIRefs. Unique them here.
- createMaybeUnusedType(*this, CU, *Ty);
- }
+ for (auto *Ty : CUNode->getEnumTypes())
+ CU.getOrCreateTypeDIE(cast<DIType>(Ty));
+
for (auto *Ty : CUNode->getRetainedTypes()) {
// The retained types array by design contains pointers to
// MDNodes rather than DIRefs. Unique them here.
if (DIType *RT = dyn_cast<DIType>(Ty))
// There is no point in force-emitting a forward declaration.
- createMaybeUnusedType(*this, CU, *RT);
+ CU.getOrCreateTypeDIE(RT);
}
// Emit imported_modules last so that the relevant context is already
// available.
@@ -1420,7 +1403,6 @@ void DwarfDebug::finalizeModuleInfo() {
SkeletonHolder.computeSizeAndOffsets();
}
-
// Emit all Dwarf sections that should come after the content.
void DwarfDebug::endModule() {
// Terminate the pending line table.
@@ -3384,30 +3366,17 @@ uint64_t DwarfDebug::makeTypeSignature(StringRef Identifier) {
void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
StringRef Identifier, DIE &RefDie,
const DICompositeType *CTy) {
- bool TopLevelType = TypeUnitsUnderConstruction.empty();
- if (auto Signature = getOrCreateDwarfTypeUnit(CU, Identifier, CTy)) {
- CU.addDIETypeSignature(RefDie, *Signature);
- } else if (TopLevelType) {
- // Construct this type in the CU directly.
- // This is inefficient because all the dependent types will be rebuilt
- // from scratch, including building them in type units, discovering that
- // they depend on addresses, throwing them out and rebuilding them.
- CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy));
- }
-}
-
-Optional<uint64_t>
-DwarfDebug::getOrCreateDwarfTypeUnit(DwarfCompileUnit &CU, StringRef Identifier,
- const DICompositeType *CTy) {
// Fast path if we're building some type units and one has already used the
// address pool we know we're going to throw away all this work anyway, so
// don't bother building dependent types.
if (!TypeUnitsUnderConstruction.empty() && AddrPool.hasBeenUsed())
- return None;
+ return;
auto Ins = TypeSignatures.insert(std::make_pair(CTy, 0));
- if (!Ins.second)
- return Ins.first->second;
+ if (!Ins.second) {
+ CU.addDIETypeSignature(RefDie, Ins.first->second);
+ return;
+ }
bool TopLevelType = TypeUnitsUnderConstruction.empty();
AddrPool.resetUsedFlag();
@@ -3461,7 +3430,13 @@ DwarfDebug::getOrCreateDwarfTypeUnit(DwarfCompileUnit &CU, StringRef Identifier,
// the type that used an address.
for (const auto &TU : TypeUnitsToAdd)
TypeSignatures.erase(TU.second);
- return None;
+
+ // Construct this type in the CU directly.
+ // This is inefficient because all the dependent types will be rebuilt
+ // from scratch, including building them in type units, discovering that
+ // they depend on addresses, throwing them out and rebuilding them.
+ CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy));
+ return;
}
// If the type wasn't dependent on fission addresses, finish adding the type
@@ -3471,7 +3446,7 @@ DwarfDebug::getOrCreateDwarfTypeUnit(DwarfCompileUnit &CU, StringRef Identifier,
InfoHolder.emitUnit(TU.first.get(), useSplitDwarf());
}
}
- return Signature;
+ CU.addDIETypeSignature(RefDie, Signature);
}
DwarfDebug::NonTypeUnitContext::NonTypeUnitContext(DwarfDebug *DD)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index ff2589b3c953f..4e1a1b1e068df 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -667,12 +667,6 @@ class DwarfDebug : public DebugHandlerBase {
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
DIE &Die, const DICompositeType *CTy);
- /// Return the type unit signature of \p CTy after finding or creating its
- /// type unit. Return None if a type unit cannot be created for \p CTy.
- Optional<uint64_t> getOrCreateDwarfTypeUnit(DwarfCompileUnit &CU,
- StringRef Identifier,
- const DICompositeType *CTy);
-
class NonTypeUnitContext {
DwarfDebug *DD;
decltype(DwarfDebug::TypeUnitsUnderConstruction) TypeUnitsUnderConstruction;
diff --git a/llvm/test/DebugInfo/X86/type-units-maybe-unused-types.ll b/llvm/test/DebugInfo/Generic/type-units-maybe-unused-types.ll
similarity index 98%
rename from llvm/test/DebugInfo/X86/type-units-maybe-unused-types.ll
rename to llvm/test/DebugInfo/Generic/type-units-maybe-unused-types.ll
index 6bfc1e881de7f..589cd1b337ad0 100644
--- a/llvm/test/DebugInfo/X86/type-units-maybe-unused-types.ll
+++ b/llvm/test/DebugInfo/Generic/type-units-maybe-unused-types.ll
@@ -1,4 +1,4 @@
-; RUN: llc %s -mtriple=x86_64-linux-gnu -generate-type-units -o - -filetype=obj \
+; RUN: %llc_dwarf %s -generate-type-units -o - -filetype=obj \
; RUN: | llvm-dwarfdump -o - - \
; RUN: | FileCheck %s
More information about the llvm-commits
mailing list