Index: lib/CodeGen/MachineScheduler.cpp =================================================================== --- lib/CodeGen/MachineScheduler.cpp +++ lib/CodeGen/MachineScheduler.cpp @@ -3000,12 +3000,15 @@ assert(BotCand.isValid()); assert(TopCand.isValid()); SchedCandidate Cand = BotCand; + GenericSchedulerBase::CandReason TopReason = TopCand.Reason; TopCand.Reason = NoCand; tryCandidate(Cand, TopCand, nullptr); if (TopCand.Reason != NoCand) { Cand.setBest(TopCand); DEBUG(traceCandidate(Cand)); - } + } else + // Restore the original Reason for TopCand if it isn't selected. + TopCand.Reason = TopReason; IsTopNode = Cand.AtTop; tracePick(Cand);