Hi, On Mon, Sep 21 2026, Josef Melcr wrote: > This patch adds a new field to cgraph_node called assume_function. It > serves the same purpose as the field of the same name in struct > function. Struct function is not always available (e.g. LTO), so this field > preserves the information. > > gcc/ChangeLog: > > * cgraph.cc (cgraph_node::dump): Print the new flag. > * cgraph.h (struct cgraph_node): Add assume_function field. > * cgraphclones.cc (cgraph_node::create_clone): Copy over the > assume_function flag. > * gimple-low.cc (lower_assumption): Set assume_function to TRUE > for assume bodies. > * lto-cgraph.cc (lto_output_node): Stream out assume_function. > (input_overwrite_node): Read assume_function.
The patch is OK once a patch using the flag is approved too but... > > Signed-off-by: Josef Melcr <[email protected]> > --- > gcc/cgraph.cc | 2 ++ > gcc/cgraph.h | 6 ++++-- > gcc/cgraphclones.cc | 1 + > gcc/gimple-low.cc | 2 ++ > gcc/lto-cgraph.cc | 2 ++ > 5 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc > index 8e349189724..c1bf53f6c36 100644 > --- a/gcc/cgraph.cc > +++ b/gcc/cgraph.cc > @@ -2583,6 +2583,8 @@ cgraph_node::dump (FILE *f) > fprintf (f, " calls_comdat_local"); > if (icf_merged) > fprintf (f, " icf_merged"); > + if (assume_function) > + fprintf (f, " assume_function"); > if (merged_comdat) > fprintf (f, " merged_comdat"); > if (merged_extern_inline) > diff --git a/gcc/cgraph.h b/gcc/cgraph.h > index d9f3d4815b0..5f8e4235184 100644 > --- a/gcc/cgraph.h > +++ b/gcc/cgraph.h > @@ -939,8 +939,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : > public symtab_node > only_called_at_startup (false), only_called_at_exit (false), > tm_clone (false), dispatcher_function (false), > dispatcher_resolver_function (false), is_target_clone (false), > - calls_comdat_local (false), > - icf_merged (false), nonfreeing_fn (false), merged_comdat (false), > + calls_comdat_local (false), icf_merged (false), assume_function > (false), > + nonfreeing_fn (false), merged_comdat (false), > merged_extern_inline (false), parallelized_function (false), > split_part (false), indirect_call_target (false), local (false), > versionable (false), can_change_signature (false), > @@ -1536,6 +1536,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : > public symtab_node > unsigned calls_comdat_local : 1; > /* True if node has been created by merge operation in IPA-ICF. */ > unsigned icf_merged: 1; > + /* True if node has been created by lowering an [[assume(...)]] statement. > */ > + unsigned assume_function : 1; > /* True if call to node can't result in a call to free, munmap or > other operation that could make previously non-trapping memory > accesses trapping. */ > diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc > index b5f2ce5ff2f..c5aead0c3b8 100644 > --- a/gcc/cgraphclones.cc > +++ b/gcc/cgraphclones.cc > @@ -452,6 +452,7 @@ cgraph_node::create_clone (tree new_decl, profile_count > prof_count, > new_node->tp_first_run = tp_first_run; > new_node->tm_clone = tm_clone; > new_node->icf_merged = icf_merged; > + new_node->assume_function = assume_function; > new_node->thunk = thunk; > new_node->unit_id = unit_id; > new_node->merged_comdat = merged_comdat; > diff --git a/gcc/gimple-low.cc b/gcc/gimple-low.cc > index ed752429854..8d9ffd24124 100644 > --- a/gcc/gimple-low.cc > +++ b/gcc/gimple-low.cc > @@ -677,6 +677,8 @@ lower_assumption (gimple_stmt_iterator *gsi, struct > lower_data *data) > DECL_STRUCT_FUNCTION (lad.id.dst_fn)->stdarg = 0; > > cgraph_node::add_new_function (lad.id.dst_fn, false); > + cgraph_node *dst_node = cgraph_node::get (lad.id.dst_fn); > + dst_node->assume_function = 1; > ...extra points for making add_new_function return the new node so that you don't need to look it up using cgraph_node::get (such change is pre-approved). Martin > for (unsigned i = 0; i < sz; ++i) > { > diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc > index bffe35f2353..b3644e47bec 100644 > --- a/gcc/lto-cgraph.cc > +++ b/gcc/lto-cgraph.cc > @@ -561,6 +561,7 @@ lto_output_node (struct lto_simple_output_block *ob, > struct cgraph_node *node, > bp_pack_value (&bp, node->tm_clone, 1); > bp_pack_value (&bp, node->calls_comdat_local, 1); > bp_pack_value (&bp, node->icf_merged, 1); > + bp_pack_value (&bp, node->assume_function, 1); > bp_pack_value (&bp, node->nonfreeing_fn, 1); > bp_pack_value (&bp, node->merged_comdat, 1); > bp_pack_value (&bp, node->merged_extern_inline, 1); > @@ -1299,6 +1300,7 @@ input_overwrite_node (struct lto_file_decl_data > *file_data, > node->tm_clone = bp_unpack_value (bp, 1); > node->calls_comdat_local = bp_unpack_value (bp, 1); > node->icf_merged = bp_unpack_value (bp, 1); > + node->assume_function = bp_unpack_value (bp, 1); > node->nonfreeing_fn = bp_unpack_value (bp, 1); > node->merged_comdat = bp_unpack_value (bp, 1); > node->merged_extern_inline = bp_unpack_value (bp, 1); > -- > 2.55.0
