[llvm] [DWARFLinker] Index Swift mangled type names in the parallel linker (PR #216429)
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 14 19:31:26 PDT 2026
================
@@ -0,0 +1,213 @@
+# A Swift type's mangled name, from DW_AT_linkage_name, is indexed as a type
+# name alongside the short DW_AT_name by both linkers.
+
+# RUN: llvm-mc -triple x86_64-apple-darwin -filetype=obj %s -o %t.o
+# RUN: llvm-dwarfdump --verify %t.o
+
+# RUN: echo '---' > %t.map
+# RUN: echo "triple: 'x86_64-apple-darwin'" >> %t.map
+# RUN: echo 'objects:' >> %t.map
+# RUN: echo " - filename: '%t.o'" >> %t.map
+# RUN: echo ' symbols:' >> %t.map
+# RUN: echo ' - { sym: _foo, objAddr: 0x0, binAddr: 0x10000, size: 0x1 }' >> %t.map
+# RUN: echo '...' >> %t.map
+
+# RUN: dsymutil --linker=parallel -accelerator=Dwarf -y %t.map -f -o %t.parallel.dSYM
+# RUN: llvm-dwarfdump --verify %t.parallel.dSYM
+# RUN: llvm-dwarfdump --debug-names %t.parallel.dSYM > %t.parallel.names
+
+# RUN: dsymutil --linker=classic -accelerator=Dwarf -y %t.map -f -o %t.classic.dSYM
+# RUN: llvm-dwarfdump --verify %t.classic.dSYM
+# RUN: llvm-dwarfdump --debug-names %t.classic.dSYM > %t.classic.names
+
+# The qualified name hash reaches only the Apple tables.
+
+# RUN: dsymutil --linker=parallel -accelerator=Apple -y %t.map -f -o %t.parallel.apple.dSYM
+# RUN: llvm-dwarfdump --apple-types %t.parallel.apple.dSYM > %t.parallel.apple
+
+# RUN: dsymutil --linker=classic -accelerator=Apple -y %t.map -f -o %t.classic.apple.dSYM
+# RUN: llvm-dwarfdump --apple-types %t.classic.apple.dSYM > %t.classic.apple
+
+# One FileCheck run per name, so that no prefix depends on the bucket a linker
+# assigns to the other names.
+
+# RUN: FileCheck %s --check-prefix=MANGLED --input-file %t.parallel.names
+# RUN: FileCheck %s --check-prefix=MANGLED --input-file %t.classic.names
+# RUN: FileCheck %s --check-prefix=SHORT --input-file %t.parallel.names
+# RUN: FileCheck %s --check-prefix=SHORT --input-file %t.classic.names
+# RUN: FileCheck %s --check-prefix=SPEC --input-file %t.parallel.names
+# RUN: FileCheck %s --check-prefix=SPEC --input-file %t.classic.names
+# RUN: FileCheck %s --check-prefix=DEDUP --input-file %t.parallel.names
+# RUN: FileCheck %s --check-prefix=DEDUP --input-file %t.classic.names
+# RUN: FileCheck %s --check-prefix=APPLE --input-file %t.parallel.apple
+# RUN: FileCheck %s --check-prefix=APPLE --input-file %t.classic.apple
+
+# The tag is checked so that the entry is known to describe the type rather
+# than another DIE carrying the same string.
+
+# MANGLED: String: {{.*}} "$sSSD"
+# MANGLED-NEXT: Entry @
+# MANGLED-NEXT: Abbrev:
+# MANGLED-NEXT: Tag: DW_TAG_structure_type
+
+# SHORT: String: {{.*}} "String"
+# SHORT-NEXT: Entry @
+# SHORT-NEXT: Abbrev:
+# SHORT-NEXT: Tag: DW_TAG_structure_type
+
+# A mangled name reachable only through DW_AT_specification.
+
+# SPEC: String: {{.*}} "$sSpecD"
+# SPEC-NEXT: Entry @
+# SPEC-NEXT: Abbrev:
+# SPEC-NEXT: Tag: DW_TAG_structure_type
+
+# A type whose two names are equal is indexed once.
+
+# DEDUP: String: {{.*}} "Same"
+# DEDUP-NOT: String: {{.*}} "Same"
+
+# Atom[3] is djbHash of the mangled name, not the qualified name hash that the
+# short name records.
+
+# APPLE: String: {{.*}} "$sSSD"
+# APPLE-NEXT: Data 0 [
+# APPLE-NEXT: Atom[0]:
+# APPLE-NEXT: Atom[1]: 0x0013 (DW_TAG_structure_type)
+# APPLE-NEXT: Atom[2]: 0x00
+# APPLE-NEXT: Atom[3]: 0x0acaede6
+
+ .section __TEXT,__text,regular,pure_instructions
+ .globl _foo
+_foo:
+Lfunc_begin0:
+ retq
+Lfunc_end0:
+
+ .section __DWARF,__debug_abbrev,regular,debug
+Lsection_abbrev:
+ .byte 1 ## Abbreviation Code
----------------
JDevlieghere wrote:
We have a good mix of both. In this case, I went with assembly because the DWARF (specifically the attributes) is more readable that way, compared to yaml where you have to manually follow the abbrevs.
https://github.com/llvm/llvm-project/pull/216429
More information about the llvm-commits
mailing list