Re: [PATCH] ipa: Implement a summary for callback edges

Martin Jambor <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
Hi,

On Tue, Aug 11 2026, Josef Melcr wrote:
> Hi,
> I rebased the patch and made these adjustments:
>  - I split the enum callback_position into enums callback_position and
>    arg_mapping_constants, as I do want to use an identifier
>    (ARG_MAPPING_UNKNOWN_IDX) instead of just -1.  I also replaced the
>    uses of -1 with said identifier.
>  - I changed where the summary is initialized.  Previously, it was
>    initialized in init_callback_edge_summary, but that function no
>    longer exists.  I moved the initialization into a method on the
>    summary itself and call it in cgraph_edge::make_callback.
>    - That might seem a bit odd, but I think that's the best way to do it, as
>      initializing in other places has problems (the summary is needed in
>      the duplication hooks, so it must be created before calling them.
>      However, there is no edge to associate the summary with before
>      calling make_callback, so it cannot be done before that without
>      changing the hooks as well).
>
> I am sending the patch for a last once-over just to be sure. I bootstrapped
> and retested the patch on x86_64-linux without issues.
>
> OK for master?

Yes, thanks a lot.

Martin

>
> Best regards,
> Josef
>
> gcc/ChangeLog:
>
> 	* Makefile.in: Add callback-info.o to OBJS.
> 	* attr-callback.cc (callback_fetch_attr_by_edge): Use fn_idx
> 	from the summary.
> 	(callback_get_arg_mapping): Replaced by
> 	callback_get_arg_mapping_from_attr and the summary field.
> 	(callback_get_arg_mapping_from_attr): New function, parses the
> 	attr and returns the computed argument mapping.
> 	(callback_fetch_fn_position): Delete, obsoleted by the summary.
> 	(callback_edge_useful_p): Check for the redirected flag in the
> 	summary instead of cgraph_node fields.
> 	* attr-callback.h (enum callback_position): Add comment.
> 	(enum arg_mapping_constants): New enum, defines the identifier
> 	for -1 in the arg_mapping vector.
> 	(callback_get_arg_mapping): Delete.
> 	(callback_fetch_fn_position): Delete.
> 	(callback_get_arg_mapping_from_attr): Add decl.
> 	* cgraph.cc (symbol_table::create_edge): Remove callback_id initializer.
> 	(cgraph_edge::make_callback): Initialize the callback_info
> 	summary, add necessary arguments.
> 	(cgraph_edge::redirect_callee): Set the redirected flag when
> 	redirecting a callback edge.
> 	(cgraph_edge::redirect_call_stmt_to_callee): Use the summary.
> 	(cgraph_node::verify_node): Remove callback_id checks.
> 	(cgraph_cc_finalize): Free the summaries.
> 	* cgraph.h: Remove callback_id from cgraph_edge, adjust decl of
> 	cgraph_edge::make_callback.
> 	* cgraphclones.cc (cgraph_edge::clone): Remove callback_id.
> 	* ipa-cp.cc (ipcp_driver): Initialize the summary sum.
> 	* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Remove
> 	callback_id, adjust call to make_callback, use the summary.
> 	(ipa_analyze_node): Initialize the summary sum.
> 	(ipa_register_cgraph_hooks): Likewise.
> 	* lto-cgraph.cc (lto_output_edge): Remove callback_id, stream
> 	out the summary.
> 	(output_symtab): Initialize the summary sum.
> 	(input_edge): Remove callback_id, stream in the summary.
> 	(input_cgraph_1): Initialize the summary sum.
> 	* callback-info.cc: New file.
> 	* callback-info.h: New file.
>
> Signed-off-by: Josef Melcr <[email protected]>
> ---
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.