Line data Source code
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. */
28 31584 : class callback_info
29 : {
30 : public:
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 dispatching function's arguments to the callback
39 : function. */
40 : auto_vec<int> arg_mapping;
41 :
42 : /* TRUE iff the associated callback edge was redirected. */
43 : bool redirected;
44 :
45 : /* Stream in callback_info. */
46 : void stream_in (lto_input_block *ib);
47 :
48 : /* Stream out callback_info. */
49 : void stream_out (lto_simple_output_block *ib) const;
50 :
51 : /* Returns the id of the associated callback attribute. */
52 : unsigned get_id () const;
53 :
54 : /* Initializes the summary. */
55 : void init (unsigned fn_idx, tree attr);
56 : };
57 :
58 : class callback_info_sum_t : public call_summary<callback_info *>
59 : {
60 : public:
61 257567 : callback_info_sum_t (symbol_table *table, bool ggc)
62 257567 : : call_summary<callback_info *> (table, ggc)
63 : {}
64 :
65 : /* Populates the callback_info_sum if it's NULL. */
66 : static void check_create_info_sum ();
67 :
68 : /* Frees the callback_info_sum pointer. */
69 : static void free_info_sum ();
70 :
71 : /* Duplication function for the cgraph_edge duplication hook. */
72 : void duplicate (cgraph_edge *src, cgraph_edge *dst, callback_info *src_s,
73 : callback_info *dst_s) override;
74 : };
75 :
76 : extern callback_info_sum_t *callback_info_sum;
77 :
78 : #endif /* CALLBACK_INFO_H */
|