1 /* Control flow graph building code for GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 /* find_basic_blocks divides the current function's rtl into basic
23 blocks and constructs the CFG. The blocks are recorded in the
24 basic_block_info array; the CFG exists in the edge structures
25 referenced by the blocks.
27 find_basic_blocks also finds any unreachable loops and deletes them.
29 Available functionality:
32 - Local CFG construction
33 find_sub_basic_blocks */
39 #include "hard-reg-set.h"
40 #include "basic-block.h"
50 static int count_basic_blocks
PARAMS ((rtx
));
51 static void find_basic_blocks_1
PARAMS ((rtx
));
52 static rtx find_label_refs
PARAMS ((rtx
, rtx
));
53 static void make_edges
PARAMS ((rtx
, int, int, int));
54 static void make_label_edge
PARAMS ((sbitmap
*, basic_block
,
56 static void make_eh_edge
PARAMS ((sbitmap
*, basic_block
, rtx
));
57 static void find_bb_boundaries
PARAMS ((basic_block
));
58 static void compute_outgoing_frequencies
PARAMS ((basic_block
));
59 static bool inside_basic_block_p
PARAMS ((rtx
));
60 static bool control_flow_insn_p
PARAMS ((rtx
));
62 /* Return true if insn is something that should be contained inside basic
66 inside_basic_block_p (insn
)
69 switch (GET_CODE (insn
))
72 /* Avoid creating of basic block for jumptables. */
73 return (NEXT_INSN (insn
) == 0
74 || GET_CODE (NEXT_INSN (insn
)) != JUMP_INSN
75 || (GET_CODE (PATTERN (NEXT_INSN (insn
))) != ADDR_VEC
76 && GET_CODE (PATTERN (NEXT_INSN (insn
))) != ADDR_DIFF_VEC
));
79 return (GET_CODE (PATTERN (insn
)) != ADDR_VEC
80 && GET_CODE (PATTERN (insn
)) != ADDR_DIFF_VEC
);
95 /* Return true if INSN may cause control flow transfer, so it should be last in
99 control_flow_insn_p (insn
)
104 switch (GET_CODE (insn
))
111 /* Jump insn always causes control transfer except for tablejumps. */
112 return (GET_CODE (PATTERN (insn
)) != ADDR_VEC
113 && GET_CODE (PATTERN (insn
)) != ADDR_DIFF_VEC
);
116 /* Call insn may return to the nonlocal goto handler. */
117 return ((nonlocal_goto_handler_labels
118 && (0 == (note
= find_reg_note (insn
, REG_EH_REGION
,
120 || INTVAL (XEXP (note
, 0)) >= 0))
122 || can_throw_internal (insn
));
125 return (flag_non_call_exceptions
&& can_throw_internal (insn
));
128 /* It is nonsence to reach barrier when looking for the
129 end of basic block, but before dead code is eliminated
138 /* Count the basic blocks of the function. */
141 count_basic_blocks (f
)
145 bool saw_insn
= false;
148 for (insn
= f
; insn
; insn
= NEXT_INSN (insn
))
150 /* Code labels and barriers causes curent basic block to be
151 terminated at previous real insn. */
152 if ((GET_CODE (insn
) == CODE_LABEL
|| GET_CODE (insn
) == BARRIER
)
154 count
++, saw_insn
= false;
156 /* Start basic block if needed. */
157 if (!saw_insn
&& inside_basic_block_p (insn
))
160 /* Control flow insn causes current basic block to be terminated. */
161 if (saw_insn
&& control_flow_insn_p (insn
))
162 count
++, saw_insn
= false;
168 /* The rest of the compiler works a bit smoother when we don't have to
169 check for the edge case of do-nothing functions with no basic blocks. */
172 emit_insn (gen_rtx_USE (VOIDmode
, const0_rtx
));
179 /* Scan a list of insns for labels referred to other than by jumps.
180 This is used to scan the alternatives of a call placeholder. */
183 find_label_refs (f
, lvl
)
189 for (insn
= f
; insn
; insn
= NEXT_INSN (insn
))
190 if (INSN_P (insn
) && GET_CODE (insn
) != JUMP_INSN
)
194 /* Make a list of all labels referred to other than by jumps
195 (which just don't have the REG_LABEL notes).
197 Make a special exception for labels followed by an ADDR*VEC,
198 as this would be a part of the tablejump setup code.
200 Make a special exception to registers loaded with label
201 values just before jump insns that use them. */
203 for (note
= REG_NOTES (insn
); note
; note
= XEXP (note
, 1))
204 if (REG_NOTE_KIND (note
) == REG_LABEL
)
206 rtx lab
= XEXP (note
, 0), next
;
208 if ((next
= next_nonnote_insn (lab
)) != NULL
209 && GET_CODE (next
) == JUMP_INSN
210 && (GET_CODE (PATTERN (next
)) == ADDR_VEC
211 || GET_CODE (PATTERN (next
)) == ADDR_DIFF_VEC
))
213 else if (GET_CODE (lab
) == NOTE
)
215 else if (GET_CODE (NEXT_INSN (insn
)) == JUMP_INSN
216 && find_reg_note (NEXT_INSN (insn
), REG_LABEL
, lab
))
219 lvl
= alloc_EXPR_LIST (0, XEXP (note
, 0), lvl
);
226 /* Create an edge between two basic blocks. FLAGS are auxiliary information
227 about the edge that is accumulated between calls. */
229 /* Create an edge from a basic block to a label. */
232 make_label_edge (edge_cache
, src
, label
, flags
)
238 if (GET_CODE (label
) != CODE_LABEL
)
241 /* If the label was never emitted, this insn is junk, but avoid a
242 crash trying to refer to BLOCK_FOR_INSN (label). This can happen
243 as a result of a syntax error and a diagnostic has already been
246 if (INSN_UID (label
) == 0)
249 cached_make_edge (edge_cache
, src
, BLOCK_FOR_INSN (label
), flags
);
252 /* Create the edges generated by INSN in REGION. */
255 make_eh_edge (edge_cache
, src
, insn
)
260 int is_call
= GET_CODE (insn
) == CALL_INSN
? EDGE_ABNORMAL_CALL
: 0;
263 handlers
= reachable_handlers (insn
);
265 for (i
= handlers
; i
; i
= XEXP (i
, 1))
266 make_label_edge (edge_cache
, src
, XEXP (i
, 0),
267 EDGE_ABNORMAL
| EDGE_EH
| is_call
);
269 free_INSN_LIST_list (&handlers
);
272 /* Identify the edges between basic blocks MIN to MAX.
274 NONLOCAL_LABEL_LIST is a list of non-local labels in the function. Blocks
275 that are otherwise unreachable may be reachable with a non-local goto.
277 BB_EH_END is an array indexed by basic block number in which we record
278 the list of exception regions active at the end of the basic block. */
281 make_edges (label_value_list
, min
, max
, update_p
)
282 rtx label_value_list
;
283 int min
, max
, update_p
;
286 sbitmap
*edge_cache
= NULL
;
288 /* Assume no computed jump; revise as we create edges. */
289 current_function_has_computed_jump
= 0;
291 /* Heavy use of computed goto in machine-generated code can lead to
292 nearly fully-connected CFGs. In that case we spend a significant
293 amount of time searching the edge lists for duplicates. */
294 if (forced_labels
|| label_value_list
)
296 edge_cache
= sbitmap_vector_alloc (n_basic_blocks
, n_basic_blocks
);
297 sbitmap_vector_zero (edge_cache
, n_basic_blocks
);
300 for (i
= min
; i
<= max
; ++i
)
304 for (e
= BASIC_BLOCK (i
)->succ
; e
; e
= e
->succ_next
)
305 if (e
->dest
!= EXIT_BLOCK_PTR
)
306 SET_BIT (edge_cache
[i
], e
->dest
->index
);
310 /* By nature of the way these get numbered, block 0 is always the entry. */
312 cached_make_edge (edge_cache
, ENTRY_BLOCK_PTR
, BASIC_BLOCK (0),
315 for (i
= min
; i
<= max
; ++i
)
317 basic_block bb
= BASIC_BLOCK (i
);
320 int force_fallthru
= 0;
322 if (GET_CODE (bb
->head
) == CODE_LABEL
&& LABEL_ALTERNATE_NAME (bb
->head
))
323 cached_make_edge (NULL
, ENTRY_BLOCK_PTR
, bb
, 0);
325 /* Examine the last instruction of the block, and discover the
326 ways we can leave the block. */
329 code
= GET_CODE (insn
);
332 if (code
== JUMP_INSN
)
336 /* Recognize exception handling placeholders. */
337 if (GET_CODE (PATTERN (insn
)) == RESX
)
338 make_eh_edge (edge_cache
, bb
, insn
);
340 /* Recognize a non-local goto as a branch outside the
342 else if (find_reg_note (insn
, REG_NON_LOCAL_GOTO
, NULL_RTX
))
345 /* ??? Recognize a tablejump and do the right thing. */
346 else if ((tmp
= JUMP_LABEL (insn
)) != NULL_RTX
347 && (tmp
= NEXT_INSN (tmp
)) != NULL_RTX
348 && GET_CODE (tmp
) == JUMP_INSN
349 && (GET_CODE (PATTERN (tmp
)) == ADDR_VEC
350 || GET_CODE (PATTERN (tmp
)) == ADDR_DIFF_VEC
))
355 if (GET_CODE (PATTERN (tmp
)) == ADDR_VEC
)
356 vec
= XVEC (PATTERN (tmp
), 0);
358 vec
= XVEC (PATTERN (tmp
), 1);
360 for (j
= GET_NUM_ELEM (vec
) - 1; j
>= 0; --j
)
361 make_label_edge (edge_cache
, bb
,
362 XEXP (RTVEC_ELT (vec
, j
), 0), 0);
364 /* Some targets (eg, ARM) emit a conditional jump that also
365 contains the out-of-range target. Scan for these and
366 add an edge if necessary. */
367 if ((tmp
= single_set (insn
)) != NULL
368 && SET_DEST (tmp
) == pc_rtx
369 && GET_CODE (SET_SRC (tmp
)) == IF_THEN_ELSE
370 && GET_CODE (XEXP (SET_SRC (tmp
), 2)) == LABEL_REF
)
371 make_label_edge (edge_cache
, bb
,
372 XEXP (XEXP (SET_SRC (tmp
), 2), 0), 0);
374 #ifdef CASE_DROPS_THROUGH
375 /* Silly VAXen. The ADDR_VEC is going to be in the way of
376 us naturally detecting fallthru into the next block. */
381 /* If this is a computed jump, then mark it as reaching
382 everything on the label_value_list and forced_labels list. */
383 else if (computed_jump_p (insn
))
385 current_function_has_computed_jump
= 1;
387 for (x
= label_value_list
; x
; x
= XEXP (x
, 1))
388 make_label_edge (edge_cache
, bb
, XEXP (x
, 0), EDGE_ABNORMAL
);
390 for (x
= forced_labels
; x
; x
= XEXP (x
, 1))
391 make_label_edge (edge_cache
, bb
, XEXP (x
, 0), EDGE_ABNORMAL
);
394 /* Returns create an exit out. */
395 else if (returnjump_p (insn
))
396 cached_make_edge (edge_cache
, bb
, EXIT_BLOCK_PTR
, 0);
398 /* Otherwise, we have a plain conditional or unconditional jump. */
401 if (! JUMP_LABEL (insn
))
403 make_label_edge (edge_cache
, bb
, JUMP_LABEL (insn
), 0);
407 /* If this is a sibling call insn, then this is in effect a combined call
408 and return, and so we need an edge to the exit block. No need to
409 worry about EH edges, since we wouldn't have created the sibling call
410 in the first place. */
411 if (code
== CALL_INSN
&& SIBLING_CALL_P (insn
))
412 cached_make_edge (edge_cache
, bb
, EXIT_BLOCK_PTR
,
413 EDGE_ABNORMAL
| EDGE_ABNORMAL_CALL
);
415 /* If this is a CALL_INSN, then mark it as reaching the active EH
416 handler for this CALL_INSN. If we're handling non-call
417 exceptions then any insn can reach any of the active handlers.
418 Also mark the CALL_INSN as reaching any nonlocal goto handler. */
419 else if (code
== CALL_INSN
|| flag_non_call_exceptions
)
421 /* Add any appropriate EH edges. */
422 make_eh_edge (edge_cache
, bb
, insn
);
424 if (code
== CALL_INSN
&& nonlocal_goto_handler_labels
)
426 /* ??? This could be made smarter: in some cases it's possible
427 to tell that certain calls will not do a nonlocal goto.
428 For example, if the nested functions that do the nonlocal
429 gotos do not have their addresses taken, then only calls to
430 those functions or to other nested functions that use them
431 could possibly do nonlocal gotos. */
433 /* We do know that a REG_EH_REGION note with a value less
434 than 0 is guaranteed not to perform a non-local goto. */
435 rtx note
= find_reg_note (insn
, REG_EH_REGION
, NULL_RTX
);
437 if (!note
|| INTVAL (XEXP (note
, 0)) >= 0)
438 for (x
= nonlocal_goto_handler_labels
; x
; x
= XEXP (x
, 1))
439 make_label_edge (edge_cache
, bb
, XEXP (x
, 0),
440 EDGE_ABNORMAL
| EDGE_ABNORMAL_CALL
);
444 /* Find out if we can drop through to the next block. */
445 insn
= next_nonnote_insn (insn
);
446 if (!insn
|| (i
+ 1 == n_basic_blocks
&& force_fallthru
))
447 cached_make_edge (edge_cache
, bb
, EXIT_BLOCK_PTR
, EDGE_FALLTHRU
);
448 else if (i
+ 1 < n_basic_blocks
)
450 rtx tmp
= BLOCK_HEAD (i
+ 1);
451 if (GET_CODE (tmp
) == NOTE
)
452 tmp
= next_nonnote_insn (tmp
);
453 if (force_fallthru
|| insn
== tmp
)
454 cached_make_edge (edge_cache
, bb
, BASIC_BLOCK (i
+ 1),
460 sbitmap_vector_free (edge_cache
);
463 /* Find all basic blocks of the function whose first insn is F.
465 Collect and return a list of labels whose addresses are taken. This
466 will be used in make_edges for use with computed gotos. */
469 find_basic_blocks_1 (f
)
474 rtx bb_note
= NULL_RTX
;
479 basic_block prev
= ENTRY_BLOCK_PTR
;
481 /* We process the instructions in a slightly different way than we did
482 previously. This is so that we see a NOTE_BASIC_BLOCK after we have
483 closed out the previous block, so that it gets attached at the proper
484 place. Since this form should be equivalent to the previous,
485 count_basic_blocks continues to use the old form as a check. */
487 for (insn
= f
; insn
; insn
= next
)
489 enum rtx_code code
= GET_CODE (insn
);
491 next
= NEXT_INSN (insn
);
493 if ((GET_CODE (insn
) == CODE_LABEL
|| GET_CODE (insn
) == BARRIER
)
496 prev
= create_basic_block_structure (i
++, head
, end
, bb_note
, prev
);
497 head
= end
= NULL_RTX
;
501 if (inside_basic_block_p (insn
))
503 if (head
== NULL_RTX
)
508 if (head
&& control_flow_insn_p (insn
))
510 prev
= create_basic_block_structure (i
++, head
, end
, bb_note
, prev
);
511 head
= end
= NULL_RTX
;
519 int kind
= NOTE_LINE_NUMBER (insn
);
521 /* Look for basic block notes with which to keep the
522 basic_block_info pointers stable. Unthread the note now;
523 we'll put it back at the right place in create_basic_block.
524 Or not at all if we've already found a note in this block. */
525 if (kind
== NOTE_INSN_BASIC_BLOCK
)
527 if (bb_note
== NULL_RTX
)
530 next
= delete_insn (insn
);
542 if (GET_CODE (PATTERN (insn
)) == CALL_PLACEHOLDER
)
544 /* Scan each of the alternatives for label refs. */
545 lvl
= find_label_refs (XEXP (PATTERN (insn
), 0), lvl
);
546 lvl
= find_label_refs (XEXP (PATTERN (insn
), 1), lvl
);
547 lvl
= find_label_refs (XEXP (PATTERN (insn
), 2), lvl
);
548 /* Record its tail recursion label, if any. */
549 if (XEXP (PATTERN (insn
), 3) != NULL_RTX
)
550 trll
= alloc_EXPR_LIST (0, XEXP (PATTERN (insn
), 3), trll
);
558 if (GET_CODE (insn
) == INSN
|| GET_CODE (insn
) == CALL_INSN
)
562 /* Make a list of all labels referred to other than by jumps.
564 Make a special exception for labels followed by an ADDR*VEC,
565 as this would be a part of the tablejump setup code.
567 Make a special exception to registers loaded with label
568 values just before jump insns that use them. */
570 for (note
= REG_NOTES (insn
); note
; note
= XEXP (note
, 1))
571 if (REG_NOTE_KIND (note
) == REG_LABEL
)
573 rtx lab
= XEXP (note
, 0), next
;
575 if ((next
= next_nonnote_insn (lab
)) != NULL
576 && GET_CODE (next
) == JUMP_INSN
577 && (GET_CODE (PATTERN (next
)) == ADDR_VEC
578 || GET_CODE (PATTERN (next
)) == ADDR_DIFF_VEC
))
580 else if (GET_CODE (lab
) == NOTE
)
582 else if (GET_CODE (NEXT_INSN (insn
)) == JUMP_INSN
583 && find_reg_note (NEXT_INSN (insn
), REG_LABEL
, lab
))
586 lvl
= alloc_EXPR_LIST (0, XEXP (note
, 0), lvl
);
591 if (head
!= NULL_RTX
)
592 create_basic_block_structure (i
++, head
, end
, bb_note
, prev
);
594 delete_insn (bb_note
);
596 if (i
!= n_basic_blocks
)
599 label_value_list
= lvl
;
600 tail_recursion_label_list
= trll
;
601 clear_aux_for_blocks ();
605 /* Find basic blocks of the current function.
606 F is the first insn of the function and NREGS the number of register
610 find_basic_blocks (f
, nregs
, file
)
612 int nregs ATTRIBUTE_UNUSED
;
613 FILE *file ATTRIBUTE_UNUSED
;
616 timevar_push (TV_CFG
);
618 basic_block_for_insn
= 0;
620 /* Flush out existing data. */
621 if (basic_block_info
!= NULL
)
627 /* Clear bb->aux on all extant basic blocks. We'll use this as a
628 tag for reuse during create_basic_block, just in case some pass
629 copies around basic block notes improperly. */
630 for (i
= 0; i
< n_basic_blocks
; ++i
)
631 BASIC_BLOCK (i
)->aux
= NULL
;
633 VARRAY_FREE (basic_block_info
);
636 n_basic_blocks
= count_basic_blocks (f
);
637 ENTRY_BLOCK_PTR
->next_bb
= EXIT_BLOCK_PTR
;
638 EXIT_BLOCK_PTR
->prev_bb
= ENTRY_BLOCK_PTR
;
640 /* Size the basic block table. The actual structures will be allocated
641 by find_basic_blocks_1, since we want to keep the structure pointers
642 stable across calls to find_basic_blocks. */
643 /* ??? This whole issue would be much simpler if we called find_basic_blocks
644 exactly once, and thereafter we don't have a single long chain of
645 instructions at all until close to the end of compilation when we
646 actually lay them out. */
648 VARRAY_BB_INIT (basic_block_info
, n_basic_blocks
, "basic_block_info");
650 find_basic_blocks_1 (f
);
652 /* Record the block to which an insn belongs. */
653 /* ??? This should be done another way, by which (perhaps) a label is
654 tagged directly with the basic block that it starts. It is used for
655 more than that currently, but IMO that is the only valid use. */
657 max_uid
= get_max_uid ();
659 /* Leave space for insns life_analysis makes in some cases for auto-inc.
660 These cases are rare, so we don't need too much space. */
661 max_uid
+= max_uid
/ 10;
664 compute_bb_for_insn (max_uid
);
666 /* Discover the edges of our cfg. */
667 make_edges (label_value_list
, 0, n_basic_blocks
- 1, 0);
669 /* Do very simple cleanup now, for the benefit of code that runs between
670 here and cleanup_cfg, e.g. thread_prologue_and_epilogue_insns. */
671 tidy_fallthru_edges ();
673 #ifdef ENABLE_CHECKING
676 timevar_pop (TV_CFG
);
679 /* State of basic block as seen by find_sub_basic_blocks. */
680 enum state
{BLOCK_NEW
= 0, BLOCK_ORIGINAL
, BLOCK_TO_SPLIT
};
682 #define STATE(BB) (enum state) ((size_t) (BB)->aux)
683 #define SET_STATE(BB, STATE) ((BB)->aux = (void *) (size_t) (STATE))
685 /* Scan basic block BB for possible BB boundaries inside the block
686 and create new basic blocks in the progress. */
689 find_bb_boundaries (bb
)
694 rtx flow_transfer_insn
= NULL_RTX
;
695 edge fallthru
= NULL
;
700 if (GET_CODE (insn
) == CODE_LABEL
)
701 insn
= NEXT_INSN (insn
);
703 /* Scan insn chain and try to find new basic block boundaries. */
706 enum rtx_code code
= GET_CODE (insn
);
708 /* On code label, split current basic block. */
709 if (code
== CODE_LABEL
)
711 fallthru
= split_block (bb
, PREV_INSN (insn
));
712 if (flow_transfer_insn
)
713 bb
->end
= flow_transfer_insn
;
716 remove_edge (fallthru
);
717 flow_transfer_insn
= NULL_RTX
;
718 if (LABEL_ALTERNATE_NAME (insn
))
719 make_edge (ENTRY_BLOCK_PTR
, bb
, 0);
722 /* In case we've previously seen an insn that effects a control
723 flow transfer, split the block. */
724 if (flow_transfer_insn
&& inside_basic_block_p (insn
))
726 fallthru
= split_block (bb
, PREV_INSN (insn
));
727 bb
->end
= flow_transfer_insn
;
729 remove_edge (fallthru
);
730 flow_transfer_insn
= NULL_RTX
;
733 if (control_flow_insn_p (insn
))
734 flow_transfer_insn
= insn
;
737 insn
= NEXT_INSN (insn
);
740 /* In case expander replaced normal insn by sequence terminating by
741 return and barrier, or possibly other sequence not behaving like
742 ordinary jump, we need to take care and move basic block boundary. */
743 if (flow_transfer_insn
)
744 bb
->end
= flow_transfer_insn
;
746 /* We've possibly replaced the conditional jump by conditional jump
747 followed by cleanup at fallthru edge, so the outgoing edges may
749 purge_dead_edges (bb
);
752 /* Assume that frequency of basic block B is known. Compute frequencies
753 and probabilities of outgoing edges. */
756 compute_outgoing_frequencies (b
)
761 if (b
->succ
&& b
->succ
->succ_next
&& !b
->succ
->succ_next
->succ_next
)
763 rtx note
= find_reg_note (b
->end
, REG_BR_PROB
, NULL
);
769 probability
= INTVAL (XEXP (find_reg_note (b
->end
,
773 e
->probability
= probability
;
774 e
->count
= ((b
->count
* probability
+ REG_BR_PROB_BASE
/ 2)
776 f
= FALLTHRU_EDGE (b
);
777 f
->probability
= REG_BR_PROB_BASE
- probability
;
778 f
->count
= b
->count
- e
->count
;
781 if (b
->succ
&& !b
->succ
->succ_next
)
784 e
->probability
= REG_BR_PROB_BASE
;
789 /* Assume that someone emitted code with control flow instructions to the
790 basic block. Update the data structure. */
793 find_many_sub_basic_blocks (blocks
)
799 for (i
= 0; i
< n_basic_blocks
; i
++)
800 SET_STATE (BASIC_BLOCK (i
),
801 TEST_BIT (blocks
, i
) ? BLOCK_TO_SPLIT
: BLOCK_ORIGINAL
);
803 for (i
= 0; i
< n_basic_blocks
; i
++)
804 if (STATE (BASIC_BLOCK (i
)) == BLOCK_TO_SPLIT
)
805 find_bb_boundaries (BASIC_BLOCK (i
));
807 for (i
= 0; i
< n_basic_blocks
; i
++)
808 if (STATE (BASIC_BLOCK (i
)) != BLOCK_ORIGINAL
)
812 for (; i
< n_basic_blocks
; i
++)
813 if (STATE (BASIC_BLOCK (i
)) != BLOCK_ORIGINAL
)
816 /* Now re-scan and wire in all edges. This expect simple (conditional)
817 jumps at the end of each new basic blocks. */
818 make_edges (NULL
, min
, max
, 1);
820 /* Update branch probabilities. Expect only (un)conditional jumps
821 to be created with only the forward edges. */
822 for (i
= min
; i
<= max
; i
++)
825 basic_block b
= BASIC_BLOCK (i
);
827 if (STATE (b
) == BLOCK_ORIGINAL
)
829 if (STATE (b
) == BLOCK_NEW
)
833 for (e
= b
->pred
; e
; e
=e
->pred_next
)
835 b
->count
+= e
->count
;
836 b
->frequency
+= EDGE_FREQUENCY (e
);
840 compute_outgoing_frequencies (b
);
843 for (i
= 0; i
< n_basic_blocks
; i
++)
844 SET_STATE (BASIC_BLOCK (i
), 0);
847 /* Like above but for single basic block only. */
850 find_sub_basic_blocks (bb
)
855 basic_block next
= (bb
->index
== n_basic_blocks
- 1
856 ? NULL
: BASIC_BLOCK (bb
->index
+ 1));
859 find_bb_boundaries (bb
);
860 max
= (next
? next
->index
: n_basic_blocks
) - 1;
862 /* Now re-scan and wire in all edges. This expect simple (conditional)
863 jumps at the end of each new basic blocks. */
864 make_edges (NULL
, min
, max
, 1);
866 /* Update branch probabilities. Expect only (un)conditional jumps
867 to be created with only the forward edges. */
868 for (i
= min
; i
<= max
; i
++)
871 basic_block b
= BASIC_BLOCK (i
);
877 for (e
= b
->pred
; e
; e
=e
->pred_next
)
879 b
->count
+= e
->count
;
880 b
->frequency
+= EDGE_FREQUENCY (e
);
884 compute_outgoing_frequencies (b
);