annotate gcc/cfg.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Control flow graph manipulation code for GNU compiler.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 1987-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 /* This file contains low level functions to manipulate the CFG and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 analyze it. All other modules should not transform the data structure
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 directly and use abstraction instead. The file is supposed to be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 ordered bottom-up and should not contain any code dependent on a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 particular intermediate language (RTL or trees).
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 Available functionality:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 - Initialization/deallocation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 init_flow, clear_edges
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 - Low level basic block manipulation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 alloc_block, expunge_block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 - Edge manipulation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 make_edge, make_single_succ_edge, cached_make_edge, remove_edge
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 - Low level edge redirection (without updating instruction chain)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 redirect_edge_succ, redirect_edge_succ_nodup, redirect_edge_pred
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 - Dumping and debugging
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 dump_flow_info, debug_flow_info, dump_edge_info
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 - Allocation of AUX fields for basic blocks
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 alloc_aux_for_blocks, free_aux_for_blocks, alloc_aux_for_block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 - clear_bb_flags
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 - Consistency checking
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 verify_flow_info
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 - Dumping and debugging
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 print_rtl_with_bb, dump_bb, debug_bb, debug_bb_n
111
kono
parents: 67
diff changeset
44
kono
parents: 67
diff changeset
45 TODO: Document these "Available functionality" functions in the files
kono
parents: 67
diff changeset
46 that implement them.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 #include "coretypes.h"
111
kono
parents: 67
diff changeset
52 #include "backend.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 #include "hard-reg-set.h"
111
kono
parents: 67
diff changeset
54 #include "tree.h"
kono
parents: 67
diff changeset
55 #include "cfghooks.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 #include "df.h"
111
kono
parents: 67
diff changeset
57 #include "cfganal.h"
kono
parents: 67
diff changeset
58 #include "cfgloop.h" /* FIXME: For struct loop. */
kono
parents: 67
diff changeset
59 #include "dumpfile.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 /* Called once at initialization time. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 init_flow (struct function *the_fun)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 if (!the_fun->cfg)
111
kono
parents: 67
diff changeset
69 the_fun->cfg = ggc_cleared_alloc<control_flow_graph> ();
kono
parents: 67
diff changeset
70 n_edges_for_fn (the_fun) = 0;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
71 the_fun->cfg->count_max = profile_count::uninitialized ();
111
kono
parents: 67
diff changeset
72 ENTRY_BLOCK_PTR_FOR_FN (the_fun)
kono
parents: 67
diff changeset
73 = alloc_block ();
kono
parents: 67
diff changeset
74 ENTRY_BLOCK_PTR_FOR_FN (the_fun)->index = ENTRY_BLOCK;
kono
parents: 67
diff changeset
75 EXIT_BLOCK_PTR_FOR_FN (the_fun)
kono
parents: 67
diff changeset
76 = alloc_block ();
kono
parents: 67
diff changeset
77 EXIT_BLOCK_PTR_FOR_FN (the_fun)->index = EXIT_BLOCK;
kono
parents: 67
diff changeset
78 ENTRY_BLOCK_PTR_FOR_FN (the_fun)->next_bb
kono
parents: 67
diff changeset
79 = EXIT_BLOCK_PTR_FOR_FN (the_fun);
kono
parents: 67
diff changeset
80 EXIT_BLOCK_PTR_FOR_FN (the_fun)->prev_bb
kono
parents: 67
diff changeset
81 = ENTRY_BLOCK_PTR_FOR_FN (the_fun);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
82 the_fun->cfg->edge_flags_allocated = EDGE_ALL_FLAGS;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
83 the_fun->cfg->bb_flags_allocated = BB_ALL_FLAGS;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 /* Helper function for remove_edge and clear_edges. Frees edge structure
111
kono
parents: 67
diff changeset
87 without actually removing it from the pred/succ arrays. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 static void
111
kono
parents: 67
diff changeset
90 free_edge (function *fn, edge e)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 {
111
kono
parents: 67
diff changeset
92 n_edges_for_fn (fn)--;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 ggc_free (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 /* Free the memory associated with the edge structures. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 void
111
kono
parents: 67
diff changeset
99 clear_edges (struct function *fn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
111
kono
parents: 67
diff changeset
105 FOR_EACH_BB_FN (bb, fn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 FOR_EACH_EDGE (e, ei, bb->succs)
111
kono
parents: 67
diff changeset
108 free_edge (fn, e);
kono
parents: 67
diff changeset
109 vec_safe_truncate (bb->succs, 0);
kono
parents: 67
diff changeset
110 vec_safe_truncate (bb->preds, 0);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
111
kono
parents: 67
diff changeset
113 FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR_FOR_FN (fn)->succs)
kono
parents: 67
diff changeset
114 free_edge (fn, e);
kono
parents: 67
diff changeset
115 vec_safe_truncate (EXIT_BLOCK_PTR_FOR_FN (fn)->preds, 0);
kono
parents: 67
diff changeset
116 vec_safe_truncate (ENTRY_BLOCK_PTR_FOR_FN (fn)->succs, 0);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117
111
kono
parents: 67
diff changeset
118 gcc_assert (!n_edges_for_fn (fn));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 /* Allocate memory for basic_block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 basic_block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 alloc_block (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 basic_block bb;
111
kono
parents: 67
diff changeset
127 bb = ggc_cleared_alloc<basic_block_def> ();
kono
parents: 67
diff changeset
128 bb->count = profile_count::uninitialized ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 return bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 /* Link block B to chain after AFTER. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 link_block (basic_block b, basic_block after)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 b->next_bb = after->next_bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 b->prev_bb = after;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 after->next_bb = b;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 b->next_bb->prev_bb = b;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 /* Unlink block B from chain. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 unlink_block (basic_block b)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 b->next_bb->prev_bb = b->prev_bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 b->prev_bb->next_bb = b->next_bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 b->prev_bb = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 b->next_bb = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 /* Sequentially order blocks and compact the arrays. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 compact_blocks (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157
111
kono
parents: 67
diff changeset
158 SET_BASIC_BLOCK_FOR_FN (cfun, ENTRY_BLOCK, ENTRY_BLOCK_PTR_FOR_FN (cfun));
kono
parents: 67
diff changeset
159 SET_BASIC_BLOCK_FOR_FN (cfun, EXIT_BLOCK, EXIT_BLOCK_PTR_FOR_FN (cfun));
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
160
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 if (df)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 df_compact_blocks ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
163 else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 basic_block bb;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
166
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 i = NUM_FIXED_BLOCKS;
111
kono
parents: 67
diff changeset
168 FOR_EACH_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 {
111
kono
parents: 67
diff changeset
170 SET_BASIC_BLOCK_FOR_FN (cfun, i, bb);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 bb->index = i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 i++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 }
111
kono
parents: 67
diff changeset
174 gcc_assert (i == n_basic_blocks_for_fn (cfun));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175
111
kono
parents: 67
diff changeset
176 for (; i < last_basic_block_for_fn (cfun); i++)
kono
parents: 67
diff changeset
177 SET_BASIC_BLOCK_FOR_FN (cfun, i, NULL);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 }
111
kono
parents: 67
diff changeset
179 last_basic_block_for_fn (cfun) = n_basic_blocks_for_fn (cfun);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 /* Remove block B from the basic block array. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 expunge_block (basic_block b)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 unlink_block (b);
111
kono
parents: 67
diff changeset
188 SET_BASIC_BLOCK_FOR_FN (cfun, b->index, NULL);
kono
parents: 67
diff changeset
189 n_basic_blocks_for_fn (cfun)--;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 /* We should be able to ggc_free here, but we are not.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 The dead SSA_NAMES are left pointing to dead statements that are pointing
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 to dead basic blocks making garbage collector to die.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 We should be able to release all dead SSA_NAMES and at the same time we should
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 clear out BB pointer of dead statements consistently. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 /* Connect E to E->src. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 static inline void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 connect_src (edge e)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 {
111
kono
parents: 67
diff changeset
202 vec_safe_push (e->src->succs, e);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 df_mark_solutions_dirty ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 /* Connect E to E->dest. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 static inline void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 connect_dest (edge e)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 basic_block dest = e->dest;
111
kono
parents: 67
diff changeset
212 vec_safe_push (dest->preds, e);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 e->dest_idx = EDGE_COUNT (dest->preds) - 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 df_mark_solutions_dirty ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 /* Disconnect edge E from E->src. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 static inline void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 disconnect_src (edge e)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 basic_block src = e->src;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 edge tmp;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 for (ei = ei_start (src->succs); (tmp = ei_safe_edge (ei)); )
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 if (tmp == e)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 {
111
kono
parents: 67
diff changeset
230 src->succs->unordered_remove (ei.index);
kono
parents: 67
diff changeset
231 df_mark_solutions_dirty ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 ei_next (&ei);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 gcc_unreachable ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 /* Disconnect edge E from E->dest. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 static inline void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 disconnect_dest (edge e)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 basic_block dest = e->dest;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 unsigned int dest_idx = e->dest_idx;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248
111
kono
parents: 67
diff changeset
249 dest->preds->unordered_remove (dest_idx);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 /* If we removed an edge in the middle of the edge vector, we need
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 to update dest_idx of the edge that moved into the "hole". */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 if (dest_idx < EDGE_COUNT (dest->preds))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 EDGE_PRED (dest, dest_idx)->dest_idx = dest_idx;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 df_mark_solutions_dirty ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 /* Create an edge connecting SRC and DEST with flags FLAGS. Return newly
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 created edge. Use this only if you are sure that this edge can't
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 possibly already exist. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 edge
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 unchecked_make_edge (basic_block src, basic_block dst, int flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 edge e;
111
kono
parents: 67
diff changeset
266 e = ggc_cleared_alloc<edge_def> ();
kono
parents: 67
diff changeset
267 n_edges_for_fn (cfun)++;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268
111
kono
parents: 67
diff changeset
269 e->probability = profile_probability::uninitialized ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 e->src = src;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 e->dest = dst;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 e->flags = flags;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 connect_src (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 connect_dest (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 execute_on_growing_pred (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 return e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 /* Create an edge connecting SRC and DST with FLAGS optionally using
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 edge cache CACHE. Return the new edge, NULL if already exist. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 edge
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 cached_make_edge (sbitmap edge_cache, basic_block src, basic_block dst, int flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 if (edge_cache == NULL
111
kono
parents: 67
diff changeset
288 || src == ENTRY_BLOCK_PTR_FOR_FN (cfun)
kono
parents: 67
diff changeset
289 || dst == EXIT_BLOCK_PTR_FOR_FN (cfun))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 return make_edge (src, dst, flags);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 /* Does the requested edge already exist? */
111
kono
parents: 67
diff changeset
293 if (! bitmap_bit_p (edge_cache, dst->index))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 /* The edge does not exist. Create one and update the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 cache. */
111
kono
parents: 67
diff changeset
297 bitmap_set_bit (edge_cache, dst->index);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 return unchecked_make_edge (src, dst, flags);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 /* At this point, we know that the requested edge exists. Adjust
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 flags if necessary. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 if (flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 edge e = find_edge (src, dst);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 e->flags |= flags;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 /* Create an edge connecting SRC and DEST with flags FLAGS. Return newly
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 created edge or NULL if already exist. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 edge
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 make_edge (basic_block src, basic_block dest, int flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 edge e = find_edge (src, dest);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 /* Make sure we don't add duplicate edges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 if (e)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 e->flags |= flags;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 return unchecked_make_edge (src, dest, flags);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 /* Create an edge connecting SRC to DEST and set probability by knowing
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 that it is the single edge leaving SRC. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 edge
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 make_single_succ_edge (basic_block src, basic_block dest, int flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 edge e = make_edge (src, dest, flags);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337
111
kono
parents: 67
diff changeset
338 e->probability = profile_probability::always ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 return e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 /* This function will remove an edge from the flow graph. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 remove_edge_raw (edge e)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 remove_predictions_associated_with_edge (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 execute_on_shrinking_pred (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 disconnect_src (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 disconnect_dest (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352
111
kono
parents: 67
diff changeset
353 free_edge (cfun, e);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 /* Redirect an edge's successor from one block to another. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 redirect_edge_succ (edge e, basic_block new_succ)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 execute_on_shrinking_pred (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 disconnect_dest (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 e->dest = new_succ;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 /* Reconnect the edge to the new successor block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 connect_dest (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 execute_on_growing_pred (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 /* Redirect an edge's predecessor from one block to another. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 redirect_edge_pred (edge e, basic_block new_pred)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 disconnect_src (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 e->src = new_pred;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 /* Reconnect the edge to the new predecessor block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 connect_src (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385
111
kono
parents: 67
diff changeset
386 /* Clear all basic block flags that do not have to be preserved. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 clear_bb_flags (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 basic_block bb;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
391 int flags_to_preserve = BB_FLAGS_TO_PRESERVE;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
392 if (current_loops
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
393 && loops_state_satisfies_p (cfun, LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
394 flags_to_preserve |= BB_IRREDUCIBLE_LOOP;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395
111
kono
parents: 67
diff changeset
396 FOR_ALL_BB_FN (bb, cfun)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
397 bb->flags &= flags_to_preserve;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 /* Check the consistency of profile information. We can't do that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 in verify_flow_info, as the counts may get invalid for incompletely
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 solved graphs, later eliminating of conditionals or roundoff errors.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 It is still practical to have them reported for debugging of simple
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 testcases. */
111
kono
parents: 67
diff changeset
405 static void
kono
parents: 67
diff changeset
406 check_bb_profile (basic_block bb, FILE * file, int indent)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 edge_iterator ei;
111
kono
parents: 67
diff changeset
410 struct function *fun = DECL_STRUCT_FUNCTION (current_function_decl);
kono
parents: 67
diff changeset
411 char *s_indent = (char *) alloca ((size_t) indent + 1);
kono
parents: 67
diff changeset
412 memset ((void *) s_indent, ' ', (size_t) indent);
kono
parents: 67
diff changeset
413 s_indent[indent] = '\0';
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414
111
kono
parents: 67
diff changeset
415 if (profile_status_for_fn (fun) == PROFILE_ABSENT)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417
111
kono
parents: 67
diff changeset
418 if (bb != EXIT_BLOCK_PTR_FOR_FN (fun))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 {
111
kono
parents: 67
diff changeset
420 bool found = false;
kono
parents: 67
diff changeset
421 profile_probability sum = profile_probability::never ();
kono
parents: 67
diff changeset
422 int isum = 0;
kono
parents: 67
diff changeset
423
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 FOR_EACH_EDGE (e, ei, bb->succs)
111
kono
parents: 67
diff changeset
425 {
kono
parents: 67
diff changeset
426 if (!(e->flags & (EDGE_EH | EDGE_FAKE)))
kono
parents: 67
diff changeset
427 found = true;
kono
parents: 67
diff changeset
428 sum += e->probability;
kono
parents: 67
diff changeset
429 if (e->probability.initialized_p ())
kono
parents: 67
diff changeset
430 isum += e->probability.to_reg_br_prob_base ();
kono
parents: 67
diff changeset
431 }
kono
parents: 67
diff changeset
432 /* Only report mismatches for non-EH control flow. If there are only EH
kono
parents: 67
diff changeset
433 edges it means that the BB ends by noreturn call. Here the control
kono
parents: 67
diff changeset
434 flow may just terminate. */
kono
parents: 67
diff changeset
435 if (found)
kono
parents: 67
diff changeset
436 {
kono
parents: 67
diff changeset
437 if (sum.differs_from_p (profile_probability::always ()))
kono
parents: 67
diff changeset
438 {
kono
parents: 67
diff changeset
439 fprintf (file,
kono
parents: 67
diff changeset
440 ";; %sInvalid sum of outgoing probabilities ",
kono
parents: 67
diff changeset
441 s_indent);
kono
parents: 67
diff changeset
442 sum.dump (file);
kono
parents: 67
diff changeset
443 fprintf (file, "\n");
kono
parents: 67
diff changeset
444 }
kono
parents: 67
diff changeset
445 /* Probabilities caps to 100% and thus the previous test will never
kono
parents: 67
diff changeset
446 fire if the sum of probabilities is too large. */
kono
parents: 67
diff changeset
447 else if (isum > REG_BR_PROB_BASE + 100)
kono
parents: 67
diff changeset
448 {
kono
parents: 67
diff changeset
449 fprintf (file,
kono
parents: 67
diff changeset
450 ";; %sInvalid sum of outgoing probabilities %.1f%%\n",
kono
parents: 67
diff changeset
451 s_indent, isum * 100.0 / REG_BR_PROB_BASE);
kono
parents: 67
diff changeset
452 }
kono
parents: 67
diff changeset
453 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 }
111
kono
parents: 67
diff changeset
455 if (bb != ENTRY_BLOCK_PTR_FOR_FN (fun))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
457 profile_count sum = profile_count::zero ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 FOR_EACH_EDGE (e, ei, bb->preds)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
459 sum += e->count ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
460 if (sum.differs_from_p (bb->count))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
461 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
462 fprintf (file, ";; %sInvalid sum of incoming counts ",
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
463 s_indent);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
464 sum.dump (file);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
465 fprintf (file, ", should be ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
466 bb->count.dump (file);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
467 fprintf (file, "\n");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
468 }
111
kono
parents: 67
diff changeset
469 }
kono
parents: 67
diff changeset
470 if (BB_PARTITION (bb) == BB_COLD_PARTITION)
kono
parents: 67
diff changeset
471 {
kono
parents: 67
diff changeset
472 /* Warn about inconsistencies in the partitioning that are
kono
parents: 67
diff changeset
473 currently caused by profile insanities created via optimization. */
kono
parents: 67
diff changeset
474 if (!probably_never_executed_bb_p (fun, bb))
kono
parents: 67
diff changeset
475 fprintf (file, ";; %sBlock in cold partition with hot count\n",
kono
parents: 67
diff changeset
476 s_indent);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 FOR_EACH_EDGE (e, ei, bb->preds)
111
kono
parents: 67
diff changeset
478 {
kono
parents: 67
diff changeset
479 if (!probably_never_executed_edge_p (fun, e))
kono
parents: 67
diff changeset
480 fprintf (file,
kono
parents: 67
diff changeset
481 ";; %sBlock in cold partition with incoming hot edge\n",
kono
parents: 67
diff changeset
482 s_indent);
kono
parents: 67
diff changeset
483 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 void
111
kono
parents: 67
diff changeset
488 dump_edge_info (FILE *file, edge e, dump_flags_t flags, int do_succ)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 basic_block side = (do_succ ? e->dest : e->src);
111
kono
parents: 67
diff changeset
491 bool do_details = false;
kono
parents: 67
diff changeset
492
kono
parents: 67
diff changeset
493 if ((flags & TDF_DETAILS) != 0
kono
parents: 67
diff changeset
494 && (flags & TDF_SLIM) == 0)
kono
parents: 67
diff changeset
495 do_details = true;
kono
parents: 67
diff changeset
496
kono
parents: 67
diff changeset
497 if (side->index == ENTRY_BLOCK)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 fputs (" ENTRY", file);
111
kono
parents: 67
diff changeset
499 else if (side->index == EXIT_BLOCK)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 fputs (" EXIT", file);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 fprintf (file, " %d", side->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503
111
kono
parents: 67
diff changeset
504 if (e->probability.initialized_p () && do_details)
kono
parents: 67
diff changeset
505 {
kono
parents: 67
diff changeset
506 fprintf (file, " [");
kono
parents: 67
diff changeset
507 e->probability.dump (file);
kono
parents: 67
diff changeset
508 fprintf (file, "] ");
kono
parents: 67
diff changeset
509 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510
111
kono
parents: 67
diff changeset
511 if (e->count ().initialized_p () && do_details)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
513 fputs (" count:", file);
111
kono
parents: 67
diff changeset
514 e->count ().dump (file);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516
111
kono
parents: 67
diff changeset
517 if (e->flags && do_details)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 {
111
kono
parents: 67
diff changeset
519 static const char * const bitnames[] =
kono
parents: 67
diff changeset
520 {
kono
parents: 67
diff changeset
521 #define DEF_EDGE_FLAG(NAME,IDX) #NAME ,
kono
parents: 67
diff changeset
522 #include "cfg-flags.def"
kono
parents: 67
diff changeset
523 NULL
kono
parents: 67
diff changeset
524 #undef DEF_EDGE_FLAG
kono
parents: 67
diff changeset
525 };
kono
parents: 67
diff changeset
526 bool comma = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 int i, flags = e->flags;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528
111
kono
parents: 67
diff changeset
529 gcc_assert (e->flags <= EDGE_ALL_FLAGS);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 fputs (" (", file);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 for (i = 0; flags; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 if (flags & (1 << i))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 flags &= ~(1 << i);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 if (comma)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 fputc (',', file);
111
kono
parents: 67
diff changeset
538 fputs (bitnames[i], file);
kono
parents: 67
diff changeset
539 comma = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 fputc (')', file);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 }
111
kono
parents: 67
diff changeset
545
kono
parents: 67
diff changeset
546 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
547 debug (edge_def &ref)
kono
parents: 67
diff changeset
548 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
549 fprintf (stderr, "<edge (%d -> %d)>\n",
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
550 ref.src->index, ref.dest->index);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
551 dump_edge_info (stderr, &ref, TDF_DETAILS, false);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
552 fprintf (stderr, "\n");
111
kono
parents: 67
diff changeset
553 }
kono
parents: 67
diff changeset
554
kono
parents: 67
diff changeset
555 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
556 debug (edge_def *ptr)
kono
parents: 67
diff changeset
557 {
kono
parents: 67
diff changeset
558 if (ptr)
kono
parents: 67
diff changeset
559 debug (*ptr);
kono
parents: 67
diff changeset
560 else
kono
parents: 67
diff changeset
561 fprintf (stderr, "<nil>\n");
kono
parents: 67
diff changeset
562 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
563
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
564 static void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
565 debug_slim (edge e)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
566 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
567 fprintf (stderr, "<edge 0x%p (%d -> %d)>", (void *) e,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
568 e->src->index, e->dest->index);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
569 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
570
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
571 DEFINE_DEBUG_VEC (edge)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
572 DEFINE_DEBUG_HASH_SET (edge)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 /* Simple routines to easily allocate AUX fields of basic blocks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 static struct obstack block_aux_obstack;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 static void *first_block_aux_obj = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 static struct obstack edge_aux_obstack;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 static void *first_edge_aux_obj = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 /* Allocate a memory block of SIZE as BB->aux. The obstack must
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 be first initialized by alloc_aux_for_blocks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
584 static void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 alloc_aux_for_block (basic_block bb, int size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 /* Verify that aux field is clear. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 gcc_assert (!bb->aux && first_block_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 bb->aux = obstack_alloc (&block_aux_obstack, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 memset (bb->aux, 0, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 /* Initialize the block_aux_obstack and if SIZE is nonzero, call
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 alloc_aux_for_block for each basic block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 alloc_aux_for_blocks (int size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 static int initialized;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 if (!initialized)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 gcc_obstack_init (&block_aux_obstack);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 initialized = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 /* Check whether AUX data are still allocated. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 gcc_assert (!first_block_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 first_block_aux_obj = obstack_alloc (&block_aux_obstack, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 if (size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
614
111
kono
parents: 67
diff changeset
615 FOR_ALL_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 alloc_aux_for_block (bb, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
619
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 /* Clear AUX pointers of all blocks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 clear_aux_for_blocks (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
626
111
kono
parents: 67
diff changeset
627 FOR_ALL_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 bb->aux = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
630
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 /* Free data allocated in block_aux_obstack and clear AUX pointers
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 of all blocks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 free_aux_for_blocks (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 gcc_assert (first_block_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 obstack_free (&block_aux_obstack, first_block_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 first_block_aux_obj = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
640
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 clear_aux_for_blocks ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
643
111
kono
parents: 67
diff changeset
644 /* Allocate a memory edge of SIZE as E->aux. The obstack must
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 be first initialized by alloc_aux_for_edges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646
111
kono
parents: 67
diff changeset
647 void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 alloc_aux_for_edge (edge e, int size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 /* Verify that aux field is clear. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 gcc_assert (!e->aux && first_edge_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 e->aux = obstack_alloc (&edge_aux_obstack, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 memset (e->aux, 0, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
655
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 /* Initialize the edge_aux_obstack and if SIZE is nonzero, call
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 alloc_aux_for_edge for each basic edge. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
658
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 alloc_aux_for_edges (int size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 static int initialized;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
663
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 if (!initialized)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 gcc_obstack_init (&edge_aux_obstack);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 initialized = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
670 /* Check whether AUX data are still allocated. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
671 gcc_assert (!first_edge_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 first_edge_aux_obj = obstack_alloc (&edge_aux_obstack, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 if (size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
677
111
kono
parents: 67
diff changeset
678 FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun),
kono
parents: 67
diff changeset
679 EXIT_BLOCK_PTR_FOR_FN (cfun), next_bb)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 FOR_EACH_EDGE (e, ei, bb->succs)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 alloc_aux_for_edge (e, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
689
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690 /* Clear AUX pointers of all edges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 clear_aux_for_edges (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697
111
kono
parents: 67
diff changeset
698 FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun),
kono
parents: 67
diff changeset
699 EXIT_BLOCK_PTR_FOR_FN (cfun), next_bb)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 FOR_EACH_EDGE (e, ei, bb->succs)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 e->aux = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 /* Free data allocated in edge_aux_obstack and clear AUX pointers
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 of all edges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
709
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 free_aux_for_edges (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 gcc_assert (first_edge_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 obstack_free (&edge_aux_obstack, first_edge_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 first_edge_aux_obj = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
716
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 clear_aux_for_edges ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
719
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
720 DEBUG_FUNCTION void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 debug_bb (basic_block bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 {
111
kono
parents: 67
diff changeset
723 dump_bb (stderr, bb, 0, dump_flags);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
725
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
726 DEBUG_FUNCTION basic_block
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 debug_bb_n (int n)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 {
111
kono
parents: 67
diff changeset
729 basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
kono
parents: 67
diff changeset
730 debug_bb (bb);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 return bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
733
111
kono
parents: 67
diff changeset
734 /* Dumps cfg related information about basic block BB to OUTF.
kono
parents: 67
diff changeset
735 If HEADER is true, dump things that appear before the instructions
kono
parents: 67
diff changeset
736 contained in BB. If FOOTER is true, dump things that appear after.
kono
parents: 67
diff changeset
737 Flags are the TDF_* masks as documented in dumpfile.h.
kono
parents: 67
diff changeset
738 NB: With TDF_DETAILS, it is assumed that cfun is available, so
kono
parents: 67
diff changeset
739 that maybe_hot_bb_p and probably_never_executed_bb_p don't ICE. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
740
111
kono
parents: 67
diff changeset
741 void
kono
parents: 67
diff changeset
742 dump_bb_info (FILE *outf, basic_block bb, int indent, dump_flags_t flags,
kono
parents: 67
diff changeset
743 bool do_header, bool do_footer)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 edge_iterator ei;
111
kono
parents: 67
diff changeset
746 edge e;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 static const char * const bb_bitnames[] =
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 {
111
kono
parents: 67
diff changeset
749 #define DEF_BASIC_BLOCK_FLAG(NAME,IDX) #NAME ,
kono
parents: 67
diff changeset
750 #include "cfg-flags.def"
kono
parents: 67
diff changeset
751 NULL
kono
parents: 67
diff changeset
752 #undef DEF_BASIC_BLOCK_FLAG
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 const unsigned n_bitnames = sizeof (bb_bitnames) / sizeof (char *);
111
kono
parents: 67
diff changeset
755 bool first;
kono
parents: 67
diff changeset
756 char *s_indent = (char *) alloca ((size_t) indent + 1);
kono
parents: 67
diff changeset
757 memset ((void *) s_indent, ' ', (size_t) indent);
kono
parents: 67
diff changeset
758 s_indent[indent] = '\0';
kono
parents: 67
diff changeset
759
kono
parents: 67
diff changeset
760 gcc_assert (bb->flags <= BB_ALL_FLAGS);
kono
parents: 67
diff changeset
761
kono
parents: 67
diff changeset
762 if (do_header)
kono
parents: 67
diff changeset
763 {
kono
parents: 67
diff changeset
764 unsigned i;
kono
parents: 67
diff changeset
765
kono
parents: 67
diff changeset
766 fputs (";; ", outf);
kono
parents: 67
diff changeset
767 fprintf (outf, "%sbasic block %d, loop depth %d",
kono
parents: 67
diff changeset
768 s_indent, bb->index, bb_loop_depth (bb));
kono
parents: 67
diff changeset
769 if (flags & TDF_DETAILS)
kono
parents: 67
diff changeset
770 {
kono
parents: 67
diff changeset
771 struct function *fun = DECL_STRUCT_FUNCTION (current_function_decl);
kono
parents: 67
diff changeset
772 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
773 {
kono
parents: 67
diff changeset
774 fputs (", count ", outf);
kono
parents: 67
diff changeset
775 bb->count.dump (outf);
kono
parents: 67
diff changeset
776 }
kono
parents: 67
diff changeset
777 if (maybe_hot_bb_p (fun, bb))
kono
parents: 67
diff changeset
778 fputs (", maybe hot", outf);
kono
parents: 67
diff changeset
779 if (probably_never_executed_bb_p (fun, bb))
kono
parents: 67
diff changeset
780 fputs (", probably never executed", outf);
kono
parents: 67
diff changeset
781 }
kono
parents: 67
diff changeset
782 fputc ('\n', outf);
kono
parents: 67
diff changeset
783
kono
parents: 67
diff changeset
784 if (flags & TDF_DETAILS)
kono
parents: 67
diff changeset
785 {
kono
parents: 67
diff changeset
786 check_bb_profile (bb, outf, indent);
kono
parents: 67
diff changeset
787 fputs (";; ", outf);
kono
parents: 67
diff changeset
788 fprintf (outf, "%s prev block ", s_indent);
kono
parents: 67
diff changeset
789 if (bb->prev_bb)
kono
parents: 67
diff changeset
790 fprintf (outf, "%d", bb->prev_bb->index);
kono
parents: 67
diff changeset
791 else
kono
parents: 67
diff changeset
792 fprintf (outf, "(nil)");
kono
parents: 67
diff changeset
793 fprintf (outf, ", next block ");
kono
parents: 67
diff changeset
794 if (bb->next_bb)
kono
parents: 67
diff changeset
795 fprintf (outf, "%d", bb->next_bb->index);
kono
parents: 67
diff changeset
796 else
kono
parents: 67
diff changeset
797 fprintf (outf, "(nil)");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
798
111
kono
parents: 67
diff changeset
799 fputs (", flags:", outf);
kono
parents: 67
diff changeset
800 first = true;
kono
parents: 67
diff changeset
801 for (i = 0; i < n_bitnames; i++)
kono
parents: 67
diff changeset
802 if (bb->flags & (1 << i))
kono
parents: 67
diff changeset
803 {
kono
parents: 67
diff changeset
804 if (first)
kono
parents: 67
diff changeset
805 fputs (" (", outf);
kono
parents: 67
diff changeset
806 else
kono
parents: 67
diff changeset
807 fputs (", ", outf);
kono
parents: 67
diff changeset
808 first = false;
kono
parents: 67
diff changeset
809 fputs (bb_bitnames[i], outf);
kono
parents: 67
diff changeset
810 }
kono
parents: 67
diff changeset
811 if (!first)
kono
parents: 67
diff changeset
812 fputc (')', outf);
kono
parents: 67
diff changeset
813 fputc ('\n', outf);
kono
parents: 67
diff changeset
814 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
815
111
kono
parents: 67
diff changeset
816 fputs (";; ", outf);
kono
parents: 67
diff changeset
817 fprintf (outf, "%s pred: ", s_indent);
kono
parents: 67
diff changeset
818 first = true;
kono
parents: 67
diff changeset
819 FOR_EACH_EDGE (e, ei, bb->preds)
kono
parents: 67
diff changeset
820 {
kono
parents: 67
diff changeset
821 if (! first)
kono
parents: 67
diff changeset
822 {
kono
parents: 67
diff changeset
823 fputs (";; ", outf);
kono
parents: 67
diff changeset
824 fprintf (outf, "%s ", s_indent);
kono
parents: 67
diff changeset
825 }
kono
parents: 67
diff changeset
826 first = false;
kono
parents: 67
diff changeset
827 dump_edge_info (outf, e, flags, 0);
kono
parents: 67
diff changeset
828 fputc ('\n', outf);
kono
parents: 67
diff changeset
829 }
kono
parents: 67
diff changeset
830 if (first)
kono
parents: 67
diff changeset
831 fputc ('\n', outf);
kono
parents: 67
diff changeset
832 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
833
111
kono
parents: 67
diff changeset
834 if (do_footer)
kono
parents: 67
diff changeset
835 {
kono
parents: 67
diff changeset
836 fputs (";; ", outf);
kono
parents: 67
diff changeset
837 fprintf (outf, "%s succ: ", s_indent);
kono
parents: 67
diff changeset
838 first = true;
kono
parents: 67
diff changeset
839 FOR_EACH_EDGE (e, ei, bb->succs)
kono
parents: 67
diff changeset
840 {
kono
parents: 67
diff changeset
841 if (! first)
kono
parents: 67
diff changeset
842 {
kono
parents: 67
diff changeset
843 fputs (";; ", outf);
kono
parents: 67
diff changeset
844 fprintf (outf, "%s ", s_indent);
kono
parents: 67
diff changeset
845 }
kono
parents: 67
diff changeset
846 first = false;
kono
parents: 67
diff changeset
847 dump_edge_info (outf, e, flags, 1);
kono
parents: 67
diff changeset
848 fputc ('\n', outf);
kono
parents: 67
diff changeset
849 }
kono
parents: 67
diff changeset
850 if (first)
kono
parents: 67
diff changeset
851 fputc ('\n', outf);
kono
parents: 67
diff changeset
852 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 /* Dumps a brief description of cfg to FILE. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 void
111
kono
parents: 67
diff changeset
858 brief_dump_cfg (FILE *file, dump_flags_t flags)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
861
111
kono
parents: 67
diff changeset
862 FOR_EACH_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 {
111
kono
parents: 67
diff changeset
864 dump_bb_info (file, bb, 0, flags & TDF_DETAILS, true, true);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
868 /* An edge originally destinating BB of COUNT has been proved to
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 leave the block by TAKEN_EDGE. Update profile of BB such that edge E can be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 redirected to destination of TAKEN_EDGE.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
871
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 This function may leave the profile inconsistent in the case TAKEN_EDGE
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
873 frequency or count is believed to be lower than COUNT
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 respectively. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
876 update_bb_profile_for_threading (basic_block bb,
111
kono
parents: 67
diff changeset
877 profile_count count, edge taken_edge)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 edge c;
111
kono
parents: 67
diff changeset
880 profile_probability prob;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882
111
kono
parents: 67
diff changeset
883 if (bb->count < count)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 fprintf (dump_file, "bb %i count became negative after threading",
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 bb->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 }
111
kono
parents: 67
diff changeset
889 bb->count -= count;
kono
parents: 67
diff changeset
890
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
891 /* Compute the probability of TAKEN_EDGE being reached via threaded edge.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
892 Watch for overflows. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
893 if (bb->count.nonzero_p ())
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
894 prob = count.probability_in (bb->count);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 else
111
kono
parents: 67
diff changeset
896 prob = profile_probability::never ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 if (prob > taken_edge->probability)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
898 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 if (dump_file)
111
kono
parents: 67
diff changeset
900 {
kono
parents: 67
diff changeset
901 fprintf (dump_file, "Jump threading proved probability of edge "
kono
parents: 67
diff changeset
902 "%i->%i too small (it is ",
kono
parents: 67
diff changeset
903 taken_edge->src->index, taken_edge->dest->index);
kono
parents: 67
diff changeset
904 taken_edge->probability.dump (dump_file);
kono
parents: 67
diff changeset
905 fprintf (dump_file, " should be ");
kono
parents: 67
diff changeset
906 prob.dump (dump_file);
kono
parents: 67
diff changeset
907 fprintf (dump_file, ")\n");
kono
parents: 67
diff changeset
908 }
kono
parents: 67
diff changeset
909 prob = taken_edge->probability.apply_scale (6, 8);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
911
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 /* Now rescale the probabilities. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
913 taken_edge->probability -= prob;
111
kono
parents: 67
diff changeset
914 prob = prob.invert ();
kono
parents: 67
diff changeset
915 if (prob == profile_probability::never ())
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
917 if (dump_file)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
918 fprintf (dump_file, "Edge probabilities of bb %i has been reset, "
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
919 "count of block should end up being 0, it is non-zero\n",
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
920 bb->index);
111
kono
parents: 67
diff changeset
921 EDGE_SUCC (bb, 0)->probability = profile_probability::guessed_always ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
922 ei = ei_start (bb->succs);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 ei_next (&ei);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 for (; (c = ei_safe_edge (ei)); ei_next (&ei))
111
kono
parents: 67
diff changeset
925 c->probability = profile_probability::guessed_never ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
926 }
111
kono
parents: 67
diff changeset
927 else if (!(prob == profile_probability::always ()))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
928 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
929 FOR_EACH_EDGE (c, ei, bb->succs)
111
kono
parents: 67
diff changeset
930 c->probability /= prob;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
931 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
932
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 gcc_assert (bb == taken_edge->src);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
935
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 /* Multiply all frequencies of basic blocks in array BBS of length NBBS
111
kono
parents: 67
diff changeset
937 by NUM/DEN, in profile_count arithmetic. More accurate than previous
kono
parents: 67
diff changeset
938 function but considerably slower. */
kono
parents: 67
diff changeset
939 void
kono
parents: 67
diff changeset
940 scale_bbs_frequencies_profile_count (basic_block *bbs, int nbbs,
kono
parents: 67
diff changeset
941 profile_count num, profile_count den)
kono
parents: 67
diff changeset
942 {
kono
parents: 67
diff changeset
943 int i;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
944 if (num == profile_count::zero () || den.nonzero_p ())
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
945 for (i = 0; i < nbbs; i++)
111
kono
parents: 67
diff changeset
946 bbs[i]->count = bbs[i]->count.apply_scale (num, den);
kono
parents: 67
diff changeset
947 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
948
111
kono
parents: 67
diff changeset
949 /* Multiply all frequencies of basic blocks in array BBS of length NBBS
kono
parents: 67
diff changeset
950 by NUM/DEN, in profile_count arithmetic. More accurate than previous
kono
parents: 67
diff changeset
951 function but considerably slower. */
kono
parents: 67
diff changeset
952 void
kono
parents: 67
diff changeset
953 scale_bbs_frequencies (basic_block *bbs, int nbbs,
kono
parents: 67
diff changeset
954 profile_probability p)
kono
parents: 67
diff changeset
955 {
kono
parents: 67
diff changeset
956 int i;
kono
parents: 67
diff changeset
957
kono
parents: 67
diff changeset
958 for (i = 0; i < nbbs; i++)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
959 bbs[i]->count = bbs[i]->count.apply_probability (p);
111
kono
parents: 67
diff changeset
960 }
kono
parents: 67
diff changeset
961
kono
parents: 67
diff changeset
962 /* Helper types for hash tables. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
963
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 struct htab_bb_copy_original_entry
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
966 /* Block we are attaching info to. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 int index1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 /* Index of original or copy (depending on the hashtable) */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 int index2;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971
111
kono
parents: 67
diff changeset
972 struct bb_copy_hasher : nofree_ptr_hash <htab_bb_copy_original_entry>
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
973 {
111
kono
parents: 67
diff changeset
974 static inline hashval_t hash (const htab_bb_copy_original_entry *);
kono
parents: 67
diff changeset
975 static inline bool equal (const htab_bb_copy_original_entry *existing,
kono
parents: 67
diff changeset
976 const htab_bb_copy_original_entry * candidate);
kono
parents: 67
diff changeset
977 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
978
111
kono
parents: 67
diff changeset
979 inline hashval_t
kono
parents: 67
diff changeset
980 bb_copy_hasher::hash (const htab_bb_copy_original_entry *data)
kono
parents: 67
diff changeset
981 {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 return data->index1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 }
111
kono
parents: 67
diff changeset
984
kono
parents: 67
diff changeset
985 inline bool
kono
parents: 67
diff changeset
986 bb_copy_hasher::equal (const htab_bb_copy_original_entry *data,
kono
parents: 67
diff changeset
987 const htab_bb_copy_original_entry *data2)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 return data->index1 == data2->index1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
991
111
kono
parents: 67
diff changeset
992 /* Data structures used to maintain mapping between basic blocks and
kono
parents: 67
diff changeset
993 copies. */
kono
parents: 67
diff changeset
994 static hash_table<bb_copy_hasher> *bb_original;
kono
parents: 67
diff changeset
995 static hash_table<bb_copy_hasher> *bb_copy;
kono
parents: 67
diff changeset
996
kono
parents: 67
diff changeset
997 /* And between loops and copies. */
kono
parents: 67
diff changeset
998 static hash_table<bb_copy_hasher> *loop_copy;
kono
parents: 67
diff changeset
999 static object_allocator<htab_bb_copy_original_entry> *original_copy_bb_pool;
kono
parents: 67
diff changeset
1000
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 /* Initialize the data structures to maintain mapping between blocks
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 and its copies. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 initialize_original_copy_tables (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 {
111
kono
parents: 67
diff changeset
1006 original_copy_bb_pool = new object_allocator<htab_bb_copy_original_entry>
kono
parents: 67
diff changeset
1007 ("original_copy");
kono
parents: 67
diff changeset
1008 bb_original = new hash_table<bb_copy_hasher> (10);
kono
parents: 67
diff changeset
1009 bb_copy = new hash_table<bb_copy_hasher> (10);
kono
parents: 67
diff changeset
1010 loop_copy = new hash_table<bb_copy_hasher> (10);
kono
parents: 67
diff changeset
1011 }
kono
parents: 67
diff changeset
1012
kono
parents: 67
diff changeset
1013 /* Reset the data structures to maintain mapping between blocks and
kono
parents: 67
diff changeset
1014 its copies. */
kono
parents: 67
diff changeset
1015
kono
parents: 67
diff changeset
1016 void
kono
parents: 67
diff changeset
1017 reset_original_copy_tables (void)
kono
parents: 67
diff changeset
1018 {
kono
parents: 67
diff changeset
1019 gcc_assert (original_copy_bb_pool);
kono
parents: 67
diff changeset
1020 bb_original->empty ();
kono
parents: 67
diff changeset
1021 bb_copy->empty ();
kono
parents: 67
diff changeset
1022 loop_copy->empty ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1023 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 /* Free the data structures to maintain mapping between blocks and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026 its copies. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028 free_original_copy_tables (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 gcc_assert (original_copy_bb_pool);
111
kono
parents: 67
diff changeset
1031 delete bb_copy;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032 bb_copy = NULL;
111
kono
parents: 67
diff changeset
1033 delete bb_original;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 bb_original = NULL;
111
kono
parents: 67
diff changeset
1035 delete loop_copy;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036 loop_copy = NULL;
111
kono
parents: 67
diff changeset
1037 delete original_copy_bb_pool;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 original_copy_bb_pool = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040
111
kono
parents: 67
diff changeset
1041 /* Return true iff we have had a call to initialize_original_copy_tables
kono
parents: 67
diff changeset
1042 without a corresponding call to free_original_copy_tables. */
kono
parents: 67
diff changeset
1043
kono
parents: 67
diff changeset
1044 bool
kono
parents: 67
diff changeset
1045 original_copy_tables_initialized_p (void)
kono
parents: 67
diff changeset
1046 {
kono
parents: 67
diff changeset
1047 return original_copy_bb_pool != NULL;
kono
parents: 67
diff changeset
1048 }
kono
parents: 67
diff changeset
1049
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050 /* Removes the value associated with OBJ from table TAB. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 static void
111
kono
parents: 67
diff changeset
1053 copy_original_table_clear (hash_table<bb_copy_hasher> *tab, unsigned obj)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054 {
111
kono
parents: 67
diff changeset
1055 htab_bb_copy_original_entry **slot;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056 struct htab_bb_copy_original_entry key, *elt;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058 if (!original_copy_bb_pool)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 key.index1 = obj;
111
kono
parents: 67
diff changeset
1062 slot = tab->find_slot (&key, NO_INSERT);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 if (!slot)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065
111
kono
parents: 67
diff changeset
1066 elt = *slot;
kono
parents: 67
diff changeset
1067 tab->clear_slot (slot);
kono
parents: 67
diff changeset
1068 original_copy_bb_pool->remove (elt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 /* Sets the value associated with OBJ in table TAB to VAL.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072 Do nothing when data structures are not initialized. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1074 static void
111
kono
parents: 67
diff changeset
1075 copy_original_table_set (hash_table<bb_copy_hasher> *tab,
kono
parents: 67
diff changeset
1076 unsigned obj, unsigned val)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 struct htab_bb_copy_original_entry **slot;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079 struct htab_bb_copy_original_entry key;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081 if (!original_copy_bb_pool)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084 key.index1 = obj;
111
kono
parents: 67
diff changeset
1085 slot = tab->find_slot (&key, INSERT);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 if (!*slot)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087 {
111
kono
parents: 67
diff changeset
1088 *slot = original_copy_bb_pool->allocate ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089 (*slot)->index1 = obj;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1090 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1091 (*slot)->index2 = val;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1092 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 /* Set original for basic block. Do nothing when data structures are not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1095 initialized so passes not needing this don't need to care. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097 set_bb_original (basic_block bb, basic_block original)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 copy_original_table_set (bb_original, bb->index, original->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 /* Get the original basic block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 basic_block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 get_bb_original (basic_block bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106 struct htab_bb_copy_original_entry *entry;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107 struct htab_bb_copy_original_entry key;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109 gcc_assert (original_copy_bb_pool);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 key.index1 = bb->index;
111
kono
parents: 67
diff changeset
1112 entry = bb_original->find (&key);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 if (entry)
111
kono
parents: 67
diff changeset
1114 return BASIC_BLOCK_FOR_FN (cfun, entry->index2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 /* Set copy for basic block. Do nothing when data structures are not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120 initialized so passes not needing this don't need to care. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 set_bb_copy (basic_block bb, basic_block copy)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124 copy_original_table_set (bb_copy, bb->index, copy->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127 /* Get the copy of basic block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128 basic_block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 get_bb_copy (basic_block bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 struct htab_bb_copy_original_entry *entry;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132 struct htab_bb_copy_original_entry key;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 gcc_assert (original_copy_bb_pool);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136 key.index1 = bb->index;
111
kono
parents: 67
diff changeset
1137 entry = bb_copy->find (&key);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1138 if (entry)
111
kono
parents: 67
diff changeset
1139 return BASIC_BLOCK_FOR_FN (cfun, entry->index2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1141 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1144 /* Set copy for LOOP to COPY. Do nothing when data structures are not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1145 initialized so passes not needing this don't need to care. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1146
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147 void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1148 set_loop_copy (class loop *loop, class loop *copy)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150 if (!copy)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 copy_original_table_clear (loop_copy, loop->num);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153 copy_original_table_set (loop_copy, loop->num, copy->num);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1154 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1155
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156 /* Get the copy of LOOP. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1158 class loop *
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1159 get_loop_copy (class loop *loop)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161 struct htab_bb_copy_original_entry *entry;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1162 struct htab_bb_copy_original_entry key;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164 gcc_assert (original_copy_bb_pool);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1166 key.index1 = loop->num;
111
kono
parents: 67
diff changeset
1167 entry = loop_copy->find (&key);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1168 if (entry)
111
kono
parents: 67
diff changeset
1169 return get_loop (cfun, entry->index2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1170 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172 }