llvm-project
122e79c3 - [MISched] Advance HazardRec past stalls before calling EmitInstruction (#182977)

Commit
75 days ago
[MISched] Advance HazardRec past stalls before calling EmitInstruction (#182977) There are three calls to bumpCycle in bumpNode. Prior to the first call, we calculate NextCycle as the next cycle in which all of a given instruction's required hardware resources (as defined by the SchedModel) are available. Any gap between this calculated NextCycle and CurrCycle measures stalls that must occur before we can schedule the given instruction. The second and third call handle adjustments that occur during or after issuing of the instruction (e.g. if the number of microops exceeds the issue width). According to the documentation of HazardRec->EmitInstruction, we should call this method when an instruction is emitted: "This callback is invoked when an instruction is emitted, to advance the hazard state." In the context of bumpNode, this implies that it should be called after we bumpCycle for stalls that must occur before issue of the instructions, but before those that occur during or after. This PR moves the placement to do that. In practice, this affects schedulers that use both the SchedModel and HazardRec. Suppose we have instructions A, B and C, and partial schedule AB. Also, suppose instruction A exclusively holds ProcResource X for 2 cycles, and B uses ProcResource X, and there is a HazardRec hazard between B and C which requires 1 cycle stall. Currently, we call HazardRec->EmitInstruction on B before we call HazardRec->AdvanceCycle for the stall between A->B. Then, when deciding whether to schedule C, HazardRec sees that a cycle has already occurred after B, so we do not need to stall. After this change, we HazardRec->EmitInstruction on B after we call HazardRec->AdvanceCycle for the stall between A->B. So, HazardRec accurately places the stall cycle between A and B. Then, when deciding whether to schedule C, HazardRec accurately sees that no cycles have occurred after B, so we do need to stall for 1 cycle.
Author
Parents
Loading