[llvm] [DebugInfo][NewGVN] Salvage debug values of trivially dead instructions (PR #149304)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 06:30:00 PDT 2025
================
@@ -0,0 +1,58 @@
+; RUN: opt -passes=newgvn -S %s | FileCheck %s
+
+; Check that assignDFSNumbers() in NewGVN salvages the debug values of the
+; trivially dead instructions that are marked for deletion.
+
+; CHECK: #dbg_value(i8 %tmp, [[META11:![0-9]+]], !DIExpression(DW_OP_constu, 8, DW_OP_eq, DW_OP_stack_value), [[META26:![0-9]+]])
+; CHECK: [[META11]] = !DILocalVariable(name: "2"
+; CHECK: [[META26]] = !DILocation(line: 3
+
+define void @test13() !dbg !5 {
+bb:
+ br label %bb1
+
+bb1:
+ %tmp = load i8, ptr null, align 1
+ %tmp2 = icmp eq i8 %tmp, 8, !dbg !26
+ #dbg_value(i1 %tmp2, !11, !DIExpression(), !26)
+ br label %bb3
+
+bb3:
----------------
OCHyams wrote:
Do we need all the instructions below, or is the following sufficient to exercise the behaviour?
```llvm
define void @test13() !dbg !5 {
entry:
%tmp = load i8, ptr null, align 1
%tmp2 = icmp eq i8 %tmp, 8, !dbg !26
#dbg_value(i1 %tmp2, !11, !DIExpression(), !26)
ret void
}
```
If you do need the extra instructions, I think you'll want to replace the `undef` with `poison`.
https://github.com/llvm/llvm-project/pull/149304
More information about the llvm-commits
mailing list