annotate gcc/cfg.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
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.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 1987-2018 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 {
kono
parents: 67
diff changeset
549 /* FIXME (crowl): Is this desireable? */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
550 dump_edge_info (stderr, &ref, TDF_NONE, false);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
551 dump_edge_info (stderr, &ref, TDF_NONE, true);
111
kono
parents: 67
diff changeset
552 }
kono
parents: 67
diff changeset
553
kono
parents: 67
diff changeset
554 DEBUG_FUNCTION void
kono
parents: 67
diff changeset
555 debug (edge_def *ptr)
kono
parents: 67
diff changeset
556 {
kono
parents: 67
diff changeset
557 if (ptr)
kono
parents: 67
diff changeset
558 debug (*ptr);
kono
parents: 67
diff changeset
559 else
kono
parents: 67
diff changeset
560 fprintf (stderr, "<nil>\n");
kono
parents: 67
diff changeset
561 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
562
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
563 static void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
564 debug_slim (edge e)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
565 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
566 fprintf (stderr, "<edge 0x%p (%d -> %d)>", (void *) e,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
567 e->src->index, e->dest->index);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
568 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
569
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
570 DEFINE_DEBUG_VEC (edge)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
571 DEFINE_DEBUG_HASH_SET (edge)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
572
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 /* Simple routines to easily allocate AUX fields of basic blocks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 static struct obstack block_aux_obstack;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 static void *first_block_aux_obj = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 static struct obstack edge_aux_obstack;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 static void *first_edge_aux_obj = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 /* 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
581 be first initialized by alloc_aux_for_blocks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582
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
583 static void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 alloc_aux_for_block (basic_block bb, int size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 /* Verify that aux field is clear. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 gcc_assert (!bb->aux && first_block_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 bb->aux = obstack_alloc (&block_aux_obstack, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 memset (bb->aux, 0, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 }
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 /* 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
593 alloc_aux_for_block for each basic block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 alloc_aux_for_blocks (int size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 static int initialized;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 if (!initialized)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 gcc_obstack_init (&block_aux_obstack);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 initialized = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 /* Check whether AUX data are still allocated. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 gcc_assert (!first_block_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 first_block_aux_obj = obstack_alloc (&block_aux_obstack, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 if (size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613
111
kono
parents: 67
diff changeset
614 FOR_ALL_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 alloc_aux_for_block (bb, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 }
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 /* Clear AUX pointers of all blocks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
620
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 clear_aux_for_blocks (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
625
111
kono
parents: 67
diff changeset
626 FOR_ALL_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 bb->aux = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 }
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 /* 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
631 of all blocks. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
632
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 free_aux_for_blocks (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 gcc_assert (first_block_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 obstack_free (&block_aux_obstack, first_block_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 first_block_aux_obj = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
639
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 clear_aux_for_blocks ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
642
111
kono
parents: 67
diff changeset
643 /* 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
644 be first initialized by alloc_aux_for_edges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645
111
kono
parents: 67
diff changeset
646 void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 alloc_aux_for_edge (edge e, int size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 /* Verify that aux field is clear. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 gcc_assert (!e->aux && first_edge_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 e->aux = obstack_alloc (&edge_aux_obstack, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 memset (e->aux, 0, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 }
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 /* 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
656 alloc_aux_for_edge for each basic edge. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
657
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 alloc_aux_for_edges (int size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 static int initialized;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
662
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 if (!initialized)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 gcc_obstack_init (&edge_aux_obstack);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 initialized = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 /* Check whether AUX data are still allocated. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
670 gcc_assert (!first_edge_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
671
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 first_edge_aux_obj = obstack_alloc (&edge_aux_obstack, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 if (size)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
676
111
kono
parents: 67
diff changeset
677 FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun),
kono
parents: 67
diff changeset
678 EXIT_BLOCK_PTR_FOR_FN (cfun), next_bb)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 FOR_EACH_EDGE (e, ei, bb->succs)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 alloc_aux_for_edge (e, size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 }
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 /* Clear AUX pointers of all edges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 clear_aux_for_edges (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
696
111
kono
parents: 67
diff changeset
697 FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun),
kono
parents: 67
diff changeset
698 EXIT_BLOCK_PTR_FOR_FN (cfun), next_bb)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 FOR_EACH_EDGE (e, ei, bb->succs)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 e->aux = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 }
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 /* 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
707 of all edges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
708
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 free_aux_for_edges (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 gcc_assert (first_edge_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 obstack_free (&edge_aux_obstack, first_edge_aux_obj);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 first_edge_aux_obj = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
715
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 clear_aux_for_edges ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
718
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
719 DEBUG_FUNCTION void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 debug_bb (basic_block bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 {
111
kono
parents: 67
diff changeset
722 dump_bb (stderr, bb, 0, dump_flags);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724
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
725 DEBUG_FUNCTION basic_block
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 debug_bb_n (int n)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 {
111
kono
parents: 67
diff changeset
728 basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
kono
parents: 67
diff changeset
729 debug_bb (bb);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 return bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
732
111
kono
parents: 67
diff changeset
733 /* Dumps cfg related information about basic block BB to OUTF.
kono
parents: 67
diff changeset
734 If HEADER is true, dump things that appear before the instructions
kono
parents: 67
diff changeset
735 contained in BB. If FOOTER is true, dump things that appear after.
kono
parents: 67
diff changeset
736 Flags are the TDF_* masks as documented in dumpfile.h.
kono
parents: 67
diff changeset
737 NB: With TDF_DETAILS, it is assumed that cfun is available, so
kono
parents: 67
diff changeset
738 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
739
111
kono
parents: 67
diff changeset
740 void
kono
parents: 67
diff changeset
741 dump_bb_info (FILE *outf, basic_block bb, int indent, dump_flags_t flags,
kono
parents: 67
diff changeset
742 bool do_header, bool do_footer)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 edge_iterator ei;
111
kono
parents: 67
diff changeset
745 edge e;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
746 static const char * const bb_bitnames[] =
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 {
111
kono
parents: 67
diff changeset
748 #define DEF_BASIC_BLOCK_FLAG(NAME,IDX) #NAME ,
kono
parents: 67
diff changeset
749 #include "cfg-flags.def"
kono
parents: 67
diff changeset
750 NULL
kono
parents: 67
diff changeset
751 #undef DEF_BASIC_BLOCK_FLAG
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 const unsigned n_bitnames = sizeof (bb_bitnames) / sizeof (char *);
111
kono
parents: 67
diff changeset
754 bool first;
kono
parents: 67
diff changeset
755 char *s_indent = (char *) alloca ((size_t) indent + 1);
kono
parents: 67
diff changeset
756 memset ((void *) s_indent, ' ', (size_t) indent);
kono
parents: 67
diff changeset
757 s_indent[indent] = '\0';
kono
parents: 67
diff changeset
758
kono
parents: 67
diff changeset
759 gcc_assert (bb->flags <= BB_ALL_FLAGS);
kono
parents: 67
diff changeset
760
kono
parents: 67
diff changeset
761 if (do_header)
kono
parents: 67
diff changeset
762 {
kono
parents: 67
diff changeset
763 unsigned i;
kono
parents: 67
diff changeset
764
kono
parents: 67
diff changeset
765 fputs (";; ", outf);
kono
parents: 67
diff changeset
766 fprintf (outf, "%sbasic block %d, loop depth %d",
kono
parents: 67
diff changeset
767 s_indent, bb->index, bb_loop_depth (bb));
kono
parents: 67
diff changeset
768 if (flags & TDF_DETAILS)
kono
parents: 67
diff changeset
769 {
kono
parents: 67
diff changeset
770 struct function *fun = DECL_STRUCT_FUNCTION (current_function_decl);
kono
parents: 67
diff changeset
771 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
772 {
kono
parents: 67
diff changeset
773 fputs (", count ", outf);
kono
parents: 67
diff changeset
774 bb->count.dump (outf);
kono
parents: 67
diff changeset
775 }
kono
parents: 67
diff changeset
776 if (maybe_hot_bb_p (fun, bb))
kono
parents: 67
diff changeset
777 fputs (", maybe hot", outf);
kono
parents: 67
diff changeset
778 if (probably_never_executed_bb_p (fun, bb))
kono
parents: 67
diff changeset
779 fputs (", probably never executed", outf);
kono
parents: 67
diff changeset
780 }
kono
parents: 67
diff changeset
781 fputc ('\n', outf);
kono
parents: 67
diff changeset
782
kono
parents: 67
diff changeset
783 if (flags & TDF_DETAILS)
kono
parents: 67
diff changeset
784 {
kono
parents: 67
diff changeset
785 check_bb_profile (bb, outf, indent);
kono
parents: 67
diff changeset
786 fputs (";; ", outf);
kono
parents: 67
diff changeset
787 fprintf (outf, "%s prev block ", s_indent);
kono
parents: 67
diff changeset
788 if (bb->prev_bb)
kono
parents: 67
diff changeset
789 fprintf (outf, "%d", bb->prev_bb->index);
kono
parents: 67
diff changeset
790 else
kono
parents: 67
diff changeset
791 fprintf (outf, "(nil)");
kono
parents: 67
diff changeset
792 fprintf (outf, ", next block ");
kono
parents: 67
diff changeset
793 if (bb->next_bb)
kono
parents: 67
diff changeset
794 fprintf (outf, "%d", bb->next_bb->index);
kono
parents: 67
diff changeset
795 else
kono
parents: 67
diff changeset
796 fprintf (outf, "(nil)");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
797
111
kono
parents: 67
diff changeset
798 fputs (", flags:", outf);
kono
parents: 67
diff changeset
799 first = true;
kono
parents: 67
diff changeset
800 for (i = 0; i < n_bitnames; i++)
kono
parents: 67
diff changeset
801 if (bb->flags & (1 << i))
kono
parents: 67
diff changeset
802 {
kono
parents: 67
diff changeset
803 if (first)
kono
parents: 67
diff changeset
804 fputs (" (", outf);
kono
parents: 67
diff changeset
805 else
kono
parents: 67
diff changeset
806 fputs (", ", outf);
kono
parents: 67
diff changeset
807 first = false;
kono
parents: 67
diff changeset
808 fputs (bb_bitnames[i], outf);
kono
parents: 67
diff changeset
809 }
kono
parents: 67
diff changeset
810 if (!first)
kono
parents: 67
diff changeset
811 fputc (')', outf);
kono
parents: 67
diff changeset
812 fputc ('\n', outf);
kono
parents: 67
diff changeset
813 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
814
111
kono
parents: 67
diff changeset
815 fputs (";; ", outf);
kono
parents: 67
diff changeset
816 fprintf (outf, "%s pred: ", s_indent);
kono
parents: 67
diff changeset
817 first = true;
kono
parents: 67
diff changeset
818 FOR_EACH_EDGE (e, ei, bb->preds)
kono
parents: 67
diff changeset
819 {
kono
parents: 67
diff changeset
820 if (! first)
kono
parents: 67
diff changeset
821 {
kono
parents: 67
diff changeset
822 fputs (";; ", outf);
kono
parents: 67
diff changeset
823 fprintf (outf, "%s ", s_indent);
kono
parents: 67
diff changeset
824 }
kono
parents: 67
diff changeset
825 first = false;
kono
parents: 67
diff changeset
826 dump_edge_info (outf, e, flags, 0);
kono
parents: 67
diff changeset
827 fputc ('\n', outf);
kono
parents: 67
diff changeset
828 }
kono
parents: 67
diff changeset
829 if (first)
kono
parents: 67
diff changeset
830 fputc ('\n', outf);
kono
parents: 67
diff changeset
831 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
832
111
kono
parents: 67
diff changeset
833 if (do_footer)
kono
parents: 67
diff changeset
834 {
kono
parents: 67
diff changeset
835 fputs (";; ", outf);
kono
parents: 67
diff changeset
836 fprintf (outf, "%s succ: ", s_indent);
kono
parents: 67
diff changeset
837 first = true;
kono
parents: 67
diff changeset
838 FOR_EACH_EDGE (e, ei, bb->succs)
kono
parents: 67
diff changeset
839 {
kono
parents: 67
diff changeset
840 if (! first)
kono
parents: 67
diff changeset
841 {
kono
parents: 67
diff changeset
842 fputs (";; ", outf);
kono
parents: 67
diff changeset
843 fprintf (outf, "%s ", s_indent);
kono
parents: 67
diff changeset
844 }
kono
parents: 67
diff changeset
845 first = false;
kono
parents: 67
diff changeset
846 dump_edge_info (outf, e, flags, 1);
kono
parents: 67
diff changeset
847 fputc ('\n', outf);
kono
parents: 67
diff changeset
848 }
kono
parents: 67
diff changeset
849 if (first)
kono
parents: 67
diff changeset
850 fputc ('\n', outf);
kono
parents: 67
diff changeset
851 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 }
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 /* Dumps a brief description of cfg to FILE. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 void
111
kono
parents: 67
diff changeset
857 brief_dump_cfg (FILE *file, dump_flags_t flags)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
860
111
kono
parents: 67
diff changeset
861 FOR_EACH_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 {
111
kono
parents: 67
diff changeset
863 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
864 }
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
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
867 /* 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
868 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
869 redirected to destination of TAKEN_EDGE.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 This function may leave the profile inconsistent in the case TAKEN_EDGE
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
872 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
873 respectively. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
875 update_bb_profile_for_threading (basic_block bb,
111
kono
parents: 67
diff changeset
876 profile_count count, edge taken_edge)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
877 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 edge c;
111
kono
parents: 67
diff changeset
879 profile_probability prob;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881
111
kono
parents: 67
diff changeset
882 if (bb->count < count)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 fprintf (dump_file, "bb %i count became negative after threading",
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 bb->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 }
111
kono
parents: 67
diff changeset
888 bb->count -= count;
kono
parents: 67
diff changeset
889
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 /* 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
891 Watch for overflows. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
892 if (bb->count.nonzero_p ())
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
893 prob = count.probability_in (bb->count);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 else
111
kono
parents: 67
diff changeset
895 prob = profile_probability::never ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
896 if (prob > taken_edge->probability)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
898 if (dump_file)
111
kono
parents: 67
diff changeset
899 {
kono
parents: 67
diff changeset
900 fprintf (dump_file, "Jump threading proved probability of edge "
kono
parents: 67
diff changeset
901 "%i->%i too small (it is ",
kono
parents: 67
diff changeset
902 taken_edge->src->index, taken_edge->dest->index);
kono
parents: 67
diff changeset
903 taken_edge->probability.dump (dump_file);
kono
parents: 67
diff changeset
904 fprintf (dump_file, " should be ");
kono
parents: 67
diff changeset
905 prob.dump (dump_file);
kono
parents: 67
diff changeset
906 fprintf (dump_file, ")\n");
kono
parents: 67
diff changeset
907 }
kono
parents: 67
diff changeset
908 prob = taken_edge->probability.apply_scale (6, 8);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 }
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 /* Now rescale the probabilities. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 taken_edge->probability -= prob;
111
kono
parents: 67
diff changeset
913 prob = prob.invert ();
kono
parents: 67
diff changeset
914 if (prob == profile_probability::never ())
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 if (dump_file)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
917 fprintf (dump_file, "Edge probabilities of bb %i has been reset, "
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
918 "count of block should end up being 0, it is non-zero\n",
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
919 bb->index);
111
kono
parents: 67
diff changeset
920 EDGE_SUCC (bb, 0)->probability = profile_probability::guessed_always ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
921 ei = ei_start (bb->succs);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
922 ei_next (&ei);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 for (; (c = ei_safe_edge (ei)); ei_next (&ei))
111
kono
parents: 67
diff changeset
924 c->probability = profile_probability::guessed_never ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
925 }
111
kono
parents: 67
diff changeset
926 else if (!(prob == profile_probability::always ()))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
927 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
928 FOR_EACH_EDGE (c, ei, bb->succs)
111
kono
parents: 67
diff changeset
929 c->probability /= prob;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
930 }
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 gcc_assert (bb == taken_edge->src);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 }
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 /* Multiply all frequencies of basic blocks in array BBS of length NBBS
111
kono
parents: 67
diff changeset
936 by NUM/DEN, in profile_count arithmetic. More accurate than previous
kono
parents: 67
diff changeset
937 function but considerably slower. */
kono
parents: 67
diff changeset
938 void
kono
parents: 67
diff changeset
939 scale_bbs_frequencies_profile_count (basic_block *bbs, int nbbs,
kono
parents: 67
diff changeset
940 profile_count num, profile_count den)
kono
parents: 67
diff changeset
941 {
kono
parents: 67
diff changeset
942 int i;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
943 if (num == profile_count::zero () || den.nonzero_p ())
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
944 for (i = 0; i < nbbs; i++)
111
kono
parents: 67
diff changeset
945 bbs[i]->count = bbs[i]->count.apply_scale (num, den);
kono
parents: 67
diff changeset
946 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
947
111
kono
parents: 67
diff changeset
948 /* Multiply all frequencies of basic blocks in array BBS of length NBBS
kono
parents: 67
diff changeset
949 by NUM/DEN, in profile_count arithmetic. More accurate than previous
kono
parents: 67
diff changeset
950 function but considerably slower. */
kono
parents: 67
diff changeset
951 void
kono
parents: 67
diff changeset
952 scale_bbs_frequencies (basic_block *bbs, int nbbs,
kono
parents: 67
diff changeset
953 profile_probability p)
kono
parents: 67
diff changeset
954 {
kono
parents: 67
diff changeset
955 int i;
kono
parents: 67
diff changeset
956
kono
parents: 67
diff changeset
957 for (i = 0; i < nbbs; i++)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
958 bbs[i]->count = bbs[i]->count.apply_probability (p);
111
kono
parents: 67
diff changeset
959 }
kono
parents: 67
diff changeset
960
kono
parents: 67
diff changeset
961 /* Helper types for hash tables. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
962
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
963 struct htab_bb_copy_original_entry
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 /* Block we are attaching info to. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
966 int index1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 /* Index of original or copy (depending on the hashtable) */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 int index2;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970
111
kono
parents: 67
diff changeset
971 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
972 {
111
kono
parents: 67
diff changeset
973 static inline hashval_t hash (const htab_bb_copy_original_entry *);
kono
parents: 67
diff changeset
974 static inline bool equal (const htab_bb_copy_original_entry *existing,
kono
parents: 67
diff changeset
975 const htab_bb_copy_original_entry * candidate);
kono
parents: 67
diff changeset
976 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
977
111
kono
parents: 67
diff changeset
978 inline hashval_t
kono
parents: 67
diff changeset
979 bb_copy_hasher::hash (const htab_bb_copy_original_entry *data)
kono
parents: 67
diff changeset
980 {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
981 return data->index1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 }
111
kono
parents: 67
diff changeset
983
kono
parents: 67
diff changeset
984 inline bool
kono
parents: 67
diff changeset
985 bb_copy_hasher::equal (const htab_bb_copy_original_entry *data,
kono
parents: 67
diff changeset
986 const htab_bb_copy_original_entry *data2)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
987 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 return data->index1 == data2->index1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
990
111
kono
parents: 67
diff changeset
991 /* Data structures used to maintain mapping between basic blocks and
kono
parents: 67
diff changeset
992 copies. */
kono
parents: 67
diff changeset
993 static hash_table<bb_copy_hasher> *bb_original;
kono
parents: 67
diff changeset
994 static hash_table<bb_copy_hasher> *bb_copy;
kono
parents: 67
diff changeset
995
kono
parents: 67
diff changeset
996 /* And between loops and copies. */
kono
parents: 67
diff changeset
997 static hash_table<bb_copy_hasher> *loop_copy;
kono
parents: 67
diff changeset
998 static object_allocator<htab_bb_copy_original_entry> *original_copy_bb_pool;
kono
parents: 67
diff changeset
999
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 /* Initialize the data structures to maintain mapping between blocks
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 and its copies. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 initialize_original_copy_tables (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 {
111
kono
parents: 67
diff changeset
1005 original_copy_bb_pool = new object_allocator<htab_bb_copy_original_entry>
kono
parents: 67
diff changeset
1006 ("original_copy");
kono
parents: 67
diff changeset
1007 bb_original = new hash_table<bb_copy_hasher> (10);
kono
parents: 67
diff changeset
1008 bb_copy = new hash_table<bb_copy_hasher> (10);
kono
parents: 67
diff changeset
1009 loop_copy = new hash_table<bb_copy_hasher> (10);
kono
parents: 67
diff changeset
1010 }
kono
parents: 67
diff changeset
1011
kono
parents: 67
diff changeset
1012 /* Reset the data structures to maintain mapping between blocks and
kono
parents: 67
diff changeset
1013 its copies. */
kono
parents: 67
diff changeset
1014
kono
parents: 67
diff changeset
1015 void
kono
parents: 67
diff changeset
1016 reset_original_copy_tables (void)
kono
parents: 67
diff changeset
1017 {
kono
parents: 67
diff changeset
1018 gcc_assert (original_copy_bb_pool);
kono
parents: 67
diff changeset
1019 bb_original->empty ();
kono
parents: 67
diff changeset
1020 bb_copy->empty ();
kono
parents: 67
diff changeset
1021 loop_copy->empty ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022 }
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 /* Free the data structures to maintain mapping between blocks and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 its copies. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027 free_original_copy_tables (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 gcc_assert (original_copy_bb_pool);
111
kono
parents: 67
diff changeset
1030 delete bb_copy;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031 bb_copy = NULL;
111
kono
parents: 67
diff changeset
1032 delete bb_original;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033 bb_original = NULL;
111
kono
parents: 67
diff changeset
1034 delete loop_copy;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 loop_copy = NULL;
111
kono
parents: 67
diff changeset
1036 delete original_copy_bb_pool;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 original_copy_bb_pool = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039
111
kono
parents: 67
diff changeset
1040 /* Return true iff we have had a call to initialize_original_copy_tables
kono
parents: 67
diff changeset
1041 without a corresponding call to free_original_copy_tables. */
kono
parents: 67
diff changeset
1042
kono
parents: 67
diff changeset
1043 bool
kono
parents: 67
diff changeset
1044 original_copy_tables_initialized_p (void)
kono
parents: 67
diff changeset
1045 {
kono
parents: 67
diff changeset
1046 return original_copy_bb_pool != NULL;
kono
parents: 67
diff changeset
1047 }
kono
parents: 67
diff changeset
1048
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049 /* Removes the value associated with OBJ from table TAB. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051 static void
111
kono
parents: 67
diff changeset
1052 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
1053 {
111
kono
parents: 67
diff changeset
1054 htab_bb_copy_original_entry **slot;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 struct htab_bb_copy_original_entry key, *elt;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057 if (!original_copy_bb_pool)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 key.index1 = obj;
111
kono
parents: 67
diff changeset
1061 slot = tab->find_slot (&key, NO_INSERT);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 if (!slot)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064
111
kono
parents: 67
diff changeset
1065 elt = *slot;
kono
parents: 67
diff changeset
1066 tab->clear_slot (slot);
kono
parents: 67
diff changeset
1067 original_copy_bb_pool->remove (elt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 }
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 /* 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
1071 Do nothing when data structures are not initialized. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 static void
111
kono
parents: 67
diff changeset
1074 copy_original_table_set (hash_table<bb_copy_hasher> *tab,
kono
parents: 67
diff changeset
1075 unsigned obj, unsigned val)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 struct htab_bb_copy_original_entry **slot;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 struct htab_bb_copy_original_entry key;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 if (!original_copy_bb_pool)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 key.index1 = obj;
111
kono
parents: 67
diff changeset
1084 slot = tab->find_slot (&key, INSERT);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 if (!*slot)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 {
111
kono
parents: 67
diff changeset
1087 *slot = original_copy_bb_pool->allocate ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 (*slot)->index1 = obj;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1090 (*slot)->index2 = val;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1091 }
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 /* 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
1094 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
1095 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 set_bb_original (basic_block bb, basic_block original)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 copy_original_table_set (bb_original, bb->index, original->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 }
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 /* Get the original basic block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 basic_block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 get_bb_original (basic_block bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 struct htab_bb_copy_original_entry *entry;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106 struct htab_bb_copy_original_entry key;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 gcc_assert (original_copy_bb_pool);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110 key.index1 = bb->index;
111
kono
parents: 67
diff changeset
1111 entry = bb_original->find (&key);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 if (entry)
111
kono
parents: 67
diff changeset
1113 return BASIC_BLOCK_FOR_FN (cfun, entry->index2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 }
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 /* 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
1119 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
1120 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 set_bb_copy (basic_block bb, basic_block copy)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 copy_original_table_set (bb_copy, bb->index, copy->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124 }
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 /* Get the copy of basic block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127 basic_block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128 get_bb_copy (basic_block bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 struct htab_bb_copy_original_entry *entry;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 struct htab_bb_copy_original_entry key;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 gcc_assert (original_copy_bb_pool);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 key.index1 = bb->index;
111
kono
parents: 67
diff changeset
1136 entry = bb_copy->find (&key);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1137 if (entry)
111
kono
parents: 67
diff changeset
1138 return BASIC_BLOCK_FOR_FN (cfun, entry->index2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1139 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1141 }
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 /* 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
1144 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
1145
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1146 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147 set_loop_copy (struct loop *loop, struct loop *copy)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 if (!copy)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150 copy_original_table_clear (loop_copy, loop->num);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152 copy_original_table_set (loop_copy, loop->num, copy->num);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153 }
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 /* Get the copy of LOOP. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157 struct loop *
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158 get_loop_copy (struct loop *loop)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160 struct htab_bb_copy_original_entry *entry;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161 struct htab_bb_copy_original_entry key;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1162
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163 gcc_assert (original_copy_bb_pool);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165 key.index1 = loop->num;
111
kono
parents: 67
diff changeset
1166 entry = loop_copy->find (&key);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167 if (entry)
111
kono
parents: 67
diff changeset
1168 return get_loop (cfun, entry->index2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1169 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1170 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 }