[llvm] [AMDGPU] Refine GCNHazardRecognizer hasHazard() (PR #138841)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 03:56:52 PDT 2025


================
@@ -441,42 +441,96 @@ using IsExpiredFn = function_ref<bool(const MachineInstr &, int WaitStates)>;
 using GetNumWaitStatesFn = function_ref<unsigned int(const MachineInstr &)>;
 
 // Search for a hazard in a block and its predecessors.
+// StateT must implement getHashValue() and isEqual().
 template <typename StateT>
 static bool
-hasHazard(StateT State,
+hasHazard(StateT InitialState,
           function_ref<HazardFnResult(StateT &, const MachineInstr &)> IsHazard,
           function_ref<void(StateT &, const MachineInstr &)> UpdateState,
----------------
jayfoad wrote:

Not something to address in the current patch, but I think this `IsHazard`/`UpdateState` interface is confusing because `IsHazard` _also_ updates the state. So technically I think there is no need for the separate `UpdateState` function, it could just become part of what `IsHazard` does before returning `NoHazardFound`.

https://github.com/llvm/llvm-project/pull/138841


More information about the llvm-commits mailing list