[PATCH] D53485: [ScheduleDAGRRList] Do not preschedule ADJCALLSTACKDOWN

Shiva Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 21 22:56:20 PDT 2018


shiva0217 created this revision.
Herald added subscribers: JDevlieghere, dylanmckay, MatzeB.

We should not pre-scheduled ADJCALLSTACKDOWN, or else, when bottom-up scheduling, ADJCALLSTACKDOWN and
ADJCALLSTACKUP may hold CallResource too long and make other calls can't be scheduled. If there's no other available node to schedule, the scheduler will try to rename the register by creating the copy to avoid the conflict which will fail because CallResource is not a real physical register.

The issue is found by Tim https://github.com/avr-rust/rust/issues/111
and discuss in http://lists.llvm.org/pipermail/llvm-dev/2018-October/127086.html.


Repository:
  rL LLVM

https://reviews.llvm.org/D53485

Files:
  lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp


Index: lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
+++ lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
@@ -2939,6 +2939,24 @@
             (cast<RegisterSDNode>(N->getOperand(1))->getReg()))
         continue;
 
+    // Try to find the predecessor which is not data dependence.
+    SDNode *PredND = nullptr;
+    for (const SDep &Pred : SU.Preds)
+      if (Pred.isCtrl() && Pred.getSUnit()) {
+        PredND = Pred.getSUnit()->getNode();
+        break;
+      }
+    // If PredND is FrameSetup, we should not pre-scheduled the node,
+    // or else, when bottom up scheduling, ADJCALLSTACKDOWN and
+    // ADJCALLSTACKUP may hold CallResource too long and make other
+    // calls can't be scheduled. If there's no other available node
+    // to schedule, the schedular will try to rename the register by
+    // creating copy to avoid the conflict which will fail because
+    // CallResource is not a real physical register.
+    if (PredND && PredND->isMachineOpcode() &&
+        (PredND->getMachineOpcode() == TII->getCallFrameSetupOpcode()))
+      continue;
+
     // Locate the single data predecessor.
     SUnit *PredSU = nullptr;
     for (const SDep &Pred : SU.Preds)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53485.170368.patch
Type: text/x-patch
Size: 1306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181022/4fb0c615/attachment.bin>


More information about the llvm-commits mailing list