[PATCH] D110462: Improve the effectiveness of ADCE's debug info salvaging

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 28 10:25:29 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9637b045e6ee: Improve the effectiveness of ADCE's debug info salvaging (authored by aprantl).

Changed prior to commit:
  https://reviews.llvm.org/D110462?vs=374999&id=375636#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110462/new/

https://reviews.llvm.org/D110462

Files:
  llvm/lib/Transforms/Scalar/ADCE.cpp
  llvm/test/Transforms/Util/salvage-debuginfo.ll


Index: llvm/test/Transforms/Util/salvage-debuginfo.ll
===================================================================
--- llvm/test/Transforms/Util/salvage-debuginfo.ll
+++ llvm/test/Transforms/Util/salvage-debuginfo.ll
@@ -5,8 +5,10 @@
 entry:
   %p_x = inttoptr i32 %0 to i8*
   %i_x = ptrtoint i8* %p_x to i32
-  ; CHECK: call void @llvm.dbg.value(metadata i8* undef,
-  ; CHECK-SAME: !DIExpression(DW_OP_LLVM_convert, 64, DW_ATE_unsigned,
+  ; CHECK: call void @llvm.dbg.value(metadata i32 %0,
+  ; CHECK-SAME: !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_unsigned,
+  ; CHECK-SAME:               DW_OP_LLVM_convert, 64, DW_ATE_unsigned,
+  ; CHECK-SAME:               DW_OP_LLVM_convert, 64, DW_ATE_unsigned,
   ; CHECK-SAME:               DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value))
   call void @llvm.dbg.value(metadata i32 %i_x, metadata !11, metadata !DIExpression()), !dbg !13
   ret void, !dbg !13
Index: llvm/lib/Transforms/Scalar/ADCE.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/ADCE.cpp
+++ llvm/lib/Transforms/Scalar/ADCE.cpp
@@ -538,7 +538,7 @@
   // that have no side effects and do not influence the control flow or return
   // value of the function, and may therefore be deleted safely.
   // NOTE: We reuse the Worklist vector here for memory efficiency.
-  for (Instruction &I : instructions(F)) {
+  for (Instruction &I : llvm::reverse(instructions(F))) {
     // Check if the instruction is alive.
     if (isLive(&I))
       continue;
@@ -554,9 +554,11 @@
     // Prepare to delete.
     Worklist.push_back(&I);
     salvageDebugInfo(I);
-    I.dropAllReferences();
   }
 
+  for (Instruction *&I : Worklist)
+    I->dropAllReferences();
+
   for (Instruction *&I : Worklist) {
     ++NumRemoved;
     I->eraseFromParent();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110462.375636.patch
Type: text/x-patch
Size: 1829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210928/9856fc96/attachment.bin>


More information about the llvm-commits mailing list