1 /* Define control flow data structures for the CFG.
2 Copyright (C) 1987-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_BASIC_BLOCK_H
21 #define GCC_BASIC_BLOCK_H
29 #include "hard-reg-set.h"
37 /* Use gcov_type to hold basic block counters. Should be at least
38 64bit. Although a counter cannot be negative, we use a signed
39 type, because erroneous negative counts can be generated when the
40 flow graph is manipulated by various optimizations. A signed type
41 makes those easy to detect. */
43 /* Control flow edge information. */
44 struct GTY((user
)) edge_def
{
45 /* The two blocks at the ends of the edge. */
49 /* Instructions queued on the edge. */
50 union edge_def_insns
{
55 /* Auxiliary info specific to a pass. */
58 /* Location of any goto implicit in the edge. */
59 location_t goto_locus
;
61 /* The index number corresponding to this edge in the edge vector
63 unsigned int dest_idx
;
65 int flags
; /* see cfg-flags.def */
66 int probability
; /* biased by REG_BR_PROB_BASE */
67 gcov_type count
; /* Expected number of executions calculated
71 /* Masks for edge.flags. */
72 #define DEF_EDGE_FLAG(NAME,IDX) EDGE_##NAME = 1 << IDX ,
74 #include "cfg-flags.def"
75 LAST_CFG_EDGE_FLAG
/* this is only used for EDGE_ALL_FLAGS */
79 /* Bit mask for all edge flags. */
80 #define EDGE_ALL_FLAGS ((LAST_CFG_EDGE_FLAG - 1) * 2 - 1)
82 /* The following four flags all indicate something special about an edge.
83 Test the edge flags on EDGE_COMPLEX to detect all forms of "strange"
84 control flow transfers. */
85 #define EDGE_COMPLEX \
86 (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_PRESERVE)
88 /* Structure to gather statistic about profile consistency, per pass.
89 An array of this structure, indexed by pass static number, is allocated
90 in passes.c. The structure is defined here so that different CFG modes
91 can do their book-keeping via CFG hooks.
93 For every field[2], field[0] is the count before the pass runs, and
94 field[1] is the post-pass count. This allows us to monitor the effect
95 of each individual pass on the profile consistency.
97 This structure is not supposed to be used by anything other than passes.c
98 and one CFG hook per CFG mode. */
101 /* The number of basic blocks where sum(freq) of the block's predecessors
102 doesn't match reasonably well with the incoming frequency. */
103 int num_mismatched_freq_in
[2];
104 /* Likewise for a basic block's successors. */
105 int num_mismatched_freq_out
[2];
106 /* The number of basic blocks where sum(count) of the block's predecessors
107 doesn't match reasonably well with the incoming frequency. */
108 int num_mismatched_count_in
[2];
109 /* Likewise for a basic block's successors. */
110 int num_mismatched_count_out
[2];
111 /* A weighted cost of the run-time of the function body. */
113 /* A weighted cost of the size of the function body. */
115 /* True iff this pass actually was run. */
120 struct GTY(()) rtl_bb_info
{
121 /* The first insn of the block is embedded into bb->il.x. */
122 /* The last insn of the block. */
125 /* In CFGlayout mode points to insn notes/jumptables to be placed just before
126 and after the block. */
131 struct GTY(()) gimple_bb_info
{
132 /* Sequence of statements in this block. */
135 /* PHI nodes for this block. */
136 gimple_seq phi_nodes
;
139 /* A basic block is a sequence of instructions with only one entry and
140 only one exit. If any one of the instructions are executed, they
141 will all be executed, and in sequence from first to last.
143 There may be COND_EXEC instructions in the basic block. The
144 COND_EXEC *instructions* will be executed -- but if the condition
145 is false the conditionally executed *expressions* will of course
146 not be executed. We don't consider the conditionally executed
147 expression (which might have side-effects) to be in a separate
148 basic block because the program counter will always be at the same
149 location after the COND_EXEC instruction, regardless of whether the
150 condition is true or not.
152 Basic blocks need not start with a label nor end with a jump insn.
153 For example, a previous basic block may just "conditionally fall"
154 into the succeeding basic block, and the last basic block need not
155 end with a jump insn. Block 0 is a descendant of the entry block.
157 A basic block beginning with two labels cannot have notes between
160 Data for jump tables are stored in jump_insns that occur in no
161 basic block even though these insns can follow or precede insns in
164 /* Basic block information indexed by block number. */
165 struct GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb"))) basic_block_def
{
166 /* The edges into and out of the block. */
167 vec
<edge
, va_gc
> *preds
;
168 vec
<edge
, va_gc
> *succs
;
170 /* Auxiliary info specific to a pass. */
171 PTR
GTY ((skip (""))) aux
;
173 /* Innermost loop containing the block. */
174 struct loop
*loop_father
;
176 /* The dominance and postdominance information node. */
177 struct et_node
* GTY ((skip (""))) dom
[2];
179 /* Previous and next blocks in the chain. */
183 union basic_block_il_dependent
{
184 struct gimple_bb_info
GTY ((tag ("0"))) gimple
;
187 struct rtl_bb_info
* rtl
;
188 } GTY ((tag ("1"))) x
;
189 } GTY ((desc ("((%1.flags & BB_RTL) != 0)"))) il
;
191 /* Various flags. See cfg-flags.def. */
194 /* The index of this block. */
197 /* Expected number of executions: calculated in profile.c. */
200 /* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */
203 /* The discriminator for this block. The discriminator distinguishes
204 among several basic blocks that share a common locus, allowing for
205 more accurate sample-based profiling. */
209 /* This ensures that struct gimple_bb_info is smaller than
210 struct rtl_bb_info, so that inlining the former into basic_block_def
211 is the better choice. */
212 typedef int __assert_gimple_bb_smaller_rtl_bb
213 [(int) sizeof (struct rtl_bb_info
)
214 - (int) sizeof (struct gimple_bb_info
)];
217 #define BB_FREQ_MAX 10000
219 /* Masks for basic_block.flags. */
220 #define DEF_BASIC_BLOCK_FLAG(NAME,IDX) BB_##NAME = 1 << IDX ,
223 #include "cfg-flags.def"
224 LAST_CFG_BB_FLAG
/* this is only used for BB_ALL_FLAGS */
226 #undef DEF_BASIC_BLOCK_FLAG
228 /* Bit mask for all basic block flags. */
229 #define BB_ALL_FLAGS ((LAST_CFG_BB_FLAG - 1) * 2 - 1)
231 /* Bit mask for all basic block flags that must be preserved. These are
232 the bit masks that are *not* cleared by clear_bb_flags. */
233 #define BB_FLAGS_TO_PRESERVE \
234 (BB_DISABLE_SCHEDULE | BB_RTL | BB_NON_LOCAL_GOTO_TARGET \
235 | BB_HOT_PARTITION | BB_COLD_PARTITION)
237 /* Dummy bitmask for convenience in the hot/cold partitioning code. */
238 #define BB_UNPARTITIONED 0
240 /* Partitions, to be used when partitioning hot and cold basic blocks into
241 separate sections. */
242 #define BB_PARTITION(bb) ((bb)->flags & (BB_HOT_PARTITION|BB_COLD_PARTITION))
243 #define BB_SET_PARTITION(bb, part) do { \
244 basic_block bb_ = (bb); \
245 bb_->flags = ((bb_->flags & ~(BB_HOT_PARTITION|BB_COLD_PARTITION)) \
249 #define BB_COPY_PARTITION(dstbb, srcbb) \
250 BB_SET_PARTITION (dstbb, BB_PARTITION (srcbb))
252 /* State of dominance information. */
256 DOM_NONE
, /* Not computed at all. */
257 DOM_NO_FAST_QUERY
, /* The data is OK, but the fast query data are not usable. */
258 DOM_OK
/* Everything is ok. */
261 /* What sort of profiling information we have. */
262 enum profile_status_d
267 PROFILE_LAST
/* Last value, used by profile streaming. */
270 /* A structure to group all the per-function control flow graph data.
271 The x_* prefixing is necessary because otherwise references to the
272 fields of this struct are interpreted as the defines for backward
273 source compatibility following the definition of this struct. */
274 struct GTY(()) control_flow_graph
{
275 /* Block pointers for the exit and entry of a function.
276 These are always the head and tail of the basic block list. */
277 basic_block x_entry_block_ptr
;
278 basic_block x_exit_block_ptr
;
280 /* Index by basic block number, get basic block struct info. */
281 vec
<basic_block
, va_gc
> *x_basic_block_info
;
283 /* Number of basic blocks in this flow graph. */
284 int x_n_basic_blocks
;
286 /* Number of edges in this flow graph. */
289 /* The first free basic block number. */
290 int x_last_basic_block
;
292 /* UIDs for LABEL_DECLs. */
295 /* Mapping of labels to their associated blocks. At present
296 only used for the gimple CFG. */
297 vec
<basic_block
, va_gc
> *x_label_to_block_map
;
299 enum profile_status_d x_profile_status
;
301 /* Whether the dominators and the postdominators are available. */
302 enum dom_state x_dom_computed
[2];
304 /* Number of basic blocks in the dominance tree. */
305 unsigned x_n_bbs_in_dom_tree
[2];
307 /* Maximal number of entities in the single jumptable. Used to estimate
308 final flowgraph size. */
309 int max_jumptable_ents
;
312 /* Defines for accessing the fields of the CFG structure for function FN. */
313 #define ENTRY_BLOCK_PTR_FOR_FN(FN) ((FN)->cfg->x_entry_block_ptr)
314 #define EXIT_BLOCK_PTR_FOR_FN(FN) ((FN)->cfg->x_exit_block_ptr)
315 #define basic_block_info_for_fn(FN) ((FN)->cfg->x_basic_block_info)
316 #define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks)
317 #define n_edges_for_fn(FN) ((FN)->cfg->x_n_edges)
318 #define last_basic_block_for_fn(FN) ((FN)->cfg->x_last_basic_block)
319 #define label_to_block_map_for_fn(FN) ((FN)->cfg->x_label_to_block_map)
320 #define profile_status_for_fn(FN) ((FN)->cfg->x_profile_status)
322 #define BASIC_BLOCK_FOR_FN(FN,N) \
323 ((*basic_block_info_for_fn (FN))[(N)])
324 #define SET_BASIC_BLOCK_FOR_FN(FN,N,BB) \
325 ((*basic_block_info_for_fn (FN))[(N)] = (BB))
327 /* For iterating over basic blocks. */
328 #define FOR_BB_BETWEEN(BB, FROM, TO, DIR) \
329 for (BB = FROM; BB != TO; BB = BB->DIR)
331 #define FOR_EACH_BB_FN(BB, FN) \
332 FOR_BB_BETWEEN (BB, (FN)->cfg->x_entry_block_ptr->next_bb, (FN)->cfg->x_exit_block_ptr, next_bb)
334 #define FOR_EACH_BB_REVERSE_FN(BB, FN) \
335 FOR_BB_BETWEEN (BB, (FN)->cfg->x_exit_block_ptr->prev_bb, (FN)->cfg->x_entry_block_ptr, prev_bb)
337 /* For iterating over insns in basic block. */
338 #define FOR_BB_INSNS(BB, INSN) \
339 for ((INSN) = BB_HEAD (BB); \
340 (INSN) && (INSN) != NEXT_INSN (BB_END (BB)); \
341 (INSN) = NEXT_INSN (INSN))
343 /* For iterating over insns in basic block when we might remove the
345 #define FOR_BB_INSNS_SAFE(BB, INSN, CURR) \
346 for ((INSN) = BB_HEAD (BB), (CURR) = (INSN) ? NEXT_INSN ((INSN)): NULL; \
347 (INSN) && (INSN) != NEXT_INSN (BB_END (BB)); \
348 (INSN) = (CURR), (CURR) = (INSN) ? NEXT_INSN ((INSN)) : NULL)
350 #define FOR_BB_INSNS_REVERSE(BB, INSN) \
351 for ((INSN) = BB_END (BB); \
352 (INSN) && (INSN) != PREV_INSN (BB_HEAD (BB)); \
353 (INSN) = PREV_INSN (INSN))
355 #define FOR_BB_INSNS_REVERSE_SAFE(BB, INSN, CURR) \
356 for ((INSN) = BB_END (BB),(CURR) = (INSN) ? PREV_INSN ((INSN)) : NULL; \
357 (INSN) && (INSN) != PREV_INSN (BB_HEAD (BB)); \
358 (INSN) = (CURR), (CURR) = (INSN) ? PREV_INSN ((INSN)) : NULL)
360 /* Cycles through _all_ basic blocks, even the fake ones (entry and
363 #define FOR_ALL_BB_FN(BB, FN) \
364 for (BB = ENTRY_BLOCK_PTR_FOR_FN (FN); BB; BB = BB->next_bb)
367 /* Stuff for recording basic block info. */
369 /* For now, these will be functions (so that they can include checked casts
370 to rtx_insn. Once the underlying fields are converted from rtx
371 to rtx_insn, these can be converted back to macros. */
373 #define BB_HEAD(B) (B)->il.x.head_
374 #define BB_END(B) (B)->il.x.rtl->end_
375 #define BB_HEADER(B) (B)->il.x.rtl->header_
376 #define BB_FOOTER(B) (B)->il.x.rtl->footer_
378 /* Special block numbers [markers] for entry and exit.
379 Neither of them is supposed to hold actual statements. */
380 #define ENTRY_BLOCK (0)
381 #define EXIT_BLOCK (1)
383 /* The two blocks that are always in the cfg. */
384 #define NUM_FIXED_BLOCKS (2)
387 extern edge
redirect_edge_succ_nodup (edge
, basic_block
);
389 /* Structure to group all of the information to process IF-THEN and
390 IF-THEN-ELSE blocks for the conditional execution support. This
391 needs to be in a public file in case the IFCVT macros call
392 functions passing the ce_if_block data structure. */
396 basic_block test_bb
; /* First test block. */
397 basic_block then_bb
; /* THEN block. */
398 basic_block else_bb
; /* ELSE block or NULL. */
399 basic_block join_bb
; /* Join THEN/ELSE blocks. */
400 basic_block last_test_bb
; /* Last bb to hold && or || tests. */
401 int num_multiple_test_blocks
; /* # of && and || basic blocks. */
402 int num_and_and_blocks
; /* # of && blocks. */
403 int num_or_or_blocks
; /* # of || blocks. */
404 int num_multiple_test_insns
; /* # of insns in && and || blocks. */
405 int and_and_p
; /* Complex test is &&. */
406 int num_then_insns
; /* # of insns in THEN block. */
407 int num_else_insns
; /* # of insns in ELSE block. */
408 int pass
; /* Pass number. */
411 /* The base value for branch probability notes and edge probabilities. */
412 #define REG_BR_PROB_BASE 10000
414 /* This is the value which indicates no edge is present. */
415 #define EDGE_INDEX_NO_EDGE -1
417 /* EDGE_INDEX returns an integer index for an edge, or EDGE_INDEX_NO_EDGE
418 if there is no edge between the 2 basic blocks. */
419 #define EDGE_INDEX(el, pred, succ) (find_edge_index ((el), (pred), (succ)))
421 /* INDEX_EDGE_PRED_BB and INDEX_EDGE_SUCC_BB return a pointer to the basic
422 block which is either the pred or succ end of the indexed edge. */
423 #define INDEX_EDGE_PRED_BB(el, index) ((el)->index_to_edge[(index)]->src)
424 #define INDEX_EDGE_SUCC_BB(el, index) ((el)->index_to_edge[(index)]->dest)
426 /* INDEX_EDGE returns a pointer to the edge. */
427 #define INDEX_EDGE(el, index) ((el)->index_to_edge[(index)])
429 /* Number of edges in the compressed edge list. */
430 #define NUM_EDGES(el) ((el)->num_edges)
432 /* BB is assumed to contain conditional jump. Return the fallthru edge. */
433 #define FALLTHRU_EDGE(bb) (EDGE_SUCC ((bb), 0)->flags & EDGE_FALLTHRU \
434 ? EDGE_SUCC ((bb), 0) : EDGE_SUCC ((bb), 1))
436 /* BB is assumed to contain conditional jump. Return the branch edge. */
437 #define BRANCH_EDGE(bb) (EDGE_SUCC ((bb), 0)->flags & EDGE_FALLTHRU \
438 ? EDGE_SUCC ((bb), 1) : EDGE_SUCC ((bb), 0))
440 #define RDIV(X,Y) (((X) + (Y) / 2) / (Y))
441 /* Return expected execution frequency of the edge E. */
442 #define EDGE_FREQUENCY(e) RDIV ((e)->src->frequency * (e)->probability, \
445 /* Compute a scale factor (or probability) suitable for scaling of
446 gcov_type values via apply_probability() and apply_scale(). */
447 #define GCOV_COMPUTE_SCALE(num,den) \
448 ((den) ? RDIV ((num) * REG_BR_PROB_BASE, (den)) : REG_BR_PROB_BASE)
450 /* Return nonzero if edge is critical. */
451 #define EDGE_CRITICAL_P(e) (EDGE_COUNT ((e)->src->succs) >= 2 \
452 && EDGE_COUNT ((e)->dest->preds) >= 2)
454 #define EDGE_COUNT(ev) vec_safe_length (ev)
455 #define EDGE_I(ev,i) (*ev)[(i)]
456 #define EDGE_PRED(bb,i) (*(bb)->preds)[(i)]
457 #define EDGE_SUCC(bb,i) (*(bb)->succs)[(i)]
459 /* Returns true if BB has precisely one successor. */
462 single_succ_p (const_basic_block bb
)
464 return EDGE_COUNT (bb
->succs
) == 1;
467 /* Returns true if BB has precisely one predecessor. */
470 single_pred_p (const_basic_block bb
)
472 return EDGE_COUNT (bb
->preds
) == 1;
475 /* Returns the single successor edge of basic block BB. Aborts if
476 BB does not have exactly one successor. */
479 single_succ_edge (const_basic_block bb
)
481 gcc_checking_assert (single_succ_p (bb
));
482 return EDGE_SUCC (bb
, 0);
485 /* Returns the single predecessor edge of basic block BB. Aborts
486 if BB does not have exactly one predecessor. */
489 single_pred_edge (const_basic_block bb
)
491 gcc_checking_assert (single_pred_p (bb
));
492 return EDGE_PRED (bb
, 0);
495 /* Returns the single successor block of basic block BB. Aborts
496 if BB does not have exactly one successor. */
498 static inline basic_block
499 single_succ (const_basic_block bb
)
501 return single_succ_edge (bb
)->dest
;
504 /* Returns the single predecessor block of basic block BB. Aborts
505 if BB does not have exactly one predecessor.*/
507 static inline basic_block
508 single_pred (const_basic_block bb
)
510 return single_pred_edge (bb
)->src
;
513 /* Iterator object for edges. */
515 struct edge_iterator
{
517 vec
<edge
, va_gc
> **container
;
520 static inline vec
<edge
, va_gc
> *
521 ei_container (edge_iterator i
)
523 gcc_checking_assert (i
.container
);
527 #define ei_start(iter) ei_start_1 (&(iter))
528 #define ei_last(iter) ei_last_1 (&(iter))
530 /* Return an iterator pointing to the start of an edge vector. */
531 static inline edge_iterator
532 ei_start_1 (vec
<edge
, va_gc
> **ev
)
542 /* Return an iterator pointing to the last element of an edge
544 static inline edge_iterator
545 ei_last_1 (vec
<edge
, va_gc
> **ev
)
549 i
.index
= EDGE_COUNT (*ev
) - 1;
555 /* Is the iterator `i' at the end of the sequence? */
557 ei_end_p (edge_iterator i
)
559 return (i
.index
== EDGE_COUNT (ei_container (i
)));
562 /* Is the iterator `i' at one position before the end of the
565 ei_one_before_end_p (edge_iterator i
)
567 return (i
.index
+ 1 == EDGE_COUNT (ei_container (i
)));
570 /* Advance the iterator to the next element. */
572 ei_next (edge_iterator
*i
)
574 gcc_checking_assert (i
->index
< EDGE_COUNT (ei_container (*i
)));
578 /* Move the iterator to the previous element. */
580 ei_prev (edge_iterator
*i
)
582 gcc_checking_assert (i
->index
> 0);
586 /* Return the edge pointed to by the iterator `i'. */
588 ei_edge (edge_iterator i
)
590 return EDGE_I (ei_container (i
), i
.index
);
593 /* Return an edge pointed to by the iterator. Do it safely so that
594 NULL is returned when the iterator is pointing at the end of the
597 ei_safe_edge (edge_iterator i
)
599 return !ei_end_p (i
) ? ei_edge (i
) : NULL
;
602 /* Return 1 if we should continue to iterate. Return 0 otherwise.
603 *Edge P is set to the next edge if we are to continue to iterate
604 and NULL otherwise. */
607 ei_cond (edge_iterator ei
, edge
*p
)
621 /* This macro serves as a convenient way to iterate each edge in a
622 vector of predecessor or successor edges. It must not be used when
623 an element might be removed during the traversal, otherwise
624 elements will be missed. Instead, use a for-loop like that shown
625 in the following pseudo-code:
627 FOR (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
636 #define FOR_EACH_EDGE(EDGE,ITER,EDGE_VEC) \
637 for ((ITER) = ei_start ((EDGE_VEC)); \
638 ei_cond ((ITER), &(EDGE)); \
641 #define CLEANUP_EXPENSIVE 1 /* Do relatively expensive optimizations
642 except for edge forwarding */
643 #define CLEANUP_CROSSJUMP 2 /* Do crossjumping. */
644 #define CLEANUP_POST_REGSTACK 4 /* We run after reg-stack and need
645 to care REG_DEAD notes. */
646 #define CLEANUP_THREADING 8 /* Do jump threading. */
647 #define CLEANUP_NO_INSN_DEL 16 /* Do not try to delete trivially dead
649 #define CLEANUP_CFGLAYOUT 32 /* Do cleanup in cfglayout mode. */
650 #define CLEANUP_CFG_CHANGED 64 /* The caller changed the CFG. */
652 extern void dump_flow_info (FILE *, int);
655 extern bool maybe_hot_count_p (struct function
*, gcov_type
);
656 extern bool maybe_hot_bb_p (struct function
*, const_basic_block
);
657 extern bool maybe_hot_edge_p (edge
);
658 extern bool probably_never_executed_bb_p (struct function
*, const_basic_block
);
659 extern bool probably_never_executed_edge_p (struct function
*, edge
);
660 extern bool optimize_bb_for_size_p (const_basic_block
);
661 extern bool optimize_bb_for_speed_p (const_basic_block
);
662 extern bool optimize_edge_for_size_p (edge
);
663 extern bool optimize_edge_for_speed_p (edge
);
664 extern bool optimize_loop_for_size_p (struct loop
*);
665 extern bool optimize_loop_for_speed_p (struct loop
*);
666 extern bool optimize_loop_nest_for_size_p (struct loop
*);
667 extern bool optimize_loop_nest_for_speed_p (struct loop
*);
668 extern bool gimple_predicted_by_p (const_basic_block
, enum br_predictor
);
669 extern bool rtl_predicted_by_p (const_basic_block
, enum br_predictor
);
670 extern void gimple_predict_edge (edge
, enum br_predictor
, int);
671 extern void rtl_predict_edge (edge
, enum br_predictor
, int);
672 extern void predict_edge_def (edge
, enum br_predictor
, enum prediction
);
673 extern void guess_outgoing_edge_probabilities (basic_block
);
674 extern void remove_predictions_associated_with_edge (edge
);
675 extern bool edge_probability_reliable_p (const_edge
);
676 extern bool br_prob_note_reliable_p (const_rtx
);
677 extern bool predictable_edge_p (edge
);
680 extern void find_many_sub_basic_blocks (sbitmap
);
681 extern void rtl_make_eh_edge (sbitmap
, basic_block
, rtx
);
683 enum replace_direction
{ dir_none
, dir_forward
, dir_backward
, dir_both
};
685 /* In cfgcleanup.c. */
686 extern bool cleanup_cfg (int);
687 extern int flow_find_cross_jump (basic_block
, basic_block
, rtx_insn
**,
688 rtx_insn
**, enum replace_direction
*);
689 extern int flow_find_head_matching_sequence (basic_block
, basic_block
,
690 rtx_insn
**, rtx_insn
**, int);
692 extern bool delete_unreachable_blocks (void);
694 extern bool inside_basic_block_p (const rtx_insn
*);
695 extern bool control_flow_insn_p (const rtx_insn
*);
696 extern rtx_insn
*get_last_bb_insn (basic_block
);
703 CDI_POST_DOMINATORS
= 2
706 extern enum dom_state
dom_info_state (function
*, enum cdi_direction
);
707 extern enum dom_state
dom_info_state (enum cdi_direction
);
708 extern void set_dom_info_availability (enum cdi_direction
, enum dom_state
);
709 extern bool dom_info_available_p (function
*, enum cdi_direction
);
710 extern bool dom_info_available_p (enum cdi_direction
);
711 extern void calculate_dominance_info (enum cdi_direction
);
712 extern void free_dominance_info (function
*, enum cdi_direction
);
713 extern void free_dominance_info (enum cdi_direction
);
714 extern basic_block
nearest_common_dominator (enum cdi_direction
,
715 basic_block
, basic_block
);
716 extern basic_block
nearest_common_dominator_for_set (enum cdi_direction
,
718 extern void set_immediate_dominator (enum cdi_direction
, basic_block
,
720 extern basic_block
get_immediate_dominator (enum cdi_direction
, basic_block
);
721 extern bool dominated_by_p (enum cdi_direction
, const_basic_block
, const_basic_block
);
722 extern vec
<basic_block
> get_dominated_by (enum cdi_direction
, basic_block
);
723 extern vec
<basic_block
> get_dominated_by_region (enum cdi_direction
,
726 extern vec
<basic_block
> get_dominated_to_depth (enum cdi_direction
,
728 extern vec
<basic_block
> get_all_dominated_blocks (enum cdi_direction
,
730 extern void add_to_dominance_info (enum cdi_direction
, basic_block
);
731 extern void delete_from_dominance_info (enum cdi_direction
, basic_block
);
732 basic_block
recompute_dominator (enum cdi_direction
, basic_block
);
733 extern void redirect_immediate_dominators (enum cdi_direction
, basic_block
,
735 extern void iterate_fix_dominators (enum cdi_direction
,
736 vec
<basic_block
> , bool);
737 extern void verify_dominators (enum cdi_direction
);
738 extern basic_block
first_dom_son (enum cdi_direction
, basic_block
);
739 extern basic_block
next_dom_son (enum cdi_direction
, basic_block
);
740 unsigned bb_dom_dfs_in (enum cdi_direction
, basic_block
);
741 unsigned bb_dom_dfs_out (enum cdi_direction
, basic_block
);
743 #include "cfghooks.h"
745 /* Return true if BB is in a transaction. */
748 bb_in_transaction (basic_block bb
)
750 return bb
->flags
& BB_IN_TRANSACTION
;
753 /* Return true when one of the predecessor edges of BB is marked with EDGE_EH. */
755 bb_has_eh_pred (basic_block bb
)
760 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
762 if (e
->flags
& EDGE_EH
)
768 /* Return true when one of the predecessor edges of BB is marked with EDGE_ABNORMAL. */
770 bb_has_abnormal_pred (basic_block bb
)
775 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
777 if (e
->flags
& EDGE_ABNORMAL
)
783 /* Return the fallthru edge in EDGES if it exists, NULL otherwise. */
785 find_fallthru_edge (vec
<edge
, va_gc
> *edges
)
790 FOR_EACH_EDGE (e
, ei
, edges
)
791 if (e
->flags
& EDGE_FALLTHRU
)
797 /* In cfgloopmanip.c. */
798 extern edge mfb_kj_edge
;
799 extern bool mfb_keep_just (edge
);
801 /* In cfgexpand.c. */
802 extern void rtl_profile_for_bb (basic_block
);
803 extern void rtl_profile_for_edge (edge
);
804 extern void default_rtl_profile (void);
807 typedef struct gcov_working_set_info gcov_working_set_t
;
808 extern gcov_working_set_t
*find_working_set (unsigned pct_times_10
);
809 extern void add_working_set (gcov_working_set_t
*);
811 /* Check tha probability is sane. */
814 check_probability (int prob
)
816 gcc_checking_assert (prob
>= 0 && prob
<= REG_BR_PROB_BASE
);
819 /* Given PROB1 and PROB2, return PROB1*PROB2/REG_BR_PROB_BASE.
820 Used to combine BB probabilities. */
823 combine_probabilities (int prob1
, int prob2
)
825 check_probability (prob1
);
826 check_probability (prob2
);
827 return RDIV (prob1
* prob2
, REG_BR_PROB_BASE
);
830 /* Apply scale factor SCALE on frequency or count FREQ. Use this
831 interface when potentially scaling up, so that SCALE is not
832 constrained to be < REG_BR_PROB_BASE. */
834 static inline gcov_type
835 apply_scale (gcov_type freq
, gcov_type scale
)
837 return RDIV (freq
* scale
, REG_BR_PROB_BASE
);
840 /* Apply probability PROB on frequency or count FREQ. */
842 static inline gcov_type
843 apply_probability (gcov_type freq
, int prob
)
845 check_probability (prob
);
846 return apply_scale (freq
, prob
);
849 /* Return inverse probability for PROB. */
852 inverse_probability (int prob1
)
854 check_probability (prob1
);
855 return REG_BR_PROB_BASE
- prob1
;
858 /* Return true if BB has at least one abnormal outgoing edge. */
861 has_abnormal_or_eh_outgoing_edge_p (basic_block bb
)
866 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
867 if (e
->flags
& (EDGE_ABNORMAL
| EDGE_EH
))
872 #endif /* GCC_BASIC_BLOCK_H */