[PATCH] D21037: Preserve DebugInfo when replacing values in DAGCombiner

Nirav Dave via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 12:53:35 PDT 2016


niravd created this revision.
niravd added a reviewer: jyknight.
niravd added a subscriber: llvm-commits.

[DAG] Previously debug values would transfer debuginfo for the
selected start node for a replacement which allows for dropped debug
information. Push debug value transfer to value replacement.

http://reviews.llvm.org/D21037

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6359,6 +6359,9 @@
     AddModifiedNodeToCSEMaps(User);
   }
 
+  // Preserve Debug Values
+  TransferDbgValues(FromN, To);
+
   // If we just RAUW'd the root, take note.
   if (FromN == getRoot())
     setRoot(To);
@@ -6382,6 +6385,11 @@
   if (From == To)
     return;
 
+  // Preserve Debug Info. Only do this if there's a use.
+  for (unsigned i = 0, e = From->getNumValues(); i != e; ++i)
+    if (From->hasAnyUseOfValue(i))
+      TransferDbgValues(SDValue(From, i), SDValue(To, i));
+
   // Iterate over just the existing users of From. See the comments in
   // the ReplaceAllUsesWith above.
   SDNode::use_iterator UI = From->use_begin(), UE = From->use_end();
@@ -6421,6 +6429,10 @@
   if (From->getNumValues() == 1)  // Handle the simple case efficiently.
     return ReplaceAllUsesWith(SDValue(From, 0), To[0]);
 
+  // Preserve Debug Info.
+  for (unsigned i = 0, e = From->getNumValues(); i != e; ++i)
+    TransferDbgValues(SDValue(From, i), *To);
+
   // Iterate over just the existing users of From. See the comments in
   // the ReplaceAllUsesWith above.
   SDNode::use_iterator UI = From->use_begin(), UE = From->use_end();
@@ -6508,6 +6520,9 @@
     AddModifiedNodeToCSEMaps(User);
   }
 
+  // Preserve Debug Info.
+  TransferDbgValues(From, To);
+
   // If we just RAUW'd the root, take note.
   if (From == getRoot())
     setRoot(To);
@@ -6539,6 +6554,8 @@
   if (Num == 1)
     return ReplaceAllUsesOfValueWith(*From, *To);
 
+  TransferDbgValues(*From, *To);
+
   // Read up all the uses and make records of them. This helps
   // processing new uses that are introduced during the
   // replacement process.
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1331,8 +1331,6 @@
     DEBUG(dbgs() << " ... into: ";
           RV.getNode()->dump(&DAG));
 
-    // Transfer debug value.
-    DAG.TransferDbgValues(SDValue(N, 0), RV);
     if (N->getNumValues() == RV.getNode()->getNumValues())
       DAG.ReplaceAllUsesWith(N, RV.getNode());
     else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21037.59768.patch
Type: text/x-patch
Size: 2348 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160606/73602ab8/attachment.bin>


More information about the llvm-commits mailing list