GCC Middle and Back End API Reference
ipa-modref.h
Go to the documentation of this file.
1/* Search for references that a functions loads or stores.
2 Copyright (C) 2019-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 IPA_MODREF_H
21#define IPA_MODREF_H
22
24typedef unsigned short eaf_flags_t;
25
26/* Single function summary. */
27
29{
30 /* Load and stores in function (transitively closed to all callees) */
35
38
39 unsigned writes_errno : 1;
40 /* Side effects does not include memory loads and stores which are
41 expressed using loads, stores and calls_interposable fields. */
42 unsigned side_effects : 1;
43 /* If true function can not be CSE optimized because it may behave
44 differently even if invoked with same inputs. */
45 unsigned nondeterministic : 1;
46 /* IF true the function may read any reachable memory but not use
47 it for anything useful. This may happen i.e. when interposing
48 function with optimized out conditional with unoptimized one.
49
50 In this situation the loads summary is not useful for DSE but
51 it is still useful for CSE. */
52 unsigned calls_interposable : 1;
53
54 /* Flags computed by finalize method. */
55
56 /* Total number of accesses in loads tree. */
57 unsigned int load_accesses;
58 /* global_memory_read is not set for functions calling functions
59 with !binds_to_current_def which, after interposition, may read global
60 memory but do nothing useful with it (except for crashing if some
61 stores are optimized out. */
62 unsigned global_memory_read : 1;
64 unsigned try_dse : 1;
65
66
69 void dump (FILE *) const;
70 bool useful_p (int ecf_flags, bool check_flags = true);
71 void finalize (tree);
72};
73
78
79/* All flags that are implied by the ECF_CONST functions. */
85
86/* All flags that are implied by the ECF_PURE function. */
90
91/* All flags implied when we know we can ignore stores (i.e. when handling
92 call to noreturn). */
96
97/* Return slot is write-only. */
102
103/* If function does not bind to current def (i.e. it is inline in comdat
104 section), the modref analysis may not match the behavior of function
105 which will be later symbol interposed to. All side effects must match
106 however it is possible that the other function body contains more loads
107 which may trap.
108 MODREF_FLAGS are flags determined by analysis of function body while
109 FLAGS are flags known otherwise (i.e. by fnspec, pure/const attributes
110 etc.) */
111inline int
113{
114 /* If parameter was previously unused, we know it is only read
115 and its value is not used. */
116 if ((modref_flags & EAF_UNUSED) && !(flags & EAF_UNUSED))
117 {
122 }
123 /* We can not determine that value is not read at all. */
128 return modref_flags;
129}
130
131#endif
Definition vec.h:1656
Definition cgraph.h:1696
#define GTY(x)
Definition coretypes.h:41
union tree_node * tree
Definition coretypes.h:97
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
modref_tree< alias_set_type > modref_records
Definition ipa-modref.h:23
void ipa_modref_cc_finalize()
Definition ipa-modref.cc:5572
static const int implicit_const_eaf_flags
Definition ipa-modref.h:81
int interposable_eaf_flags(int modref_flags, int flags)
Definition ipa-modref.h:112
static const int implicit_pure_eaf_flags
Definition ipa-modref.h:88
unsigned short eaf_flags_t
Definition ipa-modref.h:24
static const int implicit_retslot_eaf_flags
Definition ipa-modref.h:99
void ipa_merge_modref_summary_after_inlining(cgraph_edge *e)
Definition ipa-modref.cc:5293
modref_summary * get_modref_function_summary(cgraph_node *func)
Definition ipa-modref.cc:748
static const int ignore_stores_eaf_flags
Definition ipa-modref.h:94
Definition cgraph.h:875
Definition gimple.h:353
Definition ipa-modref.h:29
bool useful_p(int ecf_flags, bool check_flags=true)
Definition ipa-modref.cc:325
auto_vec< eaf_flags_t > arg_flags
Definition ipa-modref.h:34
unsigned side_effects
Definition ipa-modref.h:42
modref_summary()
Definition ipa-modref.cc:279
unsigned calls_interposable
Definition ipa-modref.h:52
auto_vec< modref_access_node > kills
Definition ipa-modref.h:33
eaf_flags_t static_chain_flags
Definition ipa-modref.h:37
~modref_summary()
Definition ipa-modref.cc:287
unsigned global_memory_written
Definition ipa-modref.h:63
modref_records * loads
Definition ipa-modref.h:31
modref_records * stores
Definition ipa-modref.h:32
unsigned global_memory_read
Definition ipa-modref.h:62
unsigned try_dse
Definition ipa-modref.h:64
eaf_flags_t retslot_flags
Definition ipa-modref.h:36
unsigned int load_accesses
Definition ipa-modref.h:57
void dump(FILE *) const
Definition ipa-modref.cc:572
unsigned nondeterministic
Definition ipa-modref.h:45
unsigned writes_errno
Definition ipa-modref.h:39
Definition ipa-modref-tree.h:309
static void finalize()
Definition toplev.cc:2000
#define EAF_NO_INDIRECT_READ
Definition tree-core.h:124
#define EAF_NOT_RETURNED_INDIRECTLY
Definition tree-core.h:120
#define EAF_NO_INDIRECT_ESCAPE
Definition tree-core.h:116
#define EAF_NO_DIRECT_CLOBBER
Definition tree-core.h:111
#define EAF_NO_DIRECT_READ
Definition tree-core.h:123
#define EAF_NO_DIRECT_ESCAPE
Definition tree-core.h:115
#define EAF_NOT_RETURNED_DIRECTLY
Definition tree-core.h:119
#define EAF_NO_INDIRECT_CLOBBER
Definition tree-core.h:112
#define EAF_UNUSED
Definition tree-core.h:104