diff --git a/llvm/include/llvm/CodeGen/MachineScheduler.h b/llvm/include/llvm/CodeGen/MachineScheduler.h --- a/llvm/include/llvm/CodeGen/MachineScheduler.h +++ b/llvm/include/llvm/CodeGen/MachineScheduler.h @@ -757,8 +757,16 @@ unsigned getOtherResourceCount(unsigned &OtherCritIdx); - template - void releaseNode(SUnit *SU, unsigned ReadyCycle, unsigned Idx = 0); + /// Release SU to make it ready. If it's not in hazard, remove it from + /// pending queue (if already in) and push into available queue. + /// Otherwise, push the SU into pending queue. + /// + /// @param SU The unit to be released. + /// @param ReadyCycle Until which cycle the unit is ready. + /// @param InPQueue Whether SU is already in pending queue. + /// @param Idx Position offset in pending queue (if in it). + void releaseNode(SUnit *SU, unsigned ReadyCycle, bool InPQueue, + unsigned Idx = 0); void bumpCycle(unsigned NextCycle); @@ -956,7 +964,7 @@ if (SU->isScheduled) return; - Top.releaseNode(SU, SU->TopReadyCycle); + Top.releaseNode(SU, SU->TopReadyCycle, false); TopCand.SU = nullptr; } @@ -964,7 +972,7 @@ if (SU->isScheduled) return; - Bot.releaseNode(SU, SU->BotReadyCycle); + Bot.releaseNode(SU, SU->BotReadyCycle, false); BotCand.SU = nullptr; } @@ -1044,7 +1052,7 @@ void releaseTopNode(SUnit *SU) override { if (SU->isScheduled) return; - Top.releaseNode(SU, SU->TopReadyCycle); + Top.releaseNode(SU, SU->TopReadyCycle, false); } // Only called for roots. diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -2088,13 +2088,8 @@ return OtherCritCount; } -template void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle, - unsigned Idx); -template void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle, - unsigned Idx); - -template -void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle, unsigned Idx) { +void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle, bool InPQueue, + unsigned Idx) { assert(SU->getInstr() && "Scheduled SUnit must have instr"); #ifndef NDEBUG @@ -2373,7 +2368,7 @@ if (Available.size() >= ReadyListLimit) break; - releaseNode(SU, ReadyCycle, I); + releaseNode(SU, ReadyCycle, true, I); if (E != Pending.size()) { --I; --E;