[llvm] [llvm][dsymutil] Use the DW_AT_name of the uniqued DIE for insertion into .debug_names (PR #168513)
Michael Buch via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 08:48:50 PST 2025
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/168513
>From 2f87c7820c0f60006de5133fe53c11b48b80f442 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 20 Nov 2025 15:47:39 +0000
Subject: [PATCH 1/3] [llvm][dsymutil][test] Create dedicated AArch64 directory
Currently the tests for LLVM targets `AArch64` and `ARM` were in the
same directory. But if you only configured LLVM for one target (e.g.,
just `AArch64`, which is how I ran into this), then all tests under the
ARM directory are marked `UNSUPPORTED`.
This patch moves all the tests that are capable of running on
`AArch64`-only targets into a dedicated `AArch64` directory. The tests
that expected a plain `ARM` target were kept in the `ARM` directory.
Drive-by:
* Rename the `dummy-debug-map-amr64.map` to `dummy-debug-map-arm64.map` (note the typo in `amr64`)
---
.../accel-imported-declarations.test | 0
.../accel-imported-declarations.test | 0
.../dsymutil/{ARM => AArch64}/call-pc-reloc.test | 0
.../debug-names-accel-table-types.ll | 0
.../dsymutil/{ARM => AArch64}/discriminator.test | 0
.../{ARM => AArch64}/discriminator_repeated.test | 0
.../dummy-debug-map-arm64.map} | 0
.../dsymutil/{ARM => AArch64}/dwarf5-addr-base.test | 12 ++++++------
.../{ARM => AArch64}/dwarf5-addrx-0x0-last.test | 0
.../dwarf5-dwarf4-combination-macho.test | 6 +++---
.../dsymutil/{ARM => AArch64}/dwarf5-macho.test | 6 +++---
.../dwarf5-str-offsets-base-strx.test | 12 ++++++------
.../dsymutil/{ARM => AArch64}/extern-alias.test | 0
.../dsymutil/{ARM => AArch64}/fat-arch-name.test | 0
.../dsymutil/{ARM => AArch64}/fat-threading.test | 0
.../tools/dsymutil/{ARM => AArch64}/firmware.test | 0
.../dsymutil/{ARM => AArch64}/inline-source.test | 0
.../tools/dsymutil/{ARM => AArch64}/inlined-low_pc.c | 4 ++--
llvm/test/tools/dsymutil/AArch64/lit.local.cfg | 10 ++++++++++
.../{ARM => AArch64}/missing-object-warning.test | 0
.../{ARM => AArch64}/missing-symbol-warning.test | 0
.../tools/dsymutil/{ARM => AArch64}/preload.test | 0
.../remarks-linking-bundle-empty.test | 0
.../{ARM => AArch64}/remarks-linking-bundle.test | 0
.../{ARM => AArch64}/static-archive-collision.test | 0
.../dsymutil/{ARM => AArch64}/stmt-seq-macho.test | 0
llvm/test/tools/dsymutil/AArch64/suppressions.txt | 2 ++
.../swiftmodule-include-from-interface.test | 0
.../tools/dsymutil/{ARM => AArch64}/swiftmodule.test | 0
.../{ARM => AArch64}/typedefs-with-same-name.test | 0
llvm/test/tools/dsymutil/ARM/lit.local.cfg | 2 --
31 files changed, 32 insertions(+), 22 deletions(-)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/DWARFLinkerParallel/accel-imported-declarations.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/accel-imported-declarations.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/call-pc-reloc.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/debug-names-accel-table-types.ll (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/discriminator.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/discriminator_repeated.test (100%)
rename llvm/test/tools/dsymutil/{ARM/dummy-debug-map-amr64.map => AArch64/dummy-debug-map-arm64.map} (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/dwarf5-addr-base.test (96%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/dwarf5-addrx-0x0-last.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/dwarf5-dwarf4-combination-macho.test (98%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/dwarf5-macho.test (97%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/dwarf5-str-offsets-base-strx.test (98%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/extern-alias.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/fat-arch-name.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/fat-threading.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/firmware.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/inline-source.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/inlined-low_pc.c (82%)
create mode 100644 llvm/test/tools/dsymutil/AArch64/lit.local.cfg
rename llvm/test/tools/dsymutil/{ARM => AArch64}/missing-object-warning.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/missing-symbol-warning.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/preload.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/remarks-linking-bundle-empty.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/remarks-linking-bundle.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/static-archive-collision.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/stmt-seq-macho.test (100%)
create mode 100644 llvm/test/tools/dsymutil/AArch64/suppressions.txt
rename llvm/test/tools/dsymutil/{ARM => AArch64}/swiftmodule-include-from-interface.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/swiftmodule.test (100%)
rename llvm/test/tools/dsymutil/{ARM => AArch64}/typedefs-with-same-name.test (100%)
diff --git a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/accel-imported-declarations.test b/llvm/test/tools/dsymutil/AArch64/DWARFLinkerParallel/accel-imported-declarations.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/accel-imported-declarations.test
rename to llvm/test/tools/dsymutil/AArch64/DWARFLinkerParallel/accel-imported-declarations.test
diff --git a/llvm/test/tools/dsymutil/ARM/accel-imported-declarations.test b/llvm/test/tools/dsymutil/AArch64/accel-imported-declarations.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/accel-imported-declarations.test
rename to llvm/test/tools/dsymutil/AArch64/accel-imported-declarations.test
diff --git a/llvm/test/tools/dsymutil/ARM/call-pc-reloc.test b/llvm/test/tools/dsymutil/AArch64/call-pc-reloc.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/call-pc-reloc.test
rename to llvm/test/tools/dsymutil/AArch64/call-pc-reloc.test
diff --git a/llvm/test/tools/dsymutil/ARM/debug-names-accel-table-types.ll b/llvm/test/tools/dsymutil/AArch64/debug-names-accel-table-types.ll
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/debug-names-accel-table-types.ll
rename to llvm/test/tools/dsymutil/AArch64/debug-names-accel-table-types.ll
diff --git a/llvm/test/tools/dsymutil/ARM/discriminator.test b/llvm/test/tools/dsymutil/AArch64/discriminator.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/discriminator.test
rename to llvm/test/tools/dsymutil/AArch64/discriminator.test
diff --git a/llvm/test/tools/dsymutil/ARM/discriminator_repeated.test b/llvm/test/tools/dsymutil/AArch64/discriminator_repeated.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/discriminator_repeated.test
rename to llvm/test/tools/dsymutil/AArch64/discriminator_repeated.test
diff --git a/llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map b/llvm/test/tools/dsymutil/AArch64/dummy-debug-map-arm64.map
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map
rename to llvm/test/tools/dsymutil/AArch64/dummy-debug-map-arm64.map
diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-addr-base.test b/llvm/test/tools/dsymutil/AArch64/dwarf5-addr-base.test
similarity index 96%
rename from llvm/test/tools/dsymutil/ARM/dwarf5-addr-base.test
rename to llvm/test/tools/dsymutil/AArch64/dwarf5-addr-base.test
index dfcfa6723ab91..ebb2378f74705 100644
--- a/llvm/test/tools/dsymutil/ARM/dwarf5-addr-base.test
+++ b/llvm/test/tools/dsymutil/AArch64/dwarf5-addr-base.test
@@ -46,17 +46,17 @@
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base -o %t.dir/dwarf5-addr-base.dSYM
+RUN: dsymutil -y %p/dummy-debug-map-arm64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | FileCheck %s
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --linker parallel --no-odr -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel --no-odr -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base \
RUN: -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | FileCheck %s
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --linker parallel -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base \
RUN: -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | \
@@ -64,18 +64,18 @@ RUN: FileCheck %s --check-prefixes=CHECK,CHECK-LLVM
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --update -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base -o %t.dir/dwarf5-addr-base.dSYM
+RUN: dsymutil --update -y %p/dummy-debug-map-arm64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | FileCheck %s --check-prefix=UPD
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --linker parallel --no-odr --update -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel --no-odr --update -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base \
RUN: -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | \
RUN: FileCheck %s --check-prefix=UPD
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --linker parallel --update -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel --update -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base \
RUN: -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | \
diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-addrx-0x0-last.test b/llvm/test/tools/dsymutil/AArch64/dwarf5-addrx-0x0-last.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/dwarf5-addrx-0x0-last.test
rename to llvm/test/tools/dsymutil/AArch64/dwarf5-addrx-0x0-last.test
diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test b/llvm/test/tools/dsymutil/AArch64/dwarf5-dwarf4-combination-macho.test
similarity index 98%
rename from llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test
rename to llvm/test/tools/dsymutil/AArch64/dwarf5-dwarf4-combination-macho.test
index fb15f46ce0b24..8c42cd59f5ec4 100644
--- a/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test
+++ b/llvm/test/tools/dsymutil/AArch64/dwarf5-dwarf4-combination-macho.test
@@ -30,11 +30,11 @@
; clang -g -c -O1 b.cpp -gdwarf-4 -o 2.o
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-DWARF4-combination -o %t.dir/dwarf5-dwarf4-combination-macho.dSYM
+RUN: dsymutil -y %p/dummy-debug-map-arm64.map -oso-prepend-path=%p/../Inputs/DWARF5-DWARF4-combination -o %t.dir/dwarf5-dwarf4-combination-macho.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-dwarf4-combination-macho.dSYM -a --verbose | FileCheck %s --check-prefixes=CHECK,WITH-PARENTS
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --no-odr --linker parallel -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --no-odr --linker parallel -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-DWARF4-combination \
RUN: -o %t.dir/dwarf5-dwarf4-combination-macho.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-dwarf4-combination-macho.dSYM \
@@ -43,7 +43,7 @@ RUN: -a --verbose | FileCheck %s --check-prefixes=CHECK,NO-PARENTS
### Uncomment following when llvm-dwarfdump will dump address ranges
### correctly for severall compile units case.
COM: rm -rf %t.dir && mkdir -p %t.dir
-COM: dsymutil --linker parallel -y %p/dummy-debug-map-amr64.map \
+COM: dsymutil --linker parallel -y %p/dummy-debug-map-arm64.map \
COM: -oso-prepend-path=%p/../Inputs/DWARF5-DWARF4-combination \
COM: -o %t.dir/dwarf5-dwarf4-combination-macho.dSYM
COM: llvm-dwarfdump %t.dir/dwarf5-dwarf4-combination-macho.dSYM \
diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test b/llvm/test/tools/dsymutil/AArch64/dwarf5-macho.test
similarity index 97%
rename from llvm/test/tools/dsymutil/ARM/dwarf5-macho.test
rename to llvm/test/tools/dsymutil/AArch64/dwarf5-macho.test
index 08c8bba739281..f90f5975e02ed 100644
--- a/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test
+++ b/llvm/test/tools/dsymutil/AArch64/dwarf5-macho.test
@@ -18,18 +18,18 @@
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5 -o %t.dir/dwarf5-macho.dSYM
+RUN: dsymutil -y %p/dummy-debug-map-arm64.map -oso-prepend-path=%p/../Inputs/DWARF5 -o %t.dir/dwarf5-macho.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-macho.dSYM -a --verbose | FileCheck %s
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --linker parallel --no-odr -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel --no-odr -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5 -o %t.dir/dwarf5-macho.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-macho.dSYM -a --verbose | FileCheck %s
### Uncomment following when llvm-dwarfdump will print resolved address ranges
### for the case mutiplue compile units.
COM: rm -rf %t.dir && mkdir -p %t.dir
-COM: dsymutil --linker parallel -y %p/dummy-debug-map-amr64.map \
+COM: dsymutil --linker parallel -y %p/dummy-debug-map-arm64.map \
COM: -oso-prepend-path=%p/../Inputs/DWARF5 -o %t.dir/dwarf5-macho.dSYM
COM: llvm-dwarfdump %t.dir/dwarf5-macho.dSYM -a --verbose | FileCheck %s \
COM: --check-prefixes=CHECK,CHECK-LLVM
diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-str-offsets-base-strx.test b/llvm/test/tools/dsymutil/AArch64/dwarf5-str-offsets-base-strx.test
similarity index 98%
rename from llvm/test/tools/dsymutil/ARM/dwarf5-str-offsets-base-strx.test
rename to llvm/test/tools/dsymutil/AArch64/dwarf5-str-offsets-base-strx.test
index 4e6c66670da65..c0c4fe835682f 100644
--- a/llvm/test/tools/dsymutil/ARM/dwarf5-str-offsets-base-strx.test
+++ b/llvm/test/tools/dsymutil/AArch64/dwarf5-str-offsets-base-strx.test
@@ -50,33 +50,33 @@
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base -o %t.dir/dwarf5-addr-base.dSYM
+RUN: dsymutil -y %p/dummy-debug-map-arm64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | FileCheck %s --check-prefixes=CHECK,GLOBAL
-RUN: dsymutil --update -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base -o %t.dir/dwarf5-addr-base.dSYM
+RUN: dsymutil --update -y %p/dummy-debug-map-arm64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | FileCheck %s --check-prefixes=UPD,GLOBALUPD
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --linker parallel --no-odr -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel --no-odr -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base \
RUN: -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | \
RUN: FileCheck %s --check-prefixes=CHECK,LOCAL
RUN: rm -rf %t.dir && mkdir -p %t.dir
-RUN: dsymutil --linker parallel -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base \
RUN: -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | \
RUN: FileCheck %s --check-prefixes=CHECK,LOCAL,CHECK-LLVM
-RUN: dsymutil --linker parallel --no-odr --update -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel --no-odr --update -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base \
RUN: -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | \
RUN: FileCheck %s --check-prefixes=UPD,LOCALUPD
-RUN: dsymutil --linker parallel --update -y %p/dummy-debug-map-amr64.map \
+RUN: dsymutil --linker parallel --update -y %p/dummy-debug-map-arm64.map \
RUN: -oso-prepend-path=%p/../Inputs/DWARF5-addr-base-str-off-base \
RUN: -o %t.dir/dwarf5-addr-base.dSYM
RUN: llvm-dwarfdump %t.dir/dwarf5-addr-base.dSYM -a --verbose | \
diff --git a/llvm/test/tools/dsymutil/ARM/extern-alias.test b/llvm/test/tools/dsymutil/AArch64/extern-alias.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/extern-alias.test
rename to llvm/test/tools/dsymutil/AArch64/extern-alias.test
diff --git a/llvm/test/tools/dsymutil/ARM/fat-arch-name.test b/llvm/test/tools/dsymutil/AArch64/fat-arch-name.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/fat-arch-name.test
rename to llvm/test/tools/dsymutil/AArch64/fat-arch-name.test
diff --git a/llvm/test/tools/dsymutil/ARM/fat-threading.test b/llvm/test/tools/dsymutil/AArch64/fat-threading.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/fat-threading.test
rename to llvm/test/tools/dsymutil/AArch64/fat-threading.test
diff --git a/llvm/test/tools/dsymutil/ARM/firmware.test b/llvm/test/tools/dsymutil/AArch64/firmware.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/firmware.test
rename to llvm/test/tools/dsymutil/AArch64/firmware.test
diff --git a/llvm/test/tools/dsymutil/ARM/inline-source.test b/llvm/test/tools/dsymutil/AArch64/inline-source.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/inline-source.test
rename to llvm/test/tools/dsymutil/AArch64/inline-source.test
diff --git a/llvm/test/tools/dsymutil/ARM/inlined-low_pc.c b/llvm/test/tools/dsymutil/AArch64/inlined-low_pc.c
similarity index 82%
rename from llvm/test/tools/dsymutil/ARM/inlined-low_pc.c
rename to llvm/test/tools/dsymutil/AArch64/inlined-low_pc.c
index ad48b599b7b6e..d2d36f675e8b7 100644
--- a/llvm/test/tools/dsymutil/ARM/inlined-low_pc.c
+++ b/llvm/test/tools/dsymutil/AArch64/inlined-low_pc.c
@@ -3,9 +3,9 @@
static int foo(int i) { return 42 + i; }
int bar(int a) { return foo(a); }
-// RUN: dsymutil -f -y %p/dummy-debug-map-amr64.map -oso-prepend-path %p/../Inputs/inlined-low_pc -o - | llvm-dwarfdump - | FileCheck %s
+// RUN: dsymutil -f -y %p/dummy-debug-map-arm64.map -oso-prepend-path %p/../Inputs/inlined-low_pc -o - | llvm-dwarfdump - | FileCheck %s
-// RUN: dsymutil --linker parallel -f -y %p/dummy-debug-map-amr64.map \
+// RUN: dsymutil --linker parallel -f -y %p/dummy-debug-map-arm64.map \
// RUN: -oso-prepend-path %p/../Inputs/inlined-low_pc -o - | \
// RUN: llvm-dwarfdump - | FileCheck %s
diff --git a/llvm/test/tools/dsymutil/AArch64/lit.local.cfg b/llvm/test/tools/dsymutil/AArch64/lit.local.cfg
new file mode 100644
index 0000000000000..923d126d8707b
--- /dev/null
+++ b/llvm/test/tools/dsymutil/AArch64/lit.local.cfg
@@ -0,0 +1,10 @@
+if not "AArch64" in config.root.targets:
+ config.unsupported = True
+
+if config.llvm_use_sanitizer:
+ suppr = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), "suppressions.txt"
+ )
+ config.environment["LSAN_OPTIONS"] = "suppressions={}".format(suppr)
+
+config.suffixes = [".test", ".cpp", ".c"]
diff --git a/llvm/test/tools/dsymutil/ARM/missing-object-warning.test b/llvm/test/tools/dsymutil/AArch64/missing-object-warning.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/missing-object-warning.test
rename to llvm/test/tools/dsymutil/AArch64/missing-object-warning.test
diff --git a/llvm/test/tools/dsymutil/ARM/missing-symbol-warning.test b/llvm/test/tools/dsymutil/AArch64/missing-symbol-warning.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/missing-symbol-warning.test
rename to llvm/test/tools/dsymutil/AArch64/missing-symbol-warning.test
diff --git a/llvm/test/tools/dsymutil/ARM/preload.test b/llvm/test/tools/dsymutil/AArch64/preload.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/preload.test
rename to llvm/test/tools/dsymutil/AArch64/preload.test
diff --git a/llvm/test/tools/dsymutil/ARM/remarks-linking-bundle-empty.test b/llvm/test/tools/dsymutil/AArch64/remarks-linking-bundle-empty.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/remarks-linking-bundle-empty.test
rename to llvm/test/tools/dsymutil/AArch64/remarks-linking-bundle-empty.test
diff --git a/llvm/test/tools/dsymutil/ARM/remarks-linking-bundle.test b/llvm/test/tools/dsymutil/AArch64/remarks-linking-bundle.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/remarks-linking-bundle.test
rename to llvm/test/tools/dsymutil/AArch64/remarks-linking-bundle.test
diff --git a/llvm/test/tools/dsymutil/ARM/static-archive-collision.test b/llvm/test/tools/dsymutil/AArch64/static-archive-collision.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/static-archive-collision.test
rename to llvm/test/tools/dsymutil/AArch64/static-archive-collision.test
diff --git a/llvm/test/tools/dsymutil/ARM/stmt-seq-macho.test b/llvm/test/tools/dsymutil/AArch64/stmt-seq-macho.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/stmt-seq-macho.test
rename to llvm/test/tools/dsymutil/AArch64/stmt-seq-macho.test
diff --git a/llvm/test/tools/dsymutil/AArch64/suppressions.txt b/llvm/test/tools/dsymutil/AArch64/suppressions.txt
new file mode 100644
index 0000000000000..0a43d4493a933
--- /dev/null
+++ b/llvm/test/tools/dsymutil/AArch64/suppressions.txt
@@ -0,0 +1,2 @@
+# Ignore leaks in CoreFoundation.
+leak:CF
diff --git a/llvm/test/tools/dsymutil/ARM/swiftmodule-include-from-interface.test b/llvm/test/tools/dsymutil/AArch64/swiftmodule-include-from-interface.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/swiftmodule-include-from-interface.test
rename to llvm/test/tools/dsymutil/AArch64/swiftmodule-include-from-interface.test
diff --git a/llvm/test/tools/dsymutil/ARM/swiftmodule.test b/llvm/test/tools/dsymutil/AArch64/swiftmodule.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/swiftmodule.test
rename to llvm/test/tools/dsymutil/AArch64/swiftmodule.test
diff --git a/llvm/test/tools/dsymutil/ARM/typedefs-with-same-name.test b/llvm/test/tools/dsymutil/AArch64/typedefs-with-same-name.test
similarity index 100%
rename from llvm/test/tools/dsymutil/ARM/typedefs-with-same-name.test
rename to llvm/test/tools/dsymutil/AArch64/typedefs-with-same-name.test
diff --git a/llvm/test/tools/dsymutil/ARM/lit.local.cfg b/llvm/test/tools/dsymutil/ARM/lit.local.cfg
index d951f4ff14d4e..6c4647ca90ab7 100644
--- a/llvm/test/tools/dsymutil/ARM/lit.local.cfg
+++ b/llvm/test/tools/dsymutil/ARM/lit.local.cfg
@@ -1,7 +1,5 @@
if not "ARM" in config.root.targets:
config.unsupported = True
-if not "AArch64" in config.root.targets:
- config.unsupported = True
if config.llvm_use_sanitizer:
suppr = os.path.join(
>From d0149ac4b502db7fa44c5696b371b26897be6db6 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Tue, 18 Nov 2025 12:48:47 +0000
Subject: [PATCH 2/3] [llvm][dsymutil] Rename DeclContext::Name to
NameForUniquing
Better describes what the `Name` field is. I'm also planning on adding a
new `Name` field to the `DeclContext`, so I wanted to differentiate the
two.
---
.../Classic/DWARFLinkerDeclContext.h | 13 +++++-----
.../Classic/DWARFLinkerDeclContext.cpp | 26 ++++++++++---------
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
index 9fb1b3f80e2ff..776d1577b1c98 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
@@ -84,11 +84,12 @@ class DeclContext {
DeclContext() : DefinedInClangModule(0), Parent(*this) {}
DeclContext(unsigned Hash, uint32_t Line, uint32_t ByteSize, uint16_t Tag,
- StringRef Name, StringRef File, const DeclContext &Parent,
- DWARFDie LastSeenDIE = DWARFDie(), unsigned CUId = 0)
+ StringRef NameForUniquing, StringRef File,
+ const DeclContext &Parent, DWARFDie LastSeenDIE = DWARFDie(),
+ unsigned CUId = 0)
: QualifiedNameHash(Hash), Line(Line), ByteSize(ByteSize), Tag(Tag),
- DefinedInClangModule(0), Name(Name), File(File), Parent(Parent),
- LastSeenDIE(LastSeenDIE), LastSeenCompileUnitID(CUId) {}
+ DefinedInClangModule(0), NameForUniquing(NameForUniquing), File(File),
+ Parent(Parent), LastSeenDIE(LastSeenDIE), LastSeenCompileUnitID(CUId) {}
uint32_t getQualifiedNameHash() const { return QualifiedNameHash; }
@@ -114,7 +115,7 @@ class DeclContext {
uint32_t ByteSize = 0;
uint16_t Tag = dwarf::DW_TAG_compile_unit;
unsigned DefinedInClangModule : 1;
- StringRef Name;
+ StringRef NameForUniquing;
StringRef File;
const DeclContext &Parent;
DWARFDie LastSeenDIE;
@@ -180,7 +181,7 @@ struct DeclMapInfo : private DenseMapInfo<DeclContext *> {
return RHS == LHS;
return LHS->QualifiedNameHash == RHS->QualifiedNameHash &&
LHS->Line == RHS->Line && LHS->ByteSize == RHS->ByteSize &&
- LHS->Name.data() == RHS->Name.data() &&
+ LHS->NameForUniquing.data() == RHS->NameForUniquing.data() &&
LHS->File.data() == RHS->File.data() &&
LHS->Parent.QualifiedNameHash == RHS->Parent.QualifiedNameHash;
}
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
index c9c8dddce9c44..2037a3508df38 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
@@ -84,24 +84,25 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
break;
}
- StringRef NameRef;
+ StringRef NameForUniquing;
StringRef FileRef;
if (const char *LinkageName = DIE.getLinkageName())
- NameRef = StringPool.internString(LinkageName);
+ NameForUniquing = StringPool.internString(LinkageName);
else if (const char *ShortName = DIE.getShortName())
- NameRef = StringPool.internString(ShortName);
+ NameForUniquing = StringPool.internString(ShortName);
- bool IsAnonymousNamespace = NameRef.empty() && Tag == dwarf::DW_TAG_namespace;
+ bool IsAnonymousNamespace =
+ NameForUniquing.empty() && Tag == dwarf::DW_TAG_namespace;
if (IsAnonymousNamespace) {
// FIXME: For dsymutil-classic compatibility. I think uniquing within
// anonymous namespaces is wrong. There is no ODR guarantee there.
- NameRef = "(anonymous namespace)";
+ NameForUniquing = "(anonymous namespace)";
}
if (Tag != dwarf::DW_TAG_class_type && Tag != dwarf::DW_TAG_structure_type &&
Tag != dwarf::DW_TAG_union_type &&
- Tag != dwarf::DW_TAG_enumeration_type && NameRef.empty())
+ Tag != dwarf::DW_TAG_enumeration_type && NameForUniquing.empty())
return PointerIntPair<DeclContext *, 1>(nullptr);
unsigned Line = 0;
@@ -140,10 +141,10 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
}
}
- if (!Line && NameRef.empty())
+ if (!Line && NameForUniquing.empty())
return PointerIntPair<DeclContext *, 1>(nullptr);
- // We hash NameRef, which is the mangled name, in order to get most
+ // We hash NameForUniquing, which is the mangled name, in order to get most
// overloaded functions resolve correctly.
//
// Strictly speaking, hashing the Tag is only necessary for a
@@ -153,7 +154,8 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
// FIXME: dsymutil-classic won't unique the same type presented
// once as a struct and once as a class. Using the Tag in the fully
// qualified name hash to get the same effect.
- unsigned Hash = hash_combine(Context.getQualifiedNameHash(), Tag, NameRef);
+ unsigned Hash =
+ hash_combine(Context.getQualifiedNameHash(), Tag, NameForUniquing);
// FIXME: dsymutil-classic compatibility: when we don't have a name,
// use the filename.
@@ -161,15 +163,15 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
Hash = hash_combine(Hash, FileRef);
// Now look if this context already exists.
- DeclContext Key(Hash, Line, ByteSize, Tag, NameRef, FileRef, Context);
+ DeclContext Key(Hash, Line, ByteSize, Tag, NameForUniquing, FileRef, Context);
auto ContextIter = Contexts.find(&Key);
if (ContextIter == Contexts.end()) {
// The context wasn't found.
bool Inserted;
DeclContext *NewContext =
- new (Allocator) DeclContext(Hash, Line, ByteSize, Tag, NameRef, FileRef,
- Context, DIE, U.getUniqueID());
+ new (Allocator) DeclContext(Hash, Line, ByteSize, Tag, NameForUniquing,
+ FileRef, Context, DIE, U.getUniqueID());
std::tie(ContextIter, Inserted) = Contexts.insert(NewContext);
assert(Inserted && "Failed to insert DeclContext");
(void)Inserted;
>From 294b03ecfef342ef4f6122e294c052f56f4cce8c Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Tue, 18 Nov 2025 12:58:21 +0000
Subject: [PATCH 3/3] [llvm][dsymutil] Use the DW_AT_name of the uniqued DIE
for insertion into .debug_names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The root cause of the issue is that we have a DW_AT_subprogram definition whose DW_AT_specification DIE got deduplicated. But the DW_AT_name of the original specification is different than the one it got uniqued to. That’s technically fine because dsymutil uniques by linkage name, which uniquely identifies any function with non-internal linkage.
But we insert the definition DIE into the debug-names table using the DW_AT_name of the original specification (we call getDIENames(InputDIE…)). But what we really want to do is use the name of the adjusted DW_AT_specifcation (i.e., the DW_AT_specification of the output DIE). That’s not as simple as it sounds because we can’t just get ahold of the DIE in the output CU. We have to grab the ODR DeclContext of the input DIE’s specification. That is the only link back to the canonical specification DIE. For that to be of any use, we have to stash the DW_AT_name into DeclContext so we can use it in getDIENames.
We have to account for the possibility of multiple levels of DW_AT_specification/DW_AT_abstract_origin. So my proposed solution is to recursively scan the referenced DIE’s, grab the canonical DIE for those and get the name from the DeclContext (if none exists then use the DW_AT_name of the DIE itself).
---
.../llvm/DWARFLinker/Classic/DWARFLinker.h | 6 +-
.../Classic/DWARFLinkerDeclContext.h | 9 ++-
llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 76 ++++++++++++++++--
.../Classic/DWARFLinkerDeclContext.cpp | 14 ++--
.../AArch64/dummy-debug-map-arm64.map | 4 +
.../odr-uniquing-DW_AT_name-conflict.test | 28 +++++++
.../odr-uniquing-DW_AT_name-conflict/1.o | Bin 0 -> 2416 bytes
.../odr-uniquing-DW_AT_name-conflict/2.o | Bin 0 -> 2416 bytes
.../odr-uniquing-DW_AT_name-conflict/lib1.cpp | 5 ++
.../odr-uniquing-DW_AT_name-conflict/lib1.h | 3 +
.../odr-uniquing-DW_AT_name-conflict/lib2.cpp | 5 ++
.../odr-uniquing-DW_AT_name-conflict/main.cpp | 6 ++
12 files changed, 139 insertions(+), 17 deletions(-)
create mode 100644 llvm/test/tools/dsymutil/AArch64/odr-uniquing-DW_AT_name-conflict.test
create mode 100644 llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/1.o
create mode 100644 llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/2.o
create mode 100644 llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib1.cpp
create mode 100644 llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib1.h
create mode 100644 llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib2.cpp
create mode 100644 llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/main.cpp
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
index 5b9535380aebf..d6f5d926f022c 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
@@ -708,7 +708,11 @@ class LLVM_ABI DWARFLinker : public DWARFLinkerBase {
/// already there.
/// \returns is a name was found.
bool getDIENames(const DWARFDie &Die, AttributesInfo &Info,
- OffsetsStringPool &StringPool, bool StripTemplate = false);
+ OffsetsStringPool &StringPool, const DWARFFile &File,
+ CompileUnit &Unit, bool StripTemplate = false);
+
+ llvm::StringRef getCanonicalDIEName(DWARFDie Die, const DWARFFile &File,
+ CompileUnit *Unit);
uint32_t hashFullyQualifiedName(DWARFDie DIE, CompileUnit &U,
const DWARFFile &File,
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
index 776d1577b1c98..5ced6d05cc231 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
@@ -84,12 +84,13 @@ class DeclContext {
DeclContext() : DefinedInClangModule(0), Parent(*this) {}
DeclContext(unsigned Hash, uint32_t Line, uint32_t ByteSize, uint16_t Tag,
- StringRef NameForUniquing, StringRef File,
+ StringRef Name, StringRef NameForUniquing, StringRef File,
const DeclContext &Parent, DWARFDie LastSeenDIE = DWARFDie(),
unsigned CUId = 0)
: QualifiedNameHash(Hash), Line(Line), ByteSize(ByteSize), Tag(Tag),
- DefinedInClangModule(0), NameForUniquing(NameForUniquing), File(File),
- Parent(Parent), LastSeenDIE(LastSeenDIE), LastSeenCompileUnitID(CUId) {}
+ DefinedInClangModule(0), Name(Name), NameForUniquing(NameForUniquing),
+ File(File), Parent(Parent), LastSeenDIE(LastSeenDIE),
+ LastSeenCompileUnitID(CUId) {}
uint32_t getQualifiedNameHash() const { return QualifiedNameHash; }
@@ -101,6 +102,7 @@ class DeclContext {
uint32_t getCanonicalDIEOffset() const { return CanonicalDIEOffset; }
void setCanonicalDIEOffset(uint32_t Offset) { CanonicalDIEOffset = Offset; }
+ llvm::StringRef getCanonicalName() const { return Name; }
bool isDefinedInClangModule() const { return DefinedInClangModule; }
void setDefinedInClangModule(bool Val) { DefinedInClangModule = Val; }
@@ -115,6 +117,7 @@ class DeclContext {
uint32_t ByteSize = 0;
uint16_t Tag = dwarf::DW_TAG_compile_unit;
unsigned DefinedInClangModule : 1;
+ StringRef Name;
StringRef NameForUniquing;
StringRef File;
const DeclContext &Parent;
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index 8637b55c78f9c..daf3788639451 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -151,22 +151,84 @@ static bool isTypeTag(uint16_t Tag) {
return false;
}
-bool DWARFLinker::DIECloner::getDIENames(const DWARFDie &Die,
- AttributesInfo &Info,
- OffsetsStringPool &StringPool,
- bool StripTemplate) {
+/// Recurse through the input DIE's canonical references until we find a
+/// DW_AT_name.
+llvm::StringRef
+DWARFLinker::DIECloner::getCanonicalDIEName(DWARFDie Die, const DWARFFile &File,
+ CompileUnit *Unit) {
+ if (!Die)
+ return {};
+
+ std::optional<DWARFFormValue> Ref;
+
+ auto GetDieName = [](const DWARFDie &D) -> llvm::StringRef {
+ auto NameForm = D.find(llvm::dwarf::DW_AT_name);
+ if (!NameForm)
+ return {};
+
+ auto NameOrErr = NameForm->getAsCString();
+ if (!NameOrErr) {
+ llvm::consumeError(NameOrErr.takeError());
+ return {};
+ }
+
+ return *NameOrErr;
+ };
+
+ llvm::StringRef Name = GetDieName(Die);
+ if (!Name.empty())
+ return Name;
+
+ while (true) {
+ if (!(Ref = Die.find(llvm::dwarf::DW_AT_specification)) &&
+ !(Ref = Die.find(llvm::dwarf::DW_AT_abstract_origin)))
+ break;
+
+ Die = Linker.resolveDIEReference(File, CompileUnits, *Ref, Die, Unit);
+ if (!Die)
+ break;
+
+ assert(Unit);
+
+ unsigned SpecIdx = Unit->getOrigUnit().getDIEIndex(Die);
+ CompileUnit::DIEInfo &SpecInfo = Unit->getInfo(SpecIdx);
+ if (SpecInfo.Ctxt && SpecInfo.Ctxt->hasCanonicalDIE()) {
+ if (!SpecInfo.Ctxt->getCanonicalName().empty()) {
+ Name = SpecInfo.Ctxt->getCanonicalName();
+ break;
+ }
+ }
+
+ Name = GetDieName(Die);
+ if (!Name.empty())
+ break;
+ }
+
+ return Name;
+}
+
+bool DWARFLinker::DIECloner::getDIENames(
+ const DWARFDie &Die, AttributesInfo &Info, OffsetsStringPool &StringPool,
+ const DWARFFile &File, CompileUnit &Unit, bool StripTemplate) {
// This function will be called on DIEs having low_pcs and
// ranges. As getting the name might be more expansive, filter out
// blocks directly.
if (Die.getTag() == dwarf::DW_TAG_lexical_block)
return false;
+ // The mangled name of an specification DIE will by virtue of the
+ // uniquing algorithm be the same as the one it got uniqued into.
+ // So just use the input DIE's linkage name.
if (!Info.MangledName)
if (const char *MangledName = Die.getLinkageName())
Info.MangledName = StringPool.getEntry(MangledName);
+ // For subprograms with linkage names, we unique on the linkage name,
+ // so DW_AT_name's may differ between the input and canonical DIEs.
+ // Use the name of the canonical DIE.
if (!Info.Name)
- if (const char *Name = Die.getShortName())
+ if (llvm::StringRef Name = getCanonicalDIEName(Die, File, &Unit);
+ !Name.empty())
Info.Name = StringPool.getEntry(Name);
if (!Info.MangledName)
@@ -1939,7 +2001,7 @@ DIE *DWARFLinker::DIECloner::cloneDIE(const DWARFDie &InputDIE,
// accelerator tables too. For now stick with dsymutil's behavior.
if ((Info.InDebugMap || AttrInfo.HasLowPc || AttrInfo.HasRanges) &&
Tag != dwarf::DW_TAG_compile_unit &&
- getDIENames(InputDIE, AttrInfo, DebugStrPool,
+ getDIENames(InputDIE, AttrInfo, DebugStrPool, File, Unit,
Tag != dwarf::DW_TAG_inlined_subroutine)) {
if (AttrInfo.MangledName && AttrInfo.MangledName != AttrInfo.Name)
Unit.addNameAccelerator(Die, AttrInfo.MangledName,
@@ -1962,7 +2024,7 @@ DIE *DWARFLinker::DIECloner::cloneDIE(const DWARFDie &InputDIE,
} else if (Tag == dwarf::DW_TAG_imported_declaration && AttrInfo.Name) {
Unit.addNamespaceAccelerator(Die, AttrInfo.Name);
} else if (isTypeTag(Tag) && !AttrInfo.IsDeclaration) {
- bool Success = getDIENames(InputDIE, AttrInfo, DebugStrPool);
+ bool Success = getDIENames(InputDIE, AttrInfo, DebugStrPool, File, Unit);
uint64_t RuntimeLang =
dwarf::toUnsigned(InputDIE.find(dwarf::DW_AT_APPLE_runtime_class))
.value_or(0);
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
index 2037a3508df38..66a1ba9c6711f 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
@@ -84,13 +84,14 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
break;
}
+ StringRef Name = DIE.getShortName();
StringRef NameForUniquing;
StringRef FileRef;
if (const char *LinkageName = DIE.getLinkageName())
NameForUniquing = StringPool.internString(LinkageName);
- else if (const char *ShortName = DIE.getShortName())
- NameForUniquing = StringPool.internString(ShortName);
+ else if (!Name.empty())
+ NameForUniquing = StringPool.internString(Name);
bool IsAnonymousNamespace =
NameForUniquing.empty() && Tag == dwarf::DW_TAG_namespace;
@@ -163,15 +164,16 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
Hash = hash_combine(Hash, FileRef);
// Now look if this context already exists.
- DeclContext Key(Hash, Line, ByteSize, Tag, NameForUniquing, FileRef, Context);
+ DeclContext Key(Hash, Line, ByteSize, Tag, Name, NameForUniquing, FileRef,
+ Context);
auto ContextIter = Contexts.find(&Key);
if (ContextIter == Contexts.end()) {
// The context wasn't found.
bool Inserted;
- DeclContext *NewContext =
- new (Allocator) DeclContext(Hash, Line, ByteSize, Tag, NameForUniquing,
- FileRef, Context, DIE, U.getUniqueID());
+ DeclContext *NewContext = new (Allocator)
+ DeclContext(Hash, Line, ByteSize, Tag, Name, NameForUniquing, FileRef,
+ Context, DIE, U.getUniqueID());
std::tie(ContextIter, Inserted) = Contexts.insert(NewContext);
assert(Inserted && "Failed to insert DeclContext");
(void)Inserted;
diff --git a/llvm/test/tools/dsymutil/AArch64/dummy-debug-map-arm64.map b/llvm/test/tools/dsymutil/AArch64/dummy-debug-map-arm64.map
index 50d860290422c..bd2b2014ee22c 100644
--- a/llvm/test/tools/dsymutil/AArch64/dummy-debug-map-arm64.map
+++ b/llvm/test/tools/dsymutil/AArch64/dummy-debug-map-arm64.map
@@ -11,9 +11,13 @@ objects:
- filename: 1.o
symbols:
- { sym: _bar, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }
+ - { sym: __Z13lib1_internalv, objAddr: 0x0, binAddr: 0x10020, size: 0x20 }
+ - { sym: __ZN3Foo4funcIZ13lib1_internalvE3$_0EEvv, objAddr: 0x0, binAddr: 0x10040, size: 0x20 }
- filename: 2.o
symbols:
- { sym: __Z3foov, objAddr: 0x0, binAddr: 0x20000, size: 0x10 }
+ - { sym: __Z13lib1_internalv, objAddr: 0x0, binAddr: 0x20020, size: 0x20 }
+ - { sym: __ZN3Foo4funcIZ13lib1_internalvE3$_0EEvv, objAddr: 0x0, binAddr: 0x20040, size: 0x20 }
- filename: 3.o
symbols:
- { sym: __Z3foov, objAddr: 0x0, binAddr: 0x30000, size: 0x10 }
diff --git a/llvm/test/tools/dsymutil/AArch64/odr-uniquing-DW_AT_name-conflict.test b/llvm/test/tools/dsymutil/AArch64/odr-uniquing-DW_AT_name-conflict.test
new file mode 100644
index 0000000000000..b6edb8bca3194
--- /dev/null
+++ b/llvm/test/tools/dsymutil/AArch64/odr-uniquing-DW_AT_name-conflict.test
@@ -0,0 +1,28 @@
+# Tests the case where a DW_TAG_subprogram for a method declaration
+# got uniqued into a DW_TAG_subprogram with the same linkage name (but
+# different DW_AT_name). Make sure the DW_TAG_subprogram DIE for the
+# definition, which previously pointed to the now de-deduplicated declaration,
+# gets inserted into the .debug_names table using the DW_AT_name of the canonical
+# declaration DW_TAG_subprogram.
+#
+# Object files compiled as follows:
+# clang -g -c -o 1.o Inputs/odr-uniquing-DW_AT_name-conflict/lib1.cpp
+# clang -g -c -o 2.o Inputs/odr-uniquing-DW_AT_name-conflict/lib2.cpp
+
+# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/odr-uniquing-DW_AT_name-conflict -y %p/dummy-debug-map-arm64.map -o - \
+# RUN: | llvm-dwarfdump --verify - | FileCheck %s
+
+# RUN: dsymutil --linker parallel -f -oso-prepend-path=%p/../Inputs/odr-uniquing-DW_AT_name-conflict -y %p/dummy-debug-map-arm64.map -o - \
+# RUN: | not llvm-dwarfdump --verify - | FileCheck %s --check-prefix=PARALLEL-ODR
+
+# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/odr-uniquing-DW_AT_name-conflict -y %p/dummy-debug-map-arm64.map -no-odr -o - \
+# RUN: | llvm-dwarfdump --verify - | FileCheck %s
+
+# RUN: dsymutil --linker parallel -f -oso-prepend-path=%p/../Inputs/odr-uniquing-DW_AT_name-conflict -y %p/dummy-debug-map-arm64.map -no-odr -o - \
+# RUN: | llvm-dwarfdump --verify - | FileCheck %s
+
+# CHECK: No errors.
+
+# FIXME: parallel DWARFLinker uses wrong DW_AT_name when inserting uniqued subprogram into .debug_names
+# PARALLEL-ODR: Verifying .debug_names...
+# PARALLEL-ODR-NEXT: error: Name Index {{.*}} mismatched Name of DIE
diff --git a/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/1.o b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/1.o
new file mode 100644
index 0000000000000000000000000000000000000000..5932a3c89aaeb1b87292f3466bd5550f4c685637
GIT binary patch
literal 2416
zcma)7O>Ep$5T0kRH at oZ7G~I|K1c57I(SqXrNt9NhGzr<Xgrqd00m7dwukCGC?ApuP
zy9H9zpIkuV5{Vvqq6i^Ti9-$`B5^23dZ-{5)MGgT2L$SgpQdHTe%>^@MP#IT^Yi9?
zp7&<n^Y?%Mc4rp=10)(^$iIj<D9A_y$V+7Z2YpTpkP=)*b{G1HQ#6UB>%RTAAL^mK
zFul02Wk*_;D}*PYzLwz0#o$~NLsHi*yVy9T8^vPXZjxPidGdv$t&j-k689Y9`LzN<
z_?8*rm7S7H&UU<OJn~&GH+G2U`E}hbmArPmso=x`4spC$i7Q)zw%?*CKg0`s?Rd)^
zuf*lb4)F}j3IN;je&S#6=NbGO50!PS2cNocevVPKJq&HfyUnB5I9?2!V;ex5sq3a&
ztr at 1TH=NUD$I|t=0$&=4HQtjG+_{c;<ofP^@~e~`o0hca_Xo#2&+-1G=0&;@^<PJR
zVgC`HPDO6(zqfdQ91LOL9mHv)ZQIY|B%O6wzK8H4A|p`{`ETNSf>e?K^C)Fxl0=j`
zF|F-vOLXpl?ykVb<}$moIR&eiyI=#Ce6+bdc?JEe--`N=cc)<EW*7X0GO$?>Q`NL2
zsu#|vzn at j>eS7)_)t<q<ajy at P))=W1{f;WCWAan-I6fny0Hd-jlZk1j*{Ce4ktt~`
z3Ozhv?Zc19Gcc1DReVGwR7P-pq8k-}WQhIq*@20ED}4+-DG7vrQ4OO2-vW?;1;@=`
zA230Tjy?wTDv%|Bf+MRYQy_{G!&8e%5 at Ss2N-!aw!?}3Z2^=w+3YcVjaAdB9<I~6~
zVKpJsV-|*nK`?@j=+=#+{w(rW$k&n6SeriN0pv+!s?{wN2HCY*#a7IU;ha*McHJwx
zj*`!5SuLyV54=P9Tox at Ym&<CS2b9;IEIYnkcZ|xA>%9S$axtfwwHjmysB9WO0(hB4
z)3xlpX4Gn#DHr1%-^rd at Gsc0Ds+G5nHSuX>r|hI!)TqE_RMdty!&W~1r+s5YX_
z at ULo~^(KVNI{ld!J={X3S~iyqyHaeJOPPXu+NrpP<z?!&)i7-<NLi0I0s5=CVcJB?
z(}bh03kx{${4i=GrG{h9bOcQgKc;7=r<+Zn`NR7wMzv at eis38KiHwbm<%bU(0e`9N
zK`)-R6cis7BqbPw;R_t8a8#Fw$R_SVrjD7Ld+B)gV3r!FMNvH6xz{g!EZ#VCXZ*8U
zV13}dFDE~FaF770*i>|C04g{UJ*D{1g}unZo!7*43_Dy%hZ2~IGr)r1V>k-II}-Y7
zu0=|ybzFPy2Wng#w!JmvdJmb7V;&_o{y)1PAc09z(x^Ndte`wZ)VrlegvU{bFMAt9
z&s at AXI{`mjeeU+dSLr<1wP|C0YPfLzm0ia^yk7it9Fs}5KG-WIQ{PBTUWqXYzLwOK
zd_hRy7k1Pr+E#Z5MO_N^gBcFdzEH-gHY61;Q3STZWdY at G42XzSvK8()LN<a#|C1-s
b?q=usEDC+6U5J4leO&RYwH(k$2SxNR3xQzl
literal 0
HcmV?d00001
diff --git a/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/2.o b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/2.o
new file mode 100644
index 0000000000000000000000000000000000000000..607b47059e98275ce59b169e18252ed9bc957a1b
GIT binary patch
literal 2416
zcma)7O>Ep$5T3VQZ}z7&O*bM5LEuWYXhE at eH&I$bX%ez&2}x;01B5?WUfbKO at Y>7T
zy9EO3Pc9&Fi9`=Q6 at -we)I$y+B5^23dZ-{5ggBKGa6mv${4|sq`*}llL1d(P^Yi9?
zp7&<n^Ot}8^w%x`21qo-k$(_ykdToEkeA5*5Bi7}ASJns>@M^Xr)d&N(|qeyKh#5e
zVR~_4%Z{`hR|qeL`dX4F7l(6E3`tEhty1H(rk6@}t4Vh8*~zDlwL&7COWbpq=hq4d
z;ag^eS8>WNIot8B^T^k^+}I(W=hrp2T=v at Wrh*d(ILz^8MXqcK+J1|o{17kjwc{;w
zyfT+7JH*pXGXQMI`;LFTpJ(u6B2?C~9(?Lw^K<m7<zZ+$-fbSe#_{6V9NPfeOieS~
zYE3tMt>K)hIHsn}75UOYtnr?l;Ldf#Bi9%Ilb>C2ELzf at -!B~RJjeTuniuJtsQ)_h
z3;U1oG%9ji|GmQd<4_0#uOUtwZQFhUC+V!i^4)_M5gCbs$bS>p6Qq;^m`9mGCP_r8
z6VuwxwnXO+=*|jkY%a4an^Um*UKecOl6N<kC$FG?^>ab{`py(=-0XtiQ3f{aVX~YR
z1^L1o^3P}Gdf%SDLAhseZ^G-tq!mW$M86{o@>u4P%s4(HLJUSTnGBhjW|oa+1UWKA
zg+-x92F!i<@q`L9SwY4}L_}o-*C)GC0Z4_|-=7_r=r^;+(UTS-)-T9m6yRF`BCz1N
z8SDcV6QZM!1HB4l#X!Q5Ra0pY1d-vX#YK at ZCUzxRERn~#MAu0iF`5dPVta68u8HHL
z$m!T>GDDA97#aq_2s)x$H;($_$e$qJK+a-q`j7{ZCy}XEw@~P0*J`#U8Mf}6mYP=G
ztGJF-$SXM|Cmjg9Lxp?}EhV4NDWeCa7apoOzEyX0d&u=(0=rTwC`PRYDgjjt-A4dV
zT{K+NDkyrbrcSvS at A#ftw3?Rf)~vcZZ|i>9tyewugl?QXwW!p%;~z1ninGylVN at AW
zX82bX&wLreWu1QYX%DxcRx8GmZrP=Vv7{E=Gmh=*rl-~|vtd{!rJUEIO at Q`%et4Uw
z3CCO)7I5OpVbn&-4ab=22$~+=ujQtvn at ynkBL{4~S~7J>_oe7W#zw{p!v~Lozf|#{
z7f)LZijNAC6pX=e6-O!@)g>abiF=T#W9H_bIgvY*qXudb#nZi`JNM$H%fg4Zz<l`I
zUu$oBZ)H;N-#tixQNgJJsNh8Ol;S at Z_96#&UJ<f!?C at ANl)z-10T%oo!!Z`TBcY$>
zS|o*9$F=8vpvJ{v+gn4fH<9T$=22qf|GE1v60{>^RPGN}P#yy6-Qs<*2T+HPdmBTK
zUA#Cu0bgBv;`Y7Q=sei<X?=ZaxOo1#UB}<KQTkvUlS#Ec*ej;epNTB95@#ZOD$421
zg;)~5u%kv%wz``-L|F><gBcFdzECEpHY6o3Q3STmWfA3W42XzSvL)^~N;ZN-|C0yN
b?q=usEDCL>U5J4leQf*HS{`VmgChDH*Q8+8
literal 0
HcmV?d00001
diff --git a/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib1.cpp b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib1.cpp
new file mode 100644
index 0000000000000..4cf90f071ee8c
--- /dev/null
+++ b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib1.cpp
@@ -0,0 +1,5 @@
+#include "lib1.h"
+
+[[gnu::weak]] void lib1_internal() {
+ Foo{}.func<decltype([]{})>();
+}
diff --git a/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib1.h b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib1.h
new file mode 100644
index 0000000000000..3b3cefbaeac17
--- /dev/null
+++ b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib1.h
@@ -0,0 +1,3 @@
+struct Foo {
+ template<typename T> void func() {}
+};
diff --git a/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib2.cpp b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib2.cpp
new file mode 100644
index 0000000000000..4cf90f071ee8c
--- /dev/null
+++ b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/lib2.cpp
@@ -0,0 +1,5 @@
+#include "lib1.h"
+
+[[gnu::weak]] void lib1_internal() {
+ Foo{}.func<decltype([]{})>();
+}
diff --git a/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/main.cpp b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/main.cpp
new file mode 100644
index 0000000000000..77f2cc4c8affe
--- /dev/null
+++ b/llvm/test/tools/dsymutil/Inputs/odr-uniquing-DW_AT_name-conflict/main.cpp
@@ -0,0 +1,6 @@
+[[gnu::weak]] void lib1_internal();
+
+int main() {
+ lib1_internal();
+ __builtin_debugtrap();
+}
More information about the llvm-commits
mailing list