[llvm] [dsymutil] Test qualified name hashing for members (PR #223017)

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 12:02:14 PDT 2026


https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/223017

hashFullyQualifiedName walks DW_AT_specification to reach a member's enclosing struct, so the accelerator table entry for a type nested in an out-of-line member function definition depends on that walk. Pin the resulting hash.

The test has lived downstream since the fix that made the function take its DWARFDie by value instead of by pointer, where the pointee went out of scope during the walk. Give it a debug map of its own describing member-hash/2.o rather than extending the shared dummy-debug-map.map, which describes a different set of objects.

rdar://184990209

>From a3d2fe916a9fff97e2253497dfc5d29965749ab3 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 11 Sep 2026 11:47:26 -0700
Subject: [PATCH] [dsymutil] Test qualified name hashing for members

hashFullyQualifiedName walks DW_AT_specification to reach a member's
enclosing struct, so the accelerator table entry for a type nested in
an out-of-line member function definition depends on that walk. Pin the
resulting hash.

The test has lived downstream since the fix that made the function take
its DWARFDie by value instead of by pointer, where the pointee went out
of scope during the walk. Give it a debug map of its own describing
member-hash/2.o rather than extending the shared dummy-debug-map.map,
which describes a different set of objects.
---
 .../tools/dsymutil/Inputs/member-hash/2.o     | Bin 0 -> 2624 bytes
 .../dsymutil/Inputs/member-hash/debug-map.map |   8 ++++
 llvm/test/tools/dsymutil/X86/member-hash.cpp  |  40 ++++++++++++++++++
 3 files changed, 48 insertions(+)
 create mode 100644 llvm/test/tools/dsymutil/Inputs/member-hash/2.o
 create mode 100644 llvm/test/tools/dsymutil/Inputs/member-hash/debug-map.map
 create mode 100644 llvm/test/tools/dsymutil/X86/member-hash.cpp

diff --git a/llvm/test/tools/dsymutil/Inputs/member-hash/2.o b/llvm/test/tools/dsymutil/Inputs/member-hash/2.o
new file mode 100644
index 0000000000000000000000000000000000000000..c43f9119501fe99437ec1d3f64a4d0480a9fafb9
GIT binary patch
literal 2624
zcmb7FU1%It6h1Svv)Sw<l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Y?v7ur0{q at gbU4c?uoHiKu
zLzN|d#|6G&AnQwxjW8?;a2${M=>l`*Yr;ALW#O1Y{$tH&a0jyKZWy1v`_b*+GQ~B%
zw9C*cl<_%-f17VZS$JKH!7&!*!G16v%*!#B at Vq?V|H%pX-{- at LwJ?8;bd-c|m%j#{
z at 2_hrZA0@HH;g&>7L@<iVmHw{&_hs&C=+_#GMo<<t_`E`{!c&$g{uS!mgReB`>V3s
zc)(kE>kKLD2_-Qy6x#v{&+s5L|1a;z&W^+<nl=-c)#pe33i)|6$V<sQuD*~^o`;}H
ze9RQ(A9Iw?AajK(`@P&m;oB`%JKTG!#&tFRy-ug}Nc=lpd0idGED!mUO!9vM>Cr{m
hKP>yS?9qwwH)YSzV`zf?i%TD!FIMnEz_{~((0_3cL at NLQ

literal 0
HcmV?d00001

diff --git a/llvm/test/tools/dsymutil/Inputs/member-hash/debug-map.map b/llvm/test/tools/dsymutil/Inputs/member-hash/debug-map.map
new file mode 100644
index 0000000000000..644ebc2a37b31
--- /dev/null
+++ b/llvm/test/tools/dsymutil/Inputs/member-hash/debug-map.map
@@ -0,0 +1,8 @@
+---
+triple:          'x86_64-apple-darwin'
+objects:
+  - filename: 2.o
+    symbols:
+      - { sym: __ZN1S3fooEv, objAddr: 0x0, binAddr: 0x1000, size: 0xf }
+      - { sym: __Z3foov, objAddr: 0x10, binAddr: 0x1010, size: 0x1a }
+...
diff --git a/llvm/test/tools/dsymutil/X86/member-hash.cpp b/llvm/test/tools/dsymutil/X86/member-hash.cpp
new file mode 100644
index 0000000000000..f4230dbc41096
--- /dev/null
+++ b/llvm/test/tools/dsymutil/X86/member-hash.cpp
@@ -0,0 +1,40 @@
+// Check that dsymutil's accelerator table hashing walks DW_AT_specification to
+// build a member's fully qualified name. The typedef below is nested in a
+// member function whose definition only reaches the enclosing struct through
+// DW_AT_specification.
+//
+// Compile with:
+//   clang -g -c member-hash.cpp -o member-hash/2.o
+
+// RUN: dsymutil --linker classic -oso-prepend-path %p/../Inputs/member-hash \
+// RUN:   -y -f %p/../Inputs/member-hash/debug-map.map -o - \
+// RUN:   | llvm-dwarfdump -apple-types - | FileCheck %s
+
+// RUN: dsymutil --linker parallel -oso-prepend-path %p/../Inputs/member-hash \
+// RUN:   -y -f %p/../Inputs/member-hash/debug-map.map -o - \
+// RUN:   | llvm-dwarfdump -apple-types - | FileCheck %s
+
+struct S {
+  int foo();
+};
+
+int S::foo() {
+  typedef int T;
+  return (T)42;
+}
+
+void foo() {
+  S s;
+  s.foo();
+}
+
+// The DIE and string offsets differ between the two linkers; the hash in
+// Atom[3] is what this test pins down.
+
+// CHECK: String: 0x{{[0-9a-f]+}} "T"
+// CHECK-NEXT: Data 0 [
+// CHECK-NEXT:  Atom[0]: 0x{{[0-9a-f]+}}
+// CHECK-NEXT:  Atom[1]: 0x0016
+// CHECK-NEXT:  Atom[2]: 0x00
+// CHECK-NEXT:  Atom[3]: 0xa415d958
+// CHECK-NEXT:]



More information about the llvm-commits mailing list