[PATCH] D43220: [DeadStoreElimination] Salvage debug info from dead insts

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 10:17:34 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL325035: [DeadStoreElimination] Salvage debug info from dead insts (authored by vedantk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43220?vs=133987&id=134077#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43220

Files:
  llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
  llvm/trunk/test/Transforms/DeadStoreElimination/debuginfo.ll


Index: llvm/trunk/test/Transforms/DeadStoreElimination/debuginfo.ll
===================================================================
--- llvm/trunk/test/Transforms/DeadStoreElimination/debuginfo.ll
+++ llvm/trunk/test/Transforms/DeadStoreElimination/debuginfo.ll
@@ -0,0 +1,40 @@
+; RUN: opt < %s -debugify -basicaa -dse -S | FileCheck %s
+
+target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
+
+declare noalias i8* @malloc(i32)
+
+declare void @test_f()
+
+define i32* @test_salvage() {
+; CHECK-LABEL: @test_salvage()
+; CHECK-NEXT: malloc
+; CHECK-NEXT: bitcast
+; CHECK-NEXT: call void @test_f()
+; CHECK-NEXT: store i32 0, i32* %P
+
+; Check that all four original local variables have their values preserved.
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i8* %p, metadata !8, metadata !DIExpression()), !dbg !14
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !10, metadata !DIExpression()), !dbg !15
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !11, metadata !DIExpression(DW_OP_deref)), !dbg !18
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !13, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !19
+  %p = tail call i8* @malloc(i32 4)
+  %P = bitcast i8* %p to i32*
+  %DEAD = load i32, i32* %P
+  %DEAD2 = add i32 %DEAD, 1
+  store i32 %DEAD2, i32* %P
+  call void @test_f()
+  store i32 0, i32* %P
+  ret i32* %P
+}
+
+; 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: !9)
+; CHECK: !11 = !DILocalVariable(name: "3", scope: !5, file: !1, line: 3, type: !12)
+; CHECK: !13 = !DILocalVariable(name: "4", scope: !5, file: !1, line: 4, type: !12)
+; CHECK-DAG: !14 = !DILocation(line: 1, column: 1, scope: !5)
+; CHECK-DAG: !15 = !DILocation(line: 2, column: 1, scope: !5)
+; CHECK-DAG: !18 = !DILocation(line: 3, column: 1, scope: !5)
+; CHECK-DAG: !19 = !DILocation(line: 4, column: 1, scope: !5)
+; CHECK-DAG: !16 = !DILocation(line: 6, column: 1, scope: !5)
+; CHECK-DAG: !17 = !DILocation(line: 7, column: 1, scope: !5)
Index: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -115,6 +115,9 @@
     Instruction *DeadInst = NowDeadInsts.pop_back_val();
     ++NumFastOther;
 
+    // Try to preserve debug information attached to the dead instruction.
+    salvageDebugInfo(*DeadInst);
+
     // This instruction is dead, zap it, in stages.  Start by removing it from
     // MemDep, which needs to know the operands and needs it to be in the
     // function.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43220.134077.patch
Type: text/x-patch
Size: 2873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180213/5e3032f0/attachment.bin>


More information about the llvm-commits mailing list