[llvm] [dsymutil] Fix parallel linker's self-recursive typedef DIE by including referred-to types (PR #166767)
Roy Shi via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 6 04:58:21 PST 2025
https://github.com/royitaqi created https://github.com/llvm/llvm-project/pull/166767
See #166675 for description of the problem, the root cause, and one solution. This patch is a "different implementation" descried there.
This patch tries to fix the problem by recursively including the referred-to types into the synthetic name. This way, the synthetic name of the typedef DIE is canonicalized. See example below:
```
SyntheticTypeNameBuilder::addDIETypeName() is called for DIE at offset 0x0000004c
SyntheticName = {H}BarInt{F}Foo<int>:() <- Two different names
Assigned to type descriptor. TypeEntryPtr = 0x0000004c0x0x150020a38 <- Hence different type entries
SyntheticTypeNameBuilder::addDIETypeName() is called for DIE at offset 0x00000044
SyntheticName = {H}BarInt{H}BarInt{F}Foo<int>:() <- Two different names
Assigned to type descriptor. TypeEntryPtr = 0x000000440x0x150020a60 <- Hence different type entries
```
The advantages of this approach over https://github.com/llvm/llvm-project/pull/166675 are:
1. The resulting synthetic name is more "correct" than using decl file and line (which _can_ still collide).
1. This doesn't depend on https://github.com/llvm/llvm-project/issues/166673 to be fixed.
Caveat is that it won't work if any of the referenced types resolve to the same name for some reason (similar to how the two typedefs resolved to the same name before this patch).
>From cfe98a31eb64713ff7966f948efb0d843daf121b Mon Sep 17 00:00:00 2001
From: Roy Shi <royshi at meta.com>
Date: Thu, 6 Nov 2025 04:37:33 -0800
Subject: [PATCH] [dsymutil] Fix parallel linker's self-recursive typedef DIE
by adding ref type name
---
llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp b/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp
index 34174f98b7e37..6900187b94ed7 100644
--- a/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp
@@ -377,8 +377,8 @@ Error SyntheticTypeNameBuilder::addTypeName(UnitEntryPairTy InputUnitEntryPair,
} break;
}
- // If name for the DIE is not determined yet add referenced types to the name.
- if (!HasLinkageName && !HasShortName && !HasDeclFileName) {
+ // If name for the DIE is not determined yet or if the DIE is a typedef, add referenced types to the name.
+ if ((!HasLinkageName && !HasShortName && !HasDeclFileName) || InputUnitEntryPair.DieEntry->getTag() == dwarf::DW_TAG_typedef) {
if (InputUnitEntryPair.CU->find(InputUnitEntryPair.DieEntry,
getODRAttributes()))
if (Error Err = addReferencedODRDies(InputUnitEntryPair, AddParentNames,
More information about the llvm-commits
mailing list