[all-commits] [llvm/llvm-project] 906916: [llvm][DebugInfo] Avoid attaching retained nodes t...

Vladislav Dzhidzhoev via All-commits all-commits at lists.llvm.org
Mon Feb 9 07:24:04 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 90691641e6419c285671f183628a0e16792df43c
      https://github.com/llvm/llvm-project/commit/90691641e6419c285671f183628a0e16792df43c
  Author: Vladislav Dzhidzhoev <vdzhidzhoev at accesssoftek.com>
  Date:   2026-02-09 (Mon, 09 Feb 2026)

  Changed paths:
    A clang/test/DebugInfo/CXX/ctor-homing-local-type.cpp
    M llvm/lib/IR/DIBuilder.cpp
    M llvm/unittests/IR/IRBuilderTest.cpp

  Log Message:
  -----------
  [llvm][DebugInfo] Avoid attaching retained nodes to unrelated subprograms in DIBuilder (#180294)

Fix a regression introduced by
https://github.com/llvm/llvm-project/pull/165032, where DIBuilder could
attach local metadata nodes to the wrong subprogram during finalization.

DIBuilder records freshly created local variables, labels, and types in
`DIBuilder::SubprogramTrackedNodes`, and later attaches them to their
parent subprogram's retainedNodes in `finalizeSubprogram()`.

However, a temporary local type created via
`createReplaceableCompositeType()` may later be replaced by a type with
a different scope.
DIBuilder does not currently verify that the scopes of the original and
replacement types match.

As a result, local types can be incorrectly attached to the
retainedNodes of an unrelated subprogram. This issue is observable in
clang with limited debug info mode (see
`clang/test/DebugInfo/CXX/ctor-homing-local-type.cpp`).

This patch updates `DIBuilder::finalizeSubprogram()` to verify that
tracked metadata nodes still belong to the subprogram being finalized,
and avoids adding nodes whose scopes no longer match to retainedNodes
field of an unrelated subprogram.



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