[llvm] r325119 - [Utils] Salvage the debug info of DCE'ed 'and' instructions
Petar Jovanovic via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 14 05:10:35 PST 2018
Author: petarj
Date: Wed Feb 14 05:10:35 2018
New Revision: 325119
URL: http://llvm.org/viewvc/llvm-project?rev=325119&view=rev
Log:
[Utils] Salvage the debug info of DCE'ed 'and' instructions
Preserve debug info from a dead 'and' instruction with a constant.
Patch by Djordje Todorovic.
Differential Revision: https://reviews.llvm.org/D43163
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
llvm/trunk/lib/IR/DebugInfoMetadata.cpp
llvm/trunk/lib/Transforms/Utils/Local.cpp
llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.cpp?rev=325119&r1=325118&r2=325119&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfExpression.cpp Wed Feb 14 05:10:35 2018
@@ -352,6 +352,7 @@ void DwarfExpression::addExpression(DIEx
case dwarf::DW_OP_div:
case dwarf::DW_OP_mod:
case dwarf::DW_OP_or:
+ case dwarf::DW_OP_and:
case dwarf::DW_OP_xor:
case dwarf::DW_OP_shl:
case dwarf::DW_OP_shr:
Modified: llvm/trunk/lib/IR/DebugInfoMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=325119&r1=325118&r2=325119&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfoMetadata.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfoMetadata.cpp Wed Feb 14 05:10:35 2018
@@ -711,6 +711,7 @@ bool DIExpression::isValid() const {
case dwarf::DW_OP_div:
case dwarf::DW_OP_mod:
case dwarf::DW_OP_or:
+ case dwarf::DW_OP_and:
case dwarf::DW_OP_xor:
case dwarf::DW_OP_shl:
case dwarf::DW_OP_shr:
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=325119&r1=325118&r2=325119&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Feb 14 05:10:35 2018
@@ -1564,6 +1564,9 @@ void llvm::salvageDebugInfo(Instruction
case Instruction::Or:
applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_or});
break;
+ case Instruction::And:
+ applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_and});
+ break;
case Instruction::Xor:
applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_xor});
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=325119&r1=325118&r2=325119&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll Wed Feb 14 05:10:35 2018
@@ -87,6 +87,13 @@ define void @test_ptrtoint(i64* %P) {
ret void
}
+define void @test_and(i64 %A) {
+; CHECK-LABEL: @test_and(
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !72, metadata !DIExpression(DW_OP_constu, 256, DW_OP_and, DW_OP_stack_value)), !dbg !73
+ %1 = and i64 %A, 256
+ 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)
@@ -124,3 +131,6 @@ define void @test_ptrtoint(i64* %P) {
; CHECK: !67 = !DILocalVariable(name: "13", scope: !65, file: !1, line: 24, type: !11)
; CHECK: !68 = !DILocation(line: 24, column: 1, scope: !65)
+
+; CHECK: !72 = !DILocalVariable(name: "14", scope: !70, file: !1, line: 26, type: !11)
+; CHECK: !73 = !DILocation(line: 26, column: 1, scope: !70)
More information about the llvm-commits
mailing list