[llvm] [dsymutil] Fix linker's ODR uniquing for typedefs with different underlying types (PR #195749)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 4 15:52:08 PDT 2026
================
@@ -116,6 +116,28 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
NameForUniquing = StringPool.internString(FullName ? *FullName : Name);
}
+ // For typedefs, include the referenced type's tag and name in the uniquing
+ // key. Two typedefs with the same name (e.g. from preferred_name) but
+ // different DW_AT_type targets must get different DeclContexts, otherwise
+ // ODR deduplication can create self-referencing typedef cycles in the output
+ // DWARF. This mirrors the parallel linker fix in the parallel linker:
+ // https://github.com/llvm/llvm-project/pull/166767
+ if (Tag == dwarf::DW_TAG_typedef && !NameForUniquing.empty()) {
+ if (auto TypeAttr = DIE.find(dwarf::DW_AT_type)) {
+ if (auto RefDie = DIE.getAttributeValueAsReferencedDie(*TypeAttr)) {
+ StringRef RefName = RefDie.getShortName();
----------------
alx32 wrote:
Could this still miss typedefs through unnamed wrapper types, like `FooA *` vs `FooB *`, since `DW_TAG_pointer_type` has no short name here? It seems the parallel linker handles this by recursively adding referenced ODR DIE names and wrapper type prefixes in [`SyntheticTypeNameBuilder`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp#L276-L305) and [`addTypePrefix`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp#L433-L570).
https://github.com/llvm/llvm-project/pull/195749
More information about the llvm-commits
mailing list