What is the precise definition of NOTE_INSN_FUNCTION_BEG?

Matthew Malcomson Matthew.Malcomson@arm.com
Fri May 3 09:29:00 GMT 2019

On 02/05/19 16:33, Segher Boessenkool wrote:
> On Thu, May 02, 2019 at 01:02:14PM +0000, Matthew Malcomson wrote:
>> On 01/05/19 20:40, Segher Boessenkool wrote:
>>> On Tue, Apr 30, 2019 at 03:48:02PM -0600, Jeff Law wrote:
>>>> On 4/30/19 11:24 AM, Matthew Malcomson wrote:
>>>>> That was why I ended up suggesting multiple notes -- it's currently
>>>>> trying to satisfy more than one criteria and they're not quite compatible.
>>>> Well, we obviously have to keep arg setup, asan, stack protector and
>>>> nonlocal stuff in the same relative order, but I believe they should all
>>>> ultimately land before the NOTE_INSN_FUNCTION_BEG.  THe question is how
>>>> to make that happen :-)
>>> The current meaning of NOTE_INSN_FUNCTION_BEG is
>>>     /* Indicate the beginning of the function body,
>>>        as opposed to parm setup.  */
>>>     emit_note (NOTE_INSN_FUNCTION_BEG);
>>> (function.c), and half of the things that use the note think that
>>> everything before it is argument setup, and nothing after it is.
>>> Just adding extra notes isn't enough afaics; some surgery is needed.
>> Apologies, I don't follow -- could you elaborate on why an extra note is
>> not enough?
>> If this note is trying to mark the end of the argument setup for those
>> places you mention, and the start of user code for debug output, and
>> those are not the same place then I would have thought splitting it
>> would be necessary.
> 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)?

> 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.

I'd guess the stack checking code is earlier since it would like to be 
optimised by the RTL passes.

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?

> Segher

More information about the Gcc mailing list