[llvm] [dsymutil] Test qualified name hashing for members (PR #223017)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 12:02:55 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Jonas Devlieghere (JDevlieghere)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/223017.diff
3 Files Affected:
- (added) llvm/test/tools/dsymutil/Inputs/member-hash/2.o ()
- (added) llvm/test/tools/dsymutil/Inputs/member-hash/debug-map.map (+8)
- (added) llvm/test/tools/dsymutil/X86/member-hash.cpp (+40)
``````````diff
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 0000000000000..c43f9119501fe
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/member-hash/2.o differ
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:]
``````````
</details>
https://github.com/llvm/llvm-project/pull/223017
More information about the llvm-commits
mailing list