[PATCH] D41864: DBG_VALUE insertion for spills breaks bundles

Saurabh Verma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 09:32:46 PST 2018


saurabhverma updated this revision to Diff 129108.
saurabhverma added a comment.

Adding descriptive comment for the change


https://reviews.llvm.org/D41864

Files:
  lib/CodeGen/LiveDebugValues.cpp


Index: lib/CodeGen/LiveDebugValues.cpp
===================================================================
--- lib/CodeGen/LiveDebugValues.cpp
+++ lib/CodeGen/LiveDebugValues.cpp
@@ -672,9 +672,23 @@
                                 /*transferSpills=*/true);
 
         // Add any DBG_VALUE instructions necessitated by spills.
-        for (auto &SP : Spills)
-          MBB->insertAfter(MachineBasicBlock::iterator(*SP.SpillInst),
-                           SP.DebugInst);
+        for (auto &SP : Spills){
+          MachineInstr *InsertPoint = SP.SpillInst;
+          MachineInstr *DebugInst = SP.DebugInst;
+          MBB->insertAfter(MachineBasicBlock::iterator(*InsertPoint),
+                           DebugInst);
+          // If the spill is part of an instruction bundle, we need to make sure
+          // that the newly inserted DBG_VALUE instruction also has the bundle
+          // flags set. Otherwise we might end up with incorrect sequences like:
+          //
+          //        MI1 [BundledSucc=true, BundledPred=false]
+          //        DBG_VALUE MI [BundledSucc=false, BundledPred=false]
+          //        MI2 [BundledSucc=false, BundledPred=true] 
+          if (InsertPoint->isBundledWithSucc()){
+            DebugInst->setFlag(MachineInstr::BundledSucc);
+            DebugInst->setFlag(MachineInstr::BundledPred);
+          }
+        }
         Spills.clear();
 
         DEBUG(printVarLocInMBB(MF, OutLocs, VarLocIDs,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41864.129108.patch
Type: text/x-patch
Size: 1460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180109/498c9ff0/attachment.bin>


More information about the llvm-commits mailing list