Skip to content

Commit 0cb2ae3

Browse files
authored
Revert "[CLANG][DWARF] Handle DIE offset collision in DW_IDX_parent" (#95302)
Reverts #95039 This looks like it caused the ASan bot to fail: https://lab.llvm.org/buildbot/#/builders/168/builds/20912 Offending line was changed in this PR
1 parent 682d461 commit 0cb2ae3

File tree

5 files changed

+22
-115
lines changed

5 files changed

+22
-115
lines changed

llvm/include/llvm/CodeGen/AccelTable.h

+15-34
Original file line numberDiff line numberDiff line change
@@ -257,38 +257,18 @@ class AppleAccelTableData : public AccelTableData {
257257

258258
/// Helper class to identify an entry in DWARF5AccelTable based on their DIE
259259
/// offset and UnitID.
260-
struct OffsetAndUnitID {
261-
uint64_t Offset = 0;
262-
uint32_t UnitID = 0;
263-
bool IsTU = false;
264-
OffsetAndUnitID() = default;
265-
OffsetAndUnitID(uint64_t Offset, uint32_t UnitID, bool IsTU)
266-
: Offset(Offset), UnitID(UnitID), IsTU(IsTU) {}
267-
uint64_t offset() const { return Offset; };
268-
uint32_t unitID() const { return UnitID; };
269-
bool isTU() const { return IsTU; }
270-
};
260+
struct OffsetAndUnitID : std::pair<uint64_t, uint32_t> {
261+
using Base = std::pair<uint64_t, uint32_t>;
262+
OffsetAndUnitID(Base B) : Base(B) {}
271263

272-
template <> struct DenseMapInfo<OffsetAndUnitID> {
273-
static inline OffsetAndUnitID getEmptyKey() {
274-
OffsetAndUnitID Entry;
275-
Entry.Offset = uint64_t(-1);
276-
return Entry;
277-
}
278-
static inline OffsetAndUnitID getTombstoneKey() {
279-
OffsetAndUnitID Entry;
280-
Entry.Offset = uint64_t(-2);
281-
return Entry;
282-
}
283-
static unsigned getHashValue(const OffsetAndUnitID &Val) {
284-
return (unsigned)llvm::hash_combine(Val.offset(), Val.unitID(), Val.IsTU);
285-
}
286-
static bool isEqual(const OffsetAndUnitID &LHS, const OffsetAndUnitID &RHS) {
287-
return LHS.offset() == RHS.offset() && LHS.unitID() == RHS.unitID() &&
288-
LHS.IsTU == RHS.isTU();
289-
}
264+
OffsetAndUnitID(uint64_t Offset, uint32_t UnitID) : Base(Offset, UnitID) {}
265+
uint64_t offset() const { return first; };
266+
uint32_t unitID() const { return second; };
290267
};
291268

269+
template <>
270+
struct DenseMapInfo<OffsetAndUnitID> : DenseMapInfo<OffsetAndUnitID::Base> {};
271+
292272
/// The Data class implementation for DWARF v5 accelerator table. Unlike the
293273
/// Apple Data classes, this class is just a DIE wrapper, and does not know to
294274
/// serialize itself. The complete serialization logic is in the
@@ -297,11 +277,12 @@ class DWARF5AccelTableData : public AccelTableData {
297277
public:
298278
static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); }
299279

300-
DWARF5AccelTableData(const DIE &Die, const uint32_t UnitID, const bool IsTU);
280+
DWARF5AccelTableData(const DIE &Die, const uint32_t UnitID,
281+
const bool IsTU = false);
301282
DWARF5AccelTableData(const uint64_t DieOffset,
302283
const std::optional<uint64_t> DefiningParentOffset,
303284
const unsigned DieTag, const unsigned UnitID,
304-
const bool IsTU)
285+
const bool IsTU = false)
305286
: OffsetVal(DieOffset), ParentOffset(DefiningParentOffset),
306287
DieTag(DieTag), AbbrevNumber(0), IsTU(IsTU), UnitID(UnitID) {}
307288

@@ -315,7 +296,7 @@ class DWARF5AccelTableData : public AccelTableData {
315296
}
316297

317298
OffsetAndUnitID getDieOffsetAndUnitID() const {
318-
return {getDieOffset(), getUnitID(), isTU()};
299+
return {getDieOffset(), UnitID};
319300
}
320301

321302
unsigned getDieTag() const { return DieTag; }
@@ -341,7 +322,7 @@ class DWARF5AccelTableData : public AccelTableData {
341322
assert(isNormalized() && "Accessing DIE Offset before normalizing.");
342323
if (!ParentOffset)
343324
return std::nullopt;
344-
return OffsetAndUnitID(*ParentOffset, getUnitID(), isTU());
325+
return OffsetAndUnitID(*ParentOffset, getUnitID());
345326
}
346327

347328
/// Sets AbbrevIndex for an Entry.
@@ -435,7 +416,7 @@ class DWARF5AccelTable : public AccelTable<DWARF5AccelTableData> {
435416
for (auto *Data : Entry.second.getValues<DWARF5AccelTableData *>()) {
436417
addName(Entry.second.Name, Data->getDieOffset(),
437418
Data->getParentDieOffset(), Data->getDieTag(),
438-
Data->getUnitID(), Data->isTU());
419+
Data->getUnitID(), true);
439420
}
440421
}
441422
}

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3592,8 +3592,7 @@ void DwarfDebug::addAccelNameImpl(
35923592
"Kind is TU but CU is being processed.");
35933593
// The type unit can be discarded, so need to add references to final
35943594
// acceleration table once we know it's complete and we emit it.
3595-
Current.addName(Ref, Die, Unit.getUniqueID(),
3596-
Unit.getUnitDie().getTag() == dwarf::DW_TAG_type_unit);
3595+
Current.addName(Ref, Die, Unit.getUniqueID());
35973596
break;
35983597
}
35993598
case AccelTableKind::Default:

llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -2247,20 +2247,17 @@ void DWARFLinker::emitAcceleratorEntriesForUnit(CompileUnit &Unit) {
22472247
DebugNames.addName(
22482248
Namespace.Name, Namespace.Die->getOffset(),
22492249
DWARF5AccelTableData::getDefiningParentDieOffset(*Namespace.Die),
2250-
Namespace.Die->getTag(), Unit.getUniqueID(),
2251-
Unit.getOutputUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);
2250+
Namespace.Die->getTag(), Unit.getUniqueID());
22522251
for (const auto &Pubname : Unit.getPubnames())
22532252
DebugNames.addName(
22542253
Pubname.Name, Pubname.Die->getOffset(),
22552254
DWARF5AccelTableData::getDefiningParentDieOffset(*Pubname.Die),
2256-
Pubname.Die->getTag(), Unit.getUniqueID(),
2257-
Unit.getOutputUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);
2255+
Pubname.Die->getTag(), Unit.getUniqueID());
22582256
for (const auto &Pubtype : Unit.getPubtypes())
22592257
DebugNames.addName(
22602258
Pubtype.Name, Pubtype.Die->getOffset(),
22612259
DWARF5AccelTableData::getDefiningParentDieOffset(*Pubtype.Die),
2262-
Pubtype.Die->getTag(), Unit.getUniqueID(),
2263-
Unit.getOutputUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);
2260+
Pubtype.Die->getTag(), Unit.getUniqueID());
22642261
} break;
22652262
}
22662263
}

llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -1356,10 +1356,9 @@ void DWARFLinkerImpl::emitDWARFv5DebugNamesSection(const Triple &TargetTriple) {
13561356
case DwarfUnit::AccelType::Name:
13571357
case DwarfUnit::AccelType::Namespace:
13581358
case DwarfUnit::AccelType::Type: {
1359-
DebugNames->addName(
1360-
*DebugStrStrings.getExistingEntry(Info.String), Info.OutOffset,
1361-
std::nullopt /*ParentDIEOffset*/, Info.Tag, CU->getUniqueID(),
1362-
CU->getOutUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);
1359+
DebugNames->addName(*DebugStrStrings.getExistingEntry(Info.String),
1360+
Info.OutOffset, std::nullopt /*ParentDIEOffset*/,
1361+
Info.Tag, CU->getUniqueID());
13631362
} break;
13641363

13651364
default:

llvm/test/DebugInfo/X86/debug-names-types-die-offset-collision.ll

-69
This file was deleted.

0 commit comments

Comments
 (0)