[all-commits] [llvm/llvm-project] 8ac8e6: [dsymutil] Fix linker's ODR uniquing for typedefs ...

Peter Rong via All-commits all-commits at lists.llvm.org
Wed May 6 11:56:38 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8ac8e6fc1645f73fbb0a82364980576c5fa2bb67
      https://github.com/llvm/llvm-project/commit/8ac8e6fc1645f73fbb0a82364980576c5fa2bb67
  Author: Peter Rong <peterrong96 at gmail.com>
  Date:   2026-05-06 (Wed, 06 May 2026)

  Changed paths:
    M llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
    A llvm/test/tools/dsymutil/AArch64/typedef-different-types.test

  Log Message:
  -----------
  [dsymutil] Fix linker's ODR uniquing for typedefs with different underlying types (#195749)

The classic DWARF linker's `DeclContext` uniquing for `typedef` only
considers the typedef's name, file, and line — not the type it refers
to. When two `typedef` share the same name and source location but point
to different underlying types (e.g. due to clang's `preferred_name`
attribute generating a second typedef), they get the same `DeclContext`.
ODR deduplication then merges them, which can produce incorrect type
references or self-referencing typedef cycles in the output DWARF.

The self-referencing cycles are latent until a consumer follows
`DW_AT_type` chains through typedefs.
In particular, `unwrapReferencedTypedefType()` (introduced in
[#168734](https://github.com/llvm/llvm-project/pull/168734)) caused an
infinite recursion and eventual stack overflow.

Fix this by including the `DW_AT_type` target's tag and name in the
`NameForUniquing`, such that `typedef` with different underlying types
get distinct `DeclContexts`. This mirrors the parallel linker fix in
https://github.com/llvm/llvm-project/pull/166767

Added a test for validation

[Assisted-by](https://t.ly/Dkjjk): [Claude Opus
4.6](https://www.anthropic.com/news/claude-opus-4-6)

---------

Signed-off-by: Peter Rong <PeterRong at meta.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list