[llvm] r324974 - [Utils] Salvage the debug info of DCE'ed 'sub' instructions
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 12 17:09:47 PST 2018
Author: vedantk
Date: Mon Feb 12 17:09:47 2018
New Revision: 324974
URL: http://llvm.org/viewvc/llvm-project?rev=324974&view=rev
Log:
[Utils] Salvage the debug info of DCE'ed 'sub' instructions
This salvages 14 debug values in a stage2 build of clang.
Modified:
llvm/trunk/lib/Transforms/Utils/Local.cpp
llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=324974&r1=324973&r2=324974&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Mon Feb 12 17:09:47 2018
@@ -1546,6 +1546,9 @@ void llvm::salvageDebugInfo(Instruction
case Instruction::Add:
applyOffset(DII, Val);
break;
+ case Instruction::Sub:
+ applyOffset(DII, -int64_t(Val));
+ break;
case Instruction::Or:
applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_or});
break;
Modified: llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll?rev=324974&r1=324973&r2=324974&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll Mon Feb 12 17:09:47 2018
@@ -24,6 +24,20 @@ define void @test_xor(i32 %A) {
ret void
}
+define void @test_sub_neg(i64 %A) {
+; CHECK-LABEL: @test_sub_neg(
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !27, metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !28
+ %1 = sub i64 %A, -1
+ ret void
+}
+
+define void @test_sub_pos(i64 %A) {
+; CHECK-LABEL: @test_sub_pos(
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !32, metadata !DIExpression(DW_OP_constu, 1, DW_OP_minus, DW_OP_stack_value)), !dbg !33
+ %1 = sub i64 %A, 1
+ ret void
+}
+
; CHECK: !8 = !DILocalVariable(name: "1", scope: !5, file: !1, line: 1, type: !9)
; CHECK: !10 = !DILocalVariable(name: "2", scope: !5, file: !1, line: 2, type: !11)
; CHECK: !12 = !DILocation(line: 2, column: 1, scope: !5)
@@ -34,3 +48,9 @@ define void @test_xor(i32 %A) {
; CHECK: !22 = !DILocalVariable(name: "4", scope: !20, file: !1, line: 6, type: !9)
; CHECK: !23 = !DILocation(line: 6, column: 1, scope: !20)
+
+; CHECK: !27 = !DILocalVariable(name: "5", scope: !25, file: !1, line: 8, type: !11)
+; CHECK: !28 = !DILocation(line: 8, column: 1, scope: !25)
+
+; CHECK: !32 = !DILocalVariable(name: "6", scope: !30, file: !1, line: 10, type: !11)
+; CHECK: !33 = !DILocation(line: 10, column: 1, scope: !30)
More information about the llvm-commits
mailing list