* [PATCH] Keep track of the FUNCTION_BEG note
@ 2024-01-05 16:28 Richard Sandiford
2024-01-09 18:45 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2024-01-05 16:28 UTC (permalink / raw)
To: gcc-patches
function.cc emits a NOTE_FUNCTION_BEG after all arguments have
been copied to pseudos. It then records this note in parm_birth_insn.
Various other pieces of code use this insn as a convenient place to
insert things at the start of the function.
However, cfgexpand later changes parm_birth_insn as follows:
/* If we emitted any instructions for setting up the variables,
emit them before the FUNCTION_START note. */
if (var_seq)
{
emit_insn_before (var_seq, parm_birth_insn);
/* In expand_function_end we'll insert the alloca save/restore
before parm_birth_insn. We've just insertted an alloca call.
Adjust the pointer to match. */
parm_birth_insn = var_seq;
}
But the FUNCTION_BEG note is still useful for things that aren't
sensitive to stack allocation, and it has the advantage that
(unlike the var_seq above) it is never deleted or combined.
This patch adds a separate variable to track it.
Tested on aarch64-linux-gnu, where it's needed for fixing PR113196.
OK to install?
Richard
gcc/
* emit-rtl.h (rtl_data::x_function_beg_note): New member variable.
(function_beg_insn): New macro.
* function.cc (expand_function_start): Initialize function_beg_insn.
---
gcc/emit-rtl.h | 4 ++++
gcc/function.cc | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/gcc/emit-rtl.h b/gcc/emit-rtl.h
index f749ca9f2a0..34f44cb2990 100644
--- a/gcc/emit-rtl.h
+++ b/gcc/emit-rtl.h
@@ -141,6 +141,9 @@ struct GTY(()) rtl_data {
If stack grows up, this is the address for the next slot. */
poly_int64 x_frame_offset;
+ /* The function's FUNCTION_BEG note. */
+ rtx_insn *x_function_beg_insn;
+
/* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */
rtx_insn *x_parm_birth_insn;
@@ -323,6 +326,7 @@ struct GTY(()) rtl_data {
#define return_label (crtl->x_return_label)
#define naked_return_label (crtl->x_naked_return_label)
#define stack_slot_list (crtl->x_stack_slot_list)
+#define function_beg_insn (crtl->x_function_beg_insn)
#define parm_birth_insn (crtl->x_parm_birth_insn)
#define frame_offset (crtl->x_frame_offset)
#define stack_check_probe_note (crtl->x_stack_check_probe_note)
diff --git a/gcc/function.cc b/gcc/function.cc
index de356f7fba3..5ffd438475e 100644
--- a/gcc/function.cc
+++ b/gcc/function.cc
@@ -5202,7 +5202,7 @@ expand_function_start (tree subr)
gcc_assert (NOTE_P (get_last_insn ()));
- parm_birth_insn = get_last_insn ();
+ function_beg_insn = parm_birth_insn = get_last_insn ();
/* If the function receives a non-local goto, then store the
bits we need to restore the frame pointer. */
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Keep track of the FUNCTION_BEG note
2024-01-05 16:28 [PATCH] Keep track of the FUNCTION_BEG note Richard Sandiford
@ 2024-01-09 18:45 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2024-01-09 18:45 UTC (permalink / raw)
To: gcc-patches, richard.sandiford
On 1/5/24 09:28, Richard Sandiford wrote:
> function.cc emits a NOTE_FUNCTION_BEG after all arguments have
> been copied to pseudos. It then records this note in parm_birth_insn.
> Various other pieces of code use this insn as a convenient place to
> insert things at the start of the function.
>
> However, cfgexpand later changes parm_birth_insn as follows:
>
> /* If we emitted any instructions for setting up the variables,
> emit them before the FUNCTION_START note. */
> if (var_seq)
> {
> emit_insn_before (var_seq, parm_birth_insn);
>
> /* In expand_function_end we'll insert the alloca save/restore
> before parm_birth_insn. We've just insertted an alloca call.
> Adjust the pointer to match. */
> parm_birth_insn = var_seq;
> }
>
> But the FUNCTION_BEG note is still useful for things that aren't
> sensitive to stack allocation, and it has the advantage that
> (unlike the var_seq above) it is never deleted or combined.
> This patch adds a separate variable to track it.
>
> Tested on aarch64-linux-gnu, where it's needed for fixing PR113196.
> OK to install?
>
> Richard
>
>
> gcc/
> * emit-rtl.h (rtl_data::x_function_beg_note): New member variable.
> (function_beg_insn): New macro.
> * function.cc (expand_function_start): Initialize function_beg_insn.
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-09 18:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-05 16:28 [PATCH] Keep track of the FUNCTION_BEG note Richard Sandiford
2024-01-09 18:45 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).