GCC Middle and Back End API Reference
domwalk.h
Go to the documentation of this file.
1/* Generic dominator tree walker
2 Copyright (C) 2003-2024 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@redhat.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_DOM_WALK_H
22#define GCC_DOM_WALK_H
23
31{
32public:
33 static const edge STOP;
34
35 /* An enum for determining whether the dom walk should be constrained to
36 blocks reachable by executable edges. */
37
39 {
40 /* Walk all blocks within the CFG. */
42
43 /* Use REACHABLE_BLOCKS when your subclass can discover that some edges
44 are not executable.
45
46 If a subclass can discover that a COND, SWITCH or GOTO has a static
47 target in the before_dom_children callback, the taken edge should
48 be returned. The generic walker will clear EDGE_EXECUTABLE on all
49 edges it can determine are not executable.
50
51 With REACHABLE_BLOCKS, EDGE_EXECUTABLE will be set on every edge in
52 the dom_walker ctor; the flag will then be cleared on edges that are
53 determined to be not executable. */
55
56 /* Identical to REACHABLE_BLOCKS, but the initial state of EDGE_EXECUTABLE
57 will instead be preserved in the ctor, allowing for information about
58 non-executable edges to be merged in from an earlier analysis (and
59 potentially for additional edges to be marked as non-executable). */
61 };
62
63 /* You can provide a mapping of basic-block index to RPO if you
64 have that readily available or you do multiple walks. If you
65 specify NULL as BB_INDEX_TO_RPO this mapping will be computed
66 lazily at walk time. If you specify -1 dominator children will
67 not be walked in RPO order. */
69 int *bb_index_to_rpo = NULL);
70
71 ~dom_walker ();
72
73 /* Walk the dominator tree. */
74 void walk (basic_block);
75
76 /* Function to call before the recursive walk of the dominator children.
77
78 Return value is the always taken edge if the block has multiple outgoing
79 edges, NULL otherwise. When skipping unreachable blocks, the walker
80 uses the taken edge information to clear EDGE_EXECUTABLE on the other
81 edges, exposing unreachable blocks. A NULL return value means all
82 outgoing edges should still be considered executable. A return value
83 of STOP means to stop the domwalk from processing dominated blocks from
84 here. This can be used to process a SEME region only (note domwalk
85 will still do work linear in function size). */
87
88 /* Function to call after the recursive walk of the dominator children. */
90
91private:
92 /* This is the direction of the dominator tree we want to walk. i.e.,
93 if it is set to CDI_DOMINATORS, then we walk the dominator tree,
94 if it is set to CDI_POST_DOMINATORS, then we walk the post
95 dominator tree. */
101
102 /* Query whether or not the given block is reachable or not. */
103 bool bb_reachable (struct function *, basic_block);
104
105 /* Given an unreachable block, propagate that property to outgoing
106 and possibly incoming edges for the block. Typically called after
107 determining a block is unreachable in the before_dom_children
108 callback. */
110
111};
112
113extern void set_all_edges_as_executable (function *fn);
114
115#endif
Definition domwalk.h:31
dom_walker(cdi_direction direction, enum reachability=ALL_BLOCKS, int *bb_index_to_rpo=NULL)
Definition domwalk.cc:187
bool bb_reachable(struct function *, basic_block)
Definition domwalk.cc:210
virtual void after_dom_children(basic_block)
Definition domwalk.h:89
void propagate_unreachable_to_edges(basic_block, FILE *, dump_flags_t)
Definition domwalk.cc:238
basic_block m_unreachable_dom
Definition domwalk.h:99
virtual edge before_dom_children(basic_block)
Definition domwalk.h:86
static const edge STOP
Definition domwalk.h:33
~dom_walker()
Definition domwalk.cc:201
void walk(basic_block)
Definition domwalk.cc:273
int * m_bb_to_rpo
Definition domwalk.h:100
enum cdi_direction m_dom_direction
Definition domwalk.h:96
enum reachability m_reachability
Definition domwalk.h:97
bool m_user_bb_to_rpo
Definition domwalk.h:98
reachability
Definition domwalk.h:39
@ ALL_BLOCKS
Definition domwalk.h:41
@ REACHABLE_BLOCKS_PRESERVING_FLAGS
Definition domwalk.h:60
@ REACHABLE_BLOCKS
Definition domwalk.h:54
class edge_def * edge
Definition coretypes.h:342
cdi_direction
Definition dominance.h:24
void set_all_edges_as_executable(function *fn)
Definition domwalk.cc:173
enum dump_flag dump_flags_t
Definition dumpfile.h:209
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
Definition basic-block.h:117
Definition function.h:249
#define NULL
Definition system.h:50