This function has had a long overdue need for refactoring. The current implementation works across the matrix of:
{IP32, IP64, I64P32} x {Function,Funclet x {Managed,Unmanaged}}
This makes the code extremely brittle and difficult to follow. Introduce the FrameBuilder that constructs the shared context to emit the various operations. The builder has a number of emitters which follow the general pattern of a series of guard statements preventing the emission if the conditions do not hold. We then perform the build. This allows the build operation to become entirely free of control flow - we perform the operations unconditionally. Furthermore, it allows us to split up the operations so that we no longer have a single 600-line function that emits the prologue for every configuration.
This was initially started in D104557. This applies the full transformation as a single patch (though it was performed through ~42 individual commits).
This variable is used only in one place. Just call TLI->hasStackProbeSymbol(MF) directly.
The same is true for most of the other variables.