[all-commits] [llvm/llvm-project] fe5d5b: [SelectionDAG] Salvage debuginfo when combining lo...

Shubham Sandeep Rastogi via All-commits all-commits at lists.llvm.org
Thu Apr 9 22:22:40 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fe5d5b762ab3b92b18b56f413965abb81a459ac6
      https://github.com/llvm/llvm-project/commit/fe5d5b762ab3b92b18b56f413965abb81a459ac6
  Author: Shubham Sandeep Rastogi <Shubham.Rastogi at sony.com>
  Date:   2026-04-09 (Thu, 09 Apr 2026)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    A llvm/test/DebugInfo/X86/sdag-load-sext-trunc.ll
    A llvm/test/DebugInfo/X86/sdag-load-sext.ll
    A llvm/test/DebugInfo/X86/sdag-load-zext-multiple-args.ll

  Log Message:
  -----------
  [SelectionDAG] Salvage debuginfo when combining load and z|s ext instrs. (#188544)

Reland 2b958b9ee24b8ea36dcc777b2d1bcfb66c4972b6

Salvage debuginfo when combining load and z|s ext instrs.

SelectionDAG uses the DAGCombiner to fold a load followed by a sext to a
load and sext instruction. For example, in x86 we will see that

```
%1 = load i32, ptr @GlobArr
    #dbg_value(i32 %1, !43, !DIExpression(), !52)
%2 = sext i32 %1 to i64, !dbg !53
```

is converted to:

```
%0:gr64_nosp = MOVSX64rm32 $rip, 1, $noreg, @GlobArr, $noreg, debug-instr-number 1, debug-location !51
DBG_VALUE $noreg, $noreg, !"Idx", !DIExpression(), debug-location !52
```

The `DBG_VALUE` needs to be transferred correctly to the new combined
instruction, and it needs to be appended with a `DIExpression` which
contains a `DW_OP_LLVM_convert` expression, which correctly casts the
value in the virtual register to the correct size.

This patch fixes the above described problem.

The patch also accounts for multiple DW_OP_LLVM_arg's in a DIExpression
which had caused it to break tests on the sanitizer-x86_64-linux bot but
has now been fixed, with an added testcase called
selectionDAG-load-zext-multiple-args.ll which was reduced from the
broken test itself.



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