[llvm] [AMDGPU] Improve isBasicBlockPrologue to only add necessary instructions (PR #113303)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 5 08:31:22 PST 2024
alex-t wrote:
> The isBasicBlockPrologue hook was something introduced by AMDGPU and have been in real use only for our backend. I share the same concerns discussed between Alex and Ruiling. The flag based (or label based) Prolog partition was discussed by Matt a few times earlier when we tried to improve this hook. But he gave up that idea by stating that the demarcation based on a flag would be highly unstable as many codegen passes might spoil it by incorrect insertion or incorrect scheduling so that we loose this flag or its purpose. I agree that we should rename this hook to `skipBlockPrologue` and use this to skip past the prolog instructions in a single go.
>
> I also think we should consolidate `SkipPHIsAndLabels` & `SkipPHIsLabelsAndDebug` into the new hook `skipBlockPrologue` (use an additional argument to include DebugInstr or not). Because the former two functions, IIUC, are trying to skip past the generic prolog instructions which are PHIs, Labels, some pseudos, debugInstr, etc. There must be a default implementation of `skipBlockPrologue` that skips the generic instructions and then allow targets to define their own prolog instructions (something that we're trying to fix now).
>
The only question to decide (and for what I need advice) is:
Do we rely on the prologue instructions in lexical order? In other words, whether we sure that the prologue sequence is always correct at the point we call skipBlockPrologue?
As I pointed out above, the reloads are themselves inserted at the point defined by calling the isBasicBlockPrologue.
The code in RegAllocFastImpl::getMBBBeginInsertionPoint checks if the given reload produces an operand for other prologue instructions and collects those that do in the special vector for further inserting.
We have more reloads insertion except for RegallocFast, I guess. So, we need to be sure that we don't have to track the def-use dependency but can just iterate until the very first EXEC update.
https://github.com/llvm/llvm-project/pull/113303
More information about the llvm-commits
mailing list