GCC Middle and Back End API Reference
value-prof.h
Go to the documentation of this file.
1/* Definitions for transformations based on profile information for values.
2 Copyright (C) 2003-2024 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_VALUE_PROF_H
21#define GCC_VALUE_PROF_H
22
23/* Supported histogram types. */
25{
26 HIST_TYPE_INTERVAL, /* Measures histogram of values inside a specified
27 interval. */
28 HIST_TYPE_POW2, /* Histogram of power of 2 values. */
29 HIST_TYPE_TOPN_VALUES, /* Tries to identify the N most common values. */
30 HIST_TYPE_INDIR_CALL, /* Tries to identify the function that is (almost)
31 called in indirect call */
32 HIST_TYPE_AVERAGE, /* Compute average value (sum of all values). */
33 HIST_TYPE_IOR, /* Used to compute expected alignment. */
34 HIST_TYPE_TIME_PROFILE, /* Used for time profile */
36};
37
38#define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER)
39#define HIST_TYPE_FOR_COUNTER(COUNTER) \
40 ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER))
41
42
43/* The value to measure. */
45{
46 struct
47 {
48 tree value; /* The value to profile. */
49 gimple *stmt; /* Insn containing the value. */
50 gcov_type *counters; /* Pointer to first counter. */
51 struct histogram_value_t *next; /* Linked list pointer. */
53 enum hist_type type; /* Type of information to measure. */
54 unsigned n_counters; /* Number of required counters. */
55 struct function *fun;
56 union
57 {
58 struct
59 {
60 int int_start; /* First value in interval. */
61 unsigned int steps; /* Number of values in it. */
62 } intvl; /* Interval histogram data. */
63 } hdata; /* Profiled information specific data. */
64};
65
68
69
71
74
76 gimple *stmt = NULL,
80 enum hist_type);
82void dump_histograms_for_stmt (struct function *, FILE *, gimple *);
86 struct function *, gimple *);
88void verify_histograms (void);
90void stringop_block_profile (gimple *, unsigned int *, HOST_WIDE_INT *);
95 unsigned n = 0);
96
97/* In tree-profile.cc. */
98extern void gimple_init_gcov_profiler (void);
99extern void gimple_gen_edge_profiler (int, edge);
100extern void gimple_gen_interval_profiler (histogram_value, unsigned);
101extern void gimple_gen_pow2_profiler (histogram_value, unsigned);
103extern void gimple_gen_ic_profiler (histogram_value, unsigned);
104extern void gimple_gen_ic_func_profiler (void);
105extern void gimple_gen_time_profiler (unsigned);
106extern void gimple_gen_average_profiler (histogram_value, unsigned);
107extern void gimple_gen_ior_profiler (histogram_value, unsigned);
109extern void stream_in_histogram_value (class lto_input_block *, gimple *);
110extern struct cgraph_node* find_func_by_profile_id (int func_id);
111
112
113/* In profile.cc. */
114extern void init_branch_prob (void);
115extern void branch_prob (bool);
116extern void read_thunk_profile (struct cgraph_node *);
117extern void end_branch_prob (void);
118
119#endif /* GCC_VALUE_PROF_H */
120
Definition lto-streamer.h:342
Definition profile-count.h:147
class edge_def * edge
Definition coretypes.h:342
int64_t gcov_type
Definition coretypes.h:46
union tree_node * tree
Definition coretypes.h:97
static unsigned int count[debug_counter_number_of_counters]
Definition dbgcnt.cc:50
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
Definition cgraph.h:875
Definition function.h:249
Definition gimple.h:352
Definition gimple.h:225
Definition value-prof.h:45
struct histogram_value_t::@89::@90 intvl
enum hist_type type
Definition value-prof.h:53
unsigned int steps
Definition value-prof.h:61
int int_start
Definition value-prof.h:60
struct histogram_value_t * next
Definition value-prof.h:51
struct function * fun
Definition value-prof.h:55
union histogram_value_t::@89 hdata
unsigned n_counters
Definition value-prof.h:54
tree value
Definition value-prof.h:48
gcov_type * counters
Definition value-prof.h:50
gimple * stmt
Definition value-prof.h:49
struct histogram_value_t::@88 hvalue
Definition lto-streamer.h:699
Definition vec.h:450
#define NULL
Definition system.h:50
#define NULL_TREE
Definition tree.h:317
void dump_histograms_for_stmt(struct function *, FILE *, gimple *)
Definition value-prof.cc:421
void gimple_gen_topn_values_profiler(histogram_value, unsigned)
Definition tree-profile.cc:1511
void verify_histograms(void)
Definition value-prof.cc:499
void gimple_gen_ic_func_profiler(void)
Definition tree-profile.cc:1582
void gimple_gen_average_profiler(histogram_value, unsigned)
Definition tree-profile.cc:1700
const struct histogram_value_t * const_histogram_value
Definition value-prof.h:67
hist_type
Definition value-prof.h:25
@ HIST_TYPE_MAX
Definition value-prof.h:35
@ HIST_TYPE_TOPN_VALUES
Definition value-prof.h:29
@ HIST_TYPE_POW2
Definition value-prof.h:28
@ HIST_TYPE_IOR
Definition value-prof.h:33
@ HIST_TYPE_AVERAGE
Definition value-prof.h:32
@ HIST_TYPE_TIME_PROFILE
Definition value-prof.h:34
@ HIST_TYPE_INTERVAL
Definition value-prof.h:26
@ HIST_TYPE_INDIR_CALL
Definition value-prof.h:30
bool get_nth_most_common_value(gimple *stmt, const char *counter_type, histogram_value hist, gcov_type *value, gcov_type *count, gcov_type *all, unsigned n=0)
Definition value-prof.cc:749
histogram_value gimple_histogram_value_of_type(struct function *, gimple *, enum hist_type)
Definition value-prof.cc:211
void gimple_gen_ior_profiler(histogram_value, unsigned)
Definition tree-profile.cc:1721
void stringop_block_profile(gimple *, unsigned int *, HOST_WIDE_INT *)
Definition value-prof.cc:1729
bool gimple_value_profile_transformations(void)
Definition value-prof.cc:603
struct cgraph_node * find_func_by_profile_id(int func_id)
Definition value-prof.cc:1290
void gimple_find_values_to_profile(histogram_values *)
Definition value-prof.cc:1908
void gimple_remove_stmt_histograms(struct function *, gimple *)
Definition value-prof.cc:431
void stream_out_histogram_value(struct output_block *, histogram_value)
Definition value-prof.cc:311
void gimple_init_gcov_profiler(void)
Definition tree-profile.cc:1218
void gimple_gen_interval_profiler(histogram_value, unsigned)
Definition tree-profile.cc:1465
void free_histograms(function *)
Definition value-prof.cc:545
void gimple_move_stmt_histograms(struct function *, gimple *, gimple *)
Definition value-prof.cc:459
void gimple_duplicate_stmt_histograms(struct function *, gimple *, struct function *, gimple *)
Definition value-prof.cc:441
void read_thunk_profile(struct cgraph_node *)
Definition profile.cc:1143
void gimple_gen_edge_profiler(int, edge)
Definition tree-profile.cc:1439
histogram_value gimple_histogram_value(struct function *, gimple *)
Definition value-prof.cc:166
void branch_prob(bool)
Definition profile.cc:1185
void end_branch_prob(void)
Definition profile.cc:1744
void gimple_add_histogram_value(struct function *, gimple *, histogram_value)
Definition value-prof.cc:177
void gimple_gen_ic_profiler(histogram_value, unsigned)
Definition tree-profile.cc:1533
void gimple_remove_histogram_value(struct function *, gimple *, histogram_value)
Definition value-prof.cc:188
gcall * gimple_ic(gcall *, struct cgraph_node *, profile_probability)
Definition value-prof.cc:1308
histogram_value gimple_alloc_histogram_value(struct function *, enum hist_type, gimple *stmt=NULL, tree value=NULL_TREE)
Definition value-prof.cc:114
void init_branch_prob(void)
Definition profile.cc:1723
void stream_in_histogram_value(class lto_input_block *, gimple *)
Definition value-prof.cc:343
void gimple_gen_time_profiler(unsigned)
Definition tree-profile.cc:1661
struct histogram_value_t * histogram_value
Definition value-prof.h:66
void gimple_gen_pow2_profiler(histogram_value, unsigned)
Definition tree-profile.cc:1491
vec< histogram_value > histogram_values
Definition value-prof.h:70