GCC Middle and Back End API Reference
callback-info.h
Go to the documentation of this file.
1/* Callback attribute summary
2 Copyright (C) 2026 Free Software Foundation, Inc.
3 Contributed by Josef Melcr <jmelcr@gcc.gnu.org>
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21#ifndef CALLBACK_INFO_H
22#define CALLBACK_INFO_H
23
24/* Summary aggregating all information relevant to callback edges. Most of the
25 information can be calculated from the attribute as well, but keeping it
26 separate allows us to modify the info without touching the underlying
27 attribute. */
29{
30public:
31 /* Index of the callback function in the argument list. Currently also used
32 as an id for the callback attribute of the function (needed if a function
33 has multiple callback attributes). This limits us to a single callback
34 attribute per parameter. If we want to allow multiple attributes per
35 parameter, we will need a separate id field. */
36 unsigned fn_idx;
37
38 /* Mapping from the indices of the arguments passed to the callback to their
39 indices in the call to the dispatching function or to
40 ARG_MAPPING_UNKNOWN_IDX if they do not correspond to any. */
42
43 /* Mapping in the opposite direction, from indices of the actual
44 arguments of the call to the dispatcher to indices of arguments in
45 which they are passed to the callback or to ARG_MAPPING_UNKNOWN_IDX
46 if they are not passed to the callback. */
48
49 /* TRUE iff the associated callback edge was redirected. */
51
52 /* Stream in callback_info. */
53 void stream_in (lto_input_block *ib);
54
55 /* Stream out callback_info. */
56 void stream_out (lto_simple_output_block *ib) const;
57
58 /* Returns the id of the associated callback attribute. */
59 unsigned get_id () const;
60
61 /* Initializes the summary. */
62 void init (cgraph_edge *e, unsigned fn_idx, tree attr);
63
64 /* Create the summary for a callback call CBE of internal function IFN. */
66 internal_fn ifn);
67};
68
69class callback_info_sum_t : public call_summary<callback_info *>
70{
71public:
73 : call_summary<callback_info *> (table, ggc)
74 {}
75
76 /* Populates the callback_info_sum if it's NULL. */
77 static void check_create_info_sum ();
78
79 /* Frees the callback_info_sum pointer. */
80 static void free_info_sum ();
81
82 /* Duplication function for the cgraph_edge duplication hook. */
83 void duplicate (cgraph_edge *src, cgraph_edge *dst, callback_info *src_s,
84 callback_info *dst_s) override;
85};
86
88
89/* Return the argument of STMT at IDX if CI is null, otherwise use the mapping
90 in CI and return the remapped argument. Presumes that the remapped index is
91 not ARG_MAPPING_UNKNOWN_IDX. */
92tree callback_call_arg_summary (const gimple *stmt, int idx, callback_info *ci);
93
94/* Return the number of arguments of STMT if CI is null,
95 ci->arg_mapping.length() otherwise. */
96unsigned callback_call_num_args_summary (const gcall *stmt, callback_info *ci);
97
98/* Returns TRUE iff STMT is an internal call statement to IFN_ASSUME. */
99bool callback_ifn_assume_call_p (const gimple *stmt);
100
101/* Returns TRUE iff STMT is an internal call statement to IFN_ASSUME with a
102 callback edge pointing to the outlined body. */
104
105#endif /* CALLBACK_INFO_H */
bool callback_ifn_assume_call_p(const gimple *stmt)
Definition callback-info.cc:199
tree callback_call_arg_summary(const gimple *stmt, int idx, callback_info *ci)
Definition callback-info.cc:179
unsigned callback_call_num_args_summary(const gcall *stmt, callback_info *ci)
Definition callback-info.cc:190
bool callback_ifn_assume_call_with_edge_p(cgraph_node *caller, gimple *stmt)
Definition callback-info.cc:208
callback_info_sum_t * callback_info_sum
Definition callback-info.cc:39
Definition vec.h:1667
Definition callback-info.h:70
static void free_info_sum()
Definition callback-info.cc:155
void duplicate(cgraph_edge *src, cgraph_edge *dst, callback_info *src_s, callback_info *dst_s) override
Definition callback-info.cc:164
static void check_create_info_sum()
Definition callback-info.cc:147
callback_info_sum_t(symbol_table *table, bool ggc)
Definition callback-info.h:72
Definition callback-info.h:29
static callback_info * create_internal_summary(cgraph_edge *cbe, internal_fn ifn)
Definition callback-info.cc:123
void init(cgraph_edge *e, unsigned fn_idx, tree attr)
Definition callback-info.cc:113
auto_vec< int > arg_mapping
Definition callback-info.h:41
void stream_in(lto_input_block *ib)
Definition callback-info.cc:95
void stream_out(lto_simple_output_block *ib) const
Definition callback-info.cc:83
bool redirected
Definition callback-info.h:50
unsigned fn_idx
Definition callback-info.h:36
auto_vec< int > inverted_mapping
Definition callback-info.h:47
unsigned get_id() const
Definition callback-info.cc:107
Definition cgraph.h:1877
Definition lto-streamer.h:349
Definition cgraph.h:2560
union tree_node * tree
Definition coretypes.h:97
internal_fn
Definition genmatch.cc:1024
Definition cgraph.h:920
Definition gimple.h:356
Definition gimple.h:225
Definition lto-streamer.h:692