diff options
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/IR/DebugInfoMetadata.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 9 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/debuginfo-variables.ll | 30 |
4 files changed, 45 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index 889250ed803..885e588982c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -347,6 +347,9 @@ void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor, case dwarf::DW_OP_mul: case dwarf::DW_OP_or: case dwarf::DW_OP_xor: + case dwarf::DW_OP_shl: + case dwarf::DW_OP_shr: + case dwarf::DW_OP_shra: emitOp(Op->getOp()); break; case dwarf::DW_OP_deref: diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 91b965cb7e0..fc3d344a11c 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -710,6 +710,9 @@ bool DIExpression::isValid() const { case dwarf::DW_OP_mul: case dwarf::DW_OP_or: case dwarf::DW_OP_xor: + case dwarf::DW_OP_shl: + case dwarf::DW_OP_shr: + case dwarf::DW_OP_shra: case dwarf::DW_OP_deref: case dwarf::DW_OP_xderef: break; diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 379b6bf1311..1340e12c5c6 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1555,6 +1555,15 @@ void llvm::salvageDebugInfo(Instruction &I) { case Instruction::Xor: applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_xor}); break; + case Instruction::Shl: + applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_shl}); + break; + case Instruction::LShr: + applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_shr}); + break; + case Instruction::AShr: + applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_shra}); + break; default: // TODO: Salvage constants from each kind of binop we know about. continue; diff --git a/llvm/test/Transforms/InstCombine/debuginfo-variables.ll b/llvm/test/Transforms/InstCombine/debuginfo-variables.ll index fec0de76339..09999c18607 100644 --- a/llvm/test/Transforms/InstCombine/debuginfo-variables.ll +++ b/llvm/test/Transforms/InstCombine/debuginfo-variables.ll @@ -38,6 +38,27 @@ define void @test_sub_pos(i64 %A) { ret void } +define void @test_shl(i64 %A) { +; CHECK-LABEL: @test_shl( +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !37, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shl, DW_OP_stack_value)), !dbg !38 + %1 = shl i64 %A, 7 + ret void +} + +define void @test_lshr(i64 %A) { +; CHECK-LABEL: @test_lshr( +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !42, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shr, DW_OP_stack_value)), !dbg !43 + %1 = lshr i64 %A, 7 + ret void +} + +define void @test_ashr(i64 %A) { +; CHECK-LABEL: @test_ashr( +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !47, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shra, DW_OP_stack_value)), !dbg !48 + %1 = ashr i64 %A, 7 + 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) @@ -54,3 +75,12 @@ define void @test_sub_pos(i64 %A) { ; CHECK: !32 = !DILocalVariable(name: "6", scope: !30, file: !1, line: 10, type: !11) ; CHECK: !33 = !DILocation(line: 10, column: 1, scope: !30) + +; CHECK: !37 = !DILocalVariable(name: "7", scope: !35, file: !1, line: 12, type: !11) +; CHECK: !38 = !DILocation(line: 12, column: 1, scope: !35) + +; CHECK: !42 = !DILocalVariable(name: "8", scope: !40, file: !1, line: 14, type: !11) +; CHECK: !43 = !DILocation(line: 14, column: 1, scope: !40) + +; CHECK: !47 = !DILocalVariable(name: "9", scope: !45, file: !1, line: 16, type: !11) +; CHECK: !48 = !DILocation(line: 16, column: 1, scope: !45) |

