Skip to content

Commit 853c343

Browse files
authored
[DebugInfo][NewGVN] Salvage debug values of trivially dead instructions (#149304)
fix #149301
1 parent 268c44f commit 853c343

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

llvm/lib/Transforms/Scalar/NewGVN.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3045,6 +3045,7 @@ std::pair<unsigned, unsigned> NewGVN::assignDFSNumbers(BasicBlock *B,
30453045
if (isInstructionTriviallyDead(&I, TLI)) {
30463046
InstrDFS[&I] = 0;
30473047
LLVM_DEBUG(dbgs() << "Skipping trivially dead instruction " << I << "\n");
3048+
salvageDebugInfo(I);
30483049
markInstructionForDeletion(&I);
30493050
continue;
30503051
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; RUN: opt -passes=newgvn -S %s | FileCheck %s
2+
3+
; Check that assignDFSNumbers() in NewGVN salvages the debug values of the
4+
; trivially dead instructions that are marked for deletion.
5+
6+
; CHECK: #dbg_value(i8 %tmp, [[META11:![0-9]+]], !DIExpression(DW_OP_constu, 8, DW_OP_eq, DW_OP_stack_value), [[META26:![0-9]+]])
7+
; CHECK: [[META11]] = !DILocalVariable(name: "2"
8+
; CHECK: [[META26]] = !DILocation(line: 2
9+
10+
define void @test13() !dbg !5 {
11+
entry:
12+
%tmp = load i8, ptr null, align 1
13+
%tmp2 = icmp eq i8 %tmp, 8, !dbg !13
14+
#dbg_value(i1 %tmp2, !11, !DIExpression(), !13)
15+
ret void
16+
}
17+
18+
!llvm.dbg.cu = !{!0}
19+
!llvm.debugify = !{!2, !3}
20+
!llvm.module.flags = !{!4}
21+
22+
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
23+
!1 = !DIFile(filename: "/app/example.ll", directory: "/")
24+
!2 = !{i32 3}
25+
!3 = !{i32 2}
26+
!4 = !{i32 2, !"Debug Info Version", i32 3}
27+
!5 = distinct !DISubprogram(name: "test13", linkageName: "test13", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
28+
!6 = !DISubroutineType(types: !7)
29+
!7 = !{}
30+
!8 = !{!11}
31+
!10 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned)
32+
!11 = !DILocalVariable(name: "2", scope: !5, file: !1, line: 2, type: !10)
33+
!13 = !DILocation(line: 2, column: 1, scope: !5)

0 commit comments

Comments
 (0)