On Fri, May 03, 2019 at 09:29:11AM +0000, Matthew Malcomson wrote: > On 02/05/19 16:33, Segher Boessenkool wrote: > > Because other things want to use it as the place to put stack checking, > > for example. And that cannot be after this note, but it can also not > > be before it. > > > > I figured the stack checking could be after one note (end of argument > setup), and before the other (start of user code)?
I don't think that can work. It needs to do its thing before anything else (that can overflow, at least) touches the stack. > > Is there any reason the stack checking code is inserted way before the > > prologue/epilogue are, btw? > > I don't know, I'm especially curious why the prologue & epilogue are > emitted in assembly with the TARGET_ASM_FUNCTION_{EPILOGUE,PROLOGUE} > macros instead of emitted as rtl somewhere earlier in the pipeline. They are emitted as RTL on most targets. Some targets *also* use some asm text output for special things, but the usual prologue code is done as RTL. > I'd guess the stack checking code is earlier since it would like to be > optimised by the RTL passes. It cannot, or *should* not, be optimised much. Hrm. > Are you thinking there's call for a more thorough handling of the > introduction and placement of these almost-prologue parts like > stack-checking, non-local goto save areas and the like? I think we should try to no longer rely on these magic notes, which only still work by luck, or even do nbot really work anymore. Segher