diff --git a/llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp b/llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp --- a/llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp +++ b/llvm/lib/CodeGen/ScoreboardHazardRecognizer.cpp @@ -143,6 +143,13 @@ } InstrStage::FuncUnits freeUnits = IS->getUnits(); + if (!freeUnits) { + // No functional units are required by this stage, so cannot conflict. + // In addition, prevent endless loop when running the post-RA-sched + // pass. + continue; + } + switch (IS->getReservationKind()) { case InstrStage::Required: // Required FUs conflict with both reserved and required ones