GCC Middle and Back End API Reference
attr-callback.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CALLBACK_ATTR_IDENT   " callback"

Enumerations

enum  callback_position { CB_UNKNOWN_POS = 0 }

Functions

tree callback_build_attr (unsigned fn_idx, unsigned arg_count...)
bool callback_is_special_cased (tree decl, gcall *stmt)
tree callback_special_case_attr (tree decl)
int callback_get_fn_index (tree cb_attr)
tree callback_fetch_attr_by_edge (cgraph_edge *e, cgraph_edge *carrying)
auto_vec< int > callback_get_arg_mapping (cgraph_edge *e, cgraph_edge *carrying)
int callback_fetch_fn_position (cgraph_edge *e, cgraph_edge *carrying)
tree handle_callback_attribute (tree *node, tree name, tree args, int flags, bool *no_add_attrs)
bool callback_edge_useful_p (cgraph_edge *e)
size_t callback_num_args (tree attr)

Macro Definition Documentation

◆ CALLBACK_ATTR_IDENT

Enumeration Type Documentation

◆ callback_position

Callback attribute handling
Copyright (C) 2025 Free Software Foundation, Inc.
Contributed by Josef Melcr <jmelcr@gcc.gnu.org>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Enumerator
CB_UNKNOWN_POS 

Function Documentation

◆ callback_build_attr()

tree callback_build_attr ( unsigned fn_idx,
unsigned arg_count... )
Returns a callback attribute with callback index FN_IDX, and ARG_COUNT
arguments specified by VA_ARGS.   
Callback attribute handling
Copyright (C) 2025 Free Software Foundation, Inc.
Contributed by Josef Melcr <jmelcr@gcc.gnu.org>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Returns a callback attribute with callback index FN_IDX, and ARG_COUNT
arguments specified by VA_ARGS.   

References build_int_cst(), build_tree_list(), CALLBACK_ATTR_IDENT, get_identifier(), i, integer_type_node, NULL, NULL_TREE, PASS_MEM_STAT, TREE_CHAIN, and tree_cons().

Referenced by callback_special_case_attr(), and set_call_expr_flags().

◆ callback_edge_useful_p()

bool callback_edge_useful_p ( cgraph_edge * e)
Returns TRUE if E is considered useful in the callgraph, FALSE otherwise.  If
this predicate returns FALSE, then E wasn't used to optimize its callee and
can be safely removed from the callgraph.   

References gcc_checking_assert.

Referenced by purge_useless_callback_edges().

◆ callback_fetch_attr_by_edge()

tree callback_fetch_attr_by_edge ( cgraph_edge * e,
cgraph_edge * carrying )

◆ callback_fetch_fn_position()

int callback_fetch_fn_position ( cgraph_edge * e,
cgraph_edge * carrying )
For a callback pair, returns the 0-based index of the address of
E's callee in the argument list of CARRYING's callee decl.   

References callback_fetch_attr_by_edge(), and callback_get_fn_index().

Referenced by cgraph_edge::redirect_call_stmt_to_callee().

◆ callback_get_arg_mapping()

auto_vec< int > callback_get_arg_mapping ( cgraph_edge * e,
cgraph_edge * carrying )
Given an instance of callback attribute, return the 0-base indices
of arguments passed to the callback.  For a callback function taking
n parameters, returns a vector of n indices of their values in the parameter
list of it's caller.  Indices with unknown positions contain -1.   

References callback_fetch_attr_by_edge(), CB_UNKNOWN_POS, gcc_checking_assert, NULL_TREE, TREE_CHAIN, TREE_INT_CST_LOW, and TREE_VALUE.

Referenced by ipa_compute_jump_functions_for_edge().

◆ callback_get_fn_index()

int callback_get_fn_index ( tree cb_attr)
Given an instance of callback attribute, return the 0-based
index of the called function in question.   

References TREE_INT_CST_LOW, and TREE_VALUE.

Referenced by callback_fetch_attr_by_edge(), callback_fetch_fn_position(), handle_callback_attribute(), and ipa_compute_jump_functions_for_edge().

◆ callback_is_special_cased()

bool callback_is_special_cased ( tree decl,
gcall * stmt )
Returns TRUE if a function should be treated as if it had a callback
attribute despite the DECL not having it.  STMT can be passed NULL
if the call statement is not available at the time, for example WPA, but it
should be called with the statement itself whenever possible.   

References fndecl_built_in_p(), gimple_call_arg(), and null_pointer_node.

Referenced by callback_fetch_attr_by_edge(), ipa_compute_jump_functions_for_edge(), purge_useless_callback_edges(), cgraph_edge::redirect_call_stmt_to_callee(), and cgraph_node::verify_node().

◆ callback_num_args()

size_t callback_num_args ( tree attr)
Returns the number of arguments the callback function described by ATTR
takes.   

References NULL_TREE, TREE_CHAIN, and TREE_VALUE.

Referenced by init_callback_edge_summary().

◆ callback_special_case_attr()

tree callback_special_case_attr ( tree decl)
Returns an attribute for a special cased function.   

References callback_build_attr(), fndecl_built_in_p(), and gcc_unreachable.

Referenced by callback_fetch_attr_by_edge(), and ipa_compute_jump_functions_for_edge().

◆ handle_callback_attribute()

tree handle_callback_attribute ( tree * node,
tree name,
tree args,
int flags,
bool * no_add_attrs )
Handle a "callback" attribute; arguments as in
struct attribute_spec.handler.