aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2001-09-16 20:21:30 +0000
committerJan Hubicka <hubicka@gcc.gnu.org>2001-09-16 20:21:30 +0000
commit3c030e88e793d2aff78a76e9df248bc029c9048c (patch)
tree3f3b141a9f45004a367eed069d691638b036e04f
parent345894b43fd5709b3990ff7897ed2b941d62742c (diff)
downloadgcc-3c030e88e793d2aff78a76e9df248bc029c9048c.zip
gcc-3c030e88e793d2aff78a76e9df248bc029c9048c.tar.gz
gcc-3c030e88e793d2aff78a76e9df248bc029c9048c.tar.bz2
basic-block.h (free_bb_for_insn): Declare.
* basic-block.h (free_bb_for_insn): Declare. * bb-reorder.c (label_for_bb): Use block_label. (emit_jump_to_block_after): Remove. (insert_intra_1): Do not update block_for_insn. (insert_inter_bb_scope_notes): Likewise; update bb->end * cfg.c (free_bb_for_insn): New. (try_rediret_by_replacing_jump): Avoid set_block_for_new_insns call. (force_nonfallthru_and_redirect): Likewise; do not update BB boundaries. (commit_one_edge_insertion): Likewise. (commit_one_edge_insertion): Do not update BB boundary. (commit_edge_insertions): Do not call compute_bb_for_insn. * cfgbuild.c (find_basic_blocks): Do not free basic_block_for_insn. * cfgcleanup.c (merge_blocks_move_predecessor): Use reorder_insns_nobb. (merge_blocks_move_successor_nojumps): Likewise. (try_crossjump_to_edge): Do not update block_for_insn. * combine.c (combine_instructions): Remove compute_bb_for_insn call. * df.c (df_pattern_emit_later): Do not update BB boundary. (df_jump_pattern_emit_after): Likewise. (df_insn_move_before): Use emit_insn_before. * emit-rtl.c (try_split): Emit after trial to get bb boundary updated properly. (add_insn_after, add_insn_before, emit_insns_after): Update BB boundaries and basic_block_for_insn. (reorder_insns_nobb): Rename from reorder_insns. (reorder_insns): New. (emit_block_insn_before, emit_block_insn_after): Kill. * flow.c (check_function_return_warnings): Do not call compute_bb_for_insn; Do not free basic_block_for_insn. (attempt_auto_inc): Do not update basic_block_for_insn. * function.c (emit_return_into_block): Likewise; do not update BB boundaries. * gcse.c (handle_avail_expr): Do not update basic_block_for_insn. (insert_insn_end_bb): Use emit_insn_before; Likewise. (pre_insert_copy_insn): Likewise. (update_ld_motion_notes): Likewise. (insert_insn_start_bb): Likewise. (replace_store_insn): Likewise. * ifcvt.c (noce_process_if_block): Likewise. (if_convert): Do not call compute_bb_for_insn. * lcm.c (optimize_mode_switching): Do not update BB boundaries. Use emit_insn_before and emit_insn_after. * recog.c (split_all_insns): Do not update BB boundaries; Do not call compute_bb_for_insn. (peephole2_optimize): Do not update BB boundaries. * reg-stack.c (emit_pop_insn): Use emit_insn_after and emit_insn_before. (emit_swap_insn): Likewise. (convert_regs_1): Likewise. * reload1.c (reload): Call compute_bb_for_insn. * rtl.h (reorder_insns_nobb): Declare. * ssa.c (rename_equivalent_regs): Use emit_insn_before. * toplev.c (rest_of_compilation): Call free_bb_for_insn at places CFG is invalidated; do not call compute_bb_for_insn. * cfg.c (expunge_block): Invalidate BB structure. * (merge_blocks_nomove): Update properly BLOCK_FOR_INSN array. * cfg.c (verify_flow_info): Verify the basic_block_for_insn array. From-SVN: r45647
-rw-r--r--gcc/ChangeLog63
-rw-r--r--gcc/basic-block.h1
-rw-r--r--gcc/bb-reorder.c62
-rw-r--r--gcc/cfg.c61
-rw-r--r--gcc/cfgbuild.c2
-rw-r--r--gcc/cfgcleanup.c6
-rw-r--r--gcc/combine.c1
-rw-r--r--gcc/df.c8
-rw-r--r--gcc/emit-rtl.c111
-rw-r--r--gcc/flow.c12
-rw-r--r--gcc/function.c15
-rw-r--r--gcc/gcse.c34
-rw-r--r--gcc/haifa-sched.c6
-rw-r--r--gcc/ifcvt.c5
-rw-r--r--gcc/lcm.c10
-rw-r--r--gcc/recog.c17
-rw-r--r--gcc/reg-stack.c10
-rw-r--r--gcc/reload1.c1
-rw-r--r--gcc/rtl.h1
-rw-r--r--gcc/ssa.c2
-rw-r--r--gcc/toplev.c32
21 files changed, 242 insertions, 218 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 934d0b1..069d527 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,66 @@
+Sun Sep 16 21:59:46 CEST 2001 Jan hubicka <jh@suse.cz>
+
+ * basic-block.h (free_bb_for_insn): Declare.
+ * bb-reorder.c (label_for_bb): Use block_label.
+ (emit_jump_to_block_after): Remove.
+ (insert_intra_1): Do not update block_for_insn.
+ (insert_inter_bb_scope_notes): Likewise; update bb->end
+ * cfg.c (free_bb_for_insn): New.
+ (try_rediret_by_replacing_jump): Avoid set_block_for_new_insns call.
+ (force_nonfallthru_and_redirect): Likewise; do not update BB boundaries.
+ (commit_one_edge_insertion): Likewise.
+ (commit_one_edge_insertion): Do not update BB boundary.
+ (commit_edge_insertions): Do not call compute_bb_for_insn.
+ * cfgbuild.c (find_basic_blocks): Do not free basic_block_for_insn.
+ * cfgcleanup.c (merge_blocks_move_predecessor): Use reorder_insns_nobb.
+ (merge_blocks_move_successor_nojumps): Likewise.
+ (try_crossjump_to_edge): Do not update block_for_insn.
+ * combine.c (combine_instructions): Remove compute_bb_for_insn call.
+ * df.c (df_pattern_emit_later): Do not update BB boundary.
+ (df_jump_pattern_emit_after): Likewise.
+ (df_insn_move_before): Use emit_insn_before.
+ * emit-rtl.c (try_split): Emit after trial to get bb boundary updated
+ properly.
+ (add_insn_after, add_insn_before, emit_insns_after): Update BB
+ boundaries and basic_block_for_insn.
+ (reorder_insns_nobb): Rename from reorder_insns.
+ (reorder_insns): New.
+ (emit_block_insn_before, emit_block_insn_after): Kill.
+ * flow.c (check_function_return_warnings): Do not call
+ compute_bb_for_insn; Do not free basic_block_for_insn.
+ (attempt_auto_inc): Do not update basic_block_for_insn.
+ * function.c (emit_return_into_block): Likewise;
+ do not update BB boundaries.
+ * gcse.c (handle_avail_expr): Do not update basic_block_for_insn.
+ (insert_insn_end_bb): Use emit_insn_before; Likewise.
+ (pre_insert_copy_insn): Likewise.
+ (update_ld_motion_notes): Likewise.
+ (insert_insn_start_bb): Likewise.
+ (replace_store_insn): Likewise.
+ * ifcvt.c (noce_process_if_block): Likewise.
+ (if_convert): Do not call compute_bb_for_insn.
+ * lcm.c (optimize_mode_switching): Do not update BB boundaries.
+ Use emit_insn_before and emit_insn_after.
+ * recog.c (split_all_insns): Do not update BB boundaries;
+ Do not call compute_bb_for_insn.
+ (peephole2_optimize): Do not update BB boundaries.
+ * reg-stack.c (emit_pop_insn): Use emit_insn_after and
+ emit_insn_before.
+ (emit_swap_insn): Likewise.
+ (convert_regs_1): Likewise.
+ * reload1.c (reload): Call compute_bb_for_insn.
+ * rtl.h (reorder_insns_nobb): Declare.
+ * ssa.c (rename_equivalent_regs): Use emit_insn_before.
+ * toplev.c (rest_of_compilation): Call free_bb_for_insn
+ at places CFG is invalidated; do not call compute_bb_for_insn.
+
+ * cfg.c (expunge_block): Invalidate BB structure.
+
+ * (merge_blocks_nomove): Update properly BLOCK_FOR_INSN
+ array.
+
+ * cfg.c (verify_flow_info): Verify the basic_block_for_insn array.
+
2001-09-16 Neil Booth <neil@daikokuya.demon.co.uk>
* cpphash.h (_cpp_lex_token): Update prototype.
diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 1a61328..8771b78 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -288,6 +288,7 @@ extern varray_type basic_block_for_insn;
#define BLOCK_NUM(INSN) (BLOCK_FOR_INSN (INSN)->index + 0)
extern void compute_bb_for_insn PARAMS ((int));
+extern void free_bb_for_insn PARAMS ((void));
extern void update_bb_for_insn PARAMS ((basic_block));
extern void set_block_for_insn PARAMS ((rtx, basic_block));
extern void set_block_for_new_insns PARAMS ((rtx, basic_block));
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index f51294b..c471a6f 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -180,7 +180,6 @@ static void record_effective_endpoints PARAMS ((void));
static void make_reorder_chain PARAMS ((void));
static basic_block make_reorder_chain_1 PARAMS ((basic_block, basic_block));
static rtx label_for_bb PARAMS ((basic_block));
-static rtx emit_jump_to_block_after PARAMS ((basic_block, rtx));
static void fixup_reorder_chain PARAMS ((void));
static void relate_bbs_with_scopes PARAMS ((scope));
static scope make_new_scope PARAMS ((int, rtx));
@@ -505,60 +504,15 @@ label_for_bb (bb)
fprintf (rtl_dump_file, "Emitting label for block %d\n",
bb->index);
- label = emit_label_before (gen_label_rtx (), label);
- if (bb->head == RBI (bb)->eff_head)
+ label = block_label (bb);
+ if (bb->head == PREV_INSN (RBI (bb)->eff_head))
RBI (bb)->eff_head = label;
- bb->head = label;
- if (basic_block_for_insn)
- set_block_for_insn (label, bb);
}
return label;
}
-/* Emit a jump to BB after insn AFTER. */
-
-static rtx
-emit_jump_to_block_after (bb, after)
- basic_block bb;
- rtx after;
-{
- rtx jump;
-
- if (bb != EXIT_BLOCK_PTR)
- {
- rtx label = label_for_bb (bb);
- jump = emit_jump_insn_after (gen_jump (label), after);
- JUMP_LABEL (jump) = label;
- LABEL_NUSES (label) += 1;
- if (basic_block_for_insn)
- set_block_for_new_insns (jump, bb);
-
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "Emitting jump to block %d\n",
- bb->index);
- }
- else
- {
-#ifdef HAVE_return
- if (! HAVE_return)
- abort ();
- jump = emit_jump_insn_after (gen_return (), after);
- if (basic_block_for_insn)
- set_block_for_new_insns (jump, bb);
-
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "Emitting return\n");
-#else
- abort ();
-#endif
- }
-
- return jump;
-}
-
-
/* Given a reorder chain, rearrange the code to match. */
static void
@@ -1122,8 +1076,6 @@ insert_intra_1 (s, ip, bb)
{
*ip = emit_note_after (NOTE_INSN_BLOCK_BEG, *ip);
NOTE_BLOCK (*ip) = NOTE_BLOCK (s->note_beg);
- if (basic_block_for_insn)
- set_block_for_insn (*ip, bb);
}
for (p = s->inner; p; p = p->next)
@@ -1133,8 +1085,6 @@ insert_intra_1 (s, ip, bb)
{
*ip = emit_note_after (NOTE_INSN_BLOCK_END, *ip);
NOTE_BLOCK (*ip) = NOTE_BLOCK (s->note_end);
- if (basic_block_for_insn)
- set_block_for_insn (*ip, bb);
}
}
@@ -1220,6 +1170,8 @@ insert_inter_bb_scope_notes (bb1, bb2)
/* Close scopes. */
if (bb1)
{
+ rtx end = bb1->end;
+
scope s = RBI (bb1)->scope;
ip = RBI (bb1)->eff_end;
while (s != com)
@@ -1228,11 +1180,11 @@ insert_inter_bb_scope_notes (bb1, bb2)
{
ip = emit_note_after (NOTE_INSN_BLOCK_END, ip);
NOTE_BLOCK (ip) = NOTE_BLOCK (s->note_end);
- if (basic_block_for_insn)
- set_block_for_insn (ip, bb1);
}
s = s->outer;
}
+ /* Emitting note may move the end of basic block to unwanted place. */
+ bb1->end = end;
}
/* Open scopes. */
@@ -1246,8 +1198,6 @@ insert_inter_bb_scope_notes (bb1, bb2)
{
ip = emit_note_before (NOTE_INSN_BLOCK_BEG, ip);
NOTE_BLOCK (ip) = NOTE_BLOCK (s->note_beg);
- if (basic_block_for_insn)
- set_block_for_insn (ip, bb2);
}
s = s->outer;
}
diff --git a/gcc/cfg.c b/gcc/cfg.c
index ff59ef5..00645c2 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -451,6 +451,9 @@ expunge_block (b)
x->index = i;
}
+ /* Invalidate data to make bughunting easier. */
+ memset (b, 0, sizeof (*b));
+ b->index = -3;
basic_block_info->num_elements--;
n_basic_blocks--;
}
@@ -552,6 +555,16 @@ compute_bb_for_insn (max)
}
}
+/* Release the basic_block_for_insn array. */
+
+void
+free_bb_for_insn ()
+{
+ if (basic_block_for_insn)
+ VARRAY_FREE (basic_block_for_insn);
+ basic_block_for_insn = 0;
+}
+
/* Update insns block within BB. */
void
@@ -933,7 +946,7 @@ merge_blocks_nomove (a, b)
}
#endif
- a_end = prev;
+ a_end = PREV_INSN (del_first);
}
else if (GET_CODE (NEXT_INSN (a_end)) == BARRIER)
del_first = NEXT_INSN (a_end);
@@ -960,13 +973,14 @@ merge_blocks_nomove (a, b)
/* Reassociate the insns of B with A. */
if (!b_empty)
{
+ rtx x = a_end;
if (basic_block_for_insn)
{
- BLOCK_FOR_INSN (b_head) = a;
- while (b_head != b_end)
+ BLOCK_FOR_INSN (x) = a;
+ while (x != b_end)
{
- b_head = NEXT_INSN (b_head);
- BLOCK_FOR_INSN (b_head) = a;
+ x = NEXT_INSN (x);
+ BLOCK_FOR_INSN (x) = a;
}
}
a_end = b_end;
@@ -1061,8 +1075,6 @@ try_redirect_by_replacing_jump (e, target)
src->end = emit_jump_insn_before (gen_jump (target_label), kill_from);
JUMP_LABEL (src->end) = target_label;
LABEL_NUSES (target_label)++;
- if (basic_block_for_insn)
- set_block_for_new_insns (src->end, src);
if (rtl_dump_file)
fprintf (rtl_dump_file, "Replacing insn %i by jump %i\n",
INSN_UID (insn), INSN_UID (src->end));
@@ -1279,11 +1291,9 @@ force_nonfallthru_and_redirect (e, target)
jump_block = e->src;
e->flags &= ~EDGE_FALLTHRU;
label = block_label (target);
- jump_block->end = emit_jump_insn_after (gen_jump (label), jump_block->end);
+ emit_jump_insn_after (gen_jump (label), jump_block->end);
JUMP_LABEL (jump_block->end) = label;
LABEL_NUSES (label)++;
- if (basic_block_for_insn)
- set_block_for_new_insns (jump_block->end, jump_block);
emit_barrier_after (jump_block->end);
redirect_edge_succ_nodup (e, target);
@@ -1641,28 +1651,13 @@ commit_one_edge_insertion (e)
/* Now that we've found the spot, do the insertion. */
- /* Set the new block number for these insns, if structure is allocated. */
- if (basic_block_for_insn)
- {
- rtx i;
- for (i = insns; i != NULL_RTX; i = NEXT_INSN (i))
- set_block_for_insn (i, bb);
- }
-
if (before)
{
emit_insns_before (insns, before);
- if (before == bb->head)
- bb->head = insns;
-
last = prev_nonnote_insn (before);
}
else
- {
- last = emit_insns_after (insns, after);
- if (after == bb->end)
- bb->end = last;
- }
+ last = emit_insns_after (insns, after);
if (returnjump_p (last))
{
@@ -1679,7 +1674,6 @@ commit_one_edge_insertion (e)
e->flags &= ~EDGE_FALLTHRU;
emit_barrier_after (last);
- bb->end = last;
if (before)
flow_delete_insn (before);
@@ -1696,7 +1690,6 @@ commit_edge_insertions ()
{
int i;
basic_block bb;
- compute_bb_for_insn (get_max_uid ());
#ifdef ENABLE_CHECKING
verify_flow_info ();
@@ -2171,6 +2164,18 @@ verify_flow_info ()
edge_checksum[e->dest->index + 2] -= (size_t) e;
e = e->pred_next;
}
+ for (x = bb->head; x != NEXT_INSN (bb->end); x = NEXT_INSN (x))
+ if (basic_block_for_insn && BLOCK_FOR_INSN (x) != bb)
+ {
+ debug_rtx (x);
+ if (! BLOCK_FOR_INSN (x))
+ error ("Insn %d is inside basic block %d but block_for_insn is NULL",
+ INSN_UID (x), bb->index);
+ else
+ error ("Insn %d is inside basic block %d but block_for_insn is %i",
+ INSN_UID (x), bb->index, BLOCK_FOR_INSN (x)->index);
+ err = 1;
+ }
/* OK pointers are correct. Now check the header of basic
block. It ought to contain optional CODE_LABEL followed
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index a6ac3a0..85185e5 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -604,8 +604,6 @@ find_basic_blocks (f, nregs, file)
int max_uid;
timevar_push (TV_CFG);
- if (basic_block_for_insn)
- VARRAY_FREE (basic_block_for_insn);
basic_block_for_insn = 0;
/* Flush out existing data. */
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 2dbf8ef..7e227f6 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -290,7 +290,7 @@ merge_blocks_move_predecessor_nojumps (a, b)
/* Scramble the insn chain. */
if (a->end != PREV_INSN (b->head))
- reorder_insns (a->head, a->end, PREV_INSN (b->head));
+ reorder_insns_nobb (a->head, a->end, PREV_INSN (b->head));
if (rtl_dump_file)
{
@@ -349,7 +349,7 @@ merge_blocks_move_successor_nojumps (a, b)
squeeze_notes (&b->head, &b->end);
/* Scramble the insn chain. */
- reorder_insns (b->head, b->end, a->end);
+ reorder_insns_nobb (b->head, b->end, a->end);
/* Now blocks A and B are contiguous. Merge them. */
merge_blocks_nomove (a, b);
@@ -904,8 +904,6 @@ try_crossjump_to_edge (mode, e1, e2)
src1->end = emit_jump_insn_before (gen_jump (label), newpos1);
JUMP_LABEL (src1->end) = label;
LABEL_NUSES (label)++;
- if (basic_block_for_insn)
- set_block_for_new_insns (src1->end, src1);
/* Delete the now unreachable instructions. */
flow_delete_insn_chain (newpos1, last);
diff --git a/gcc/combine.c b/gcc/combine.c
index 1512ef0..ed1c45f 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -717,7 +717,6 @@ combine_instructions (f, nregs)
if (need_refresh)
{
- compute_bb_for_insn (get_max_uid ());
update_life_info (refresh_blocks, UPDATE_LIFE_GLOBAL_RM_NOTES,
PROP_DEATH_NOTES);
}
diff --git a/gcc/df.c b/gcc/df.c
index 177da10..947ea45 100644
--- a/gcc/df.c
+++ b/gcc/df.c
@@ -2959,9 +2959,6 @@ df_pattern_emit_after (df, pattern, bb, insn)
if (ret_insn == insn)
return ret_insn;
- if (bb->end == insn)
- bb->end = ret_insn;
-
df_insns_modify (df, bb, NEXT_INSN (insn), ret_insn);
return ret_insn;
}
@@ -2981,9 +2978,6 @@ df_jump_pattern_emit_after (df, pattern, bb, insn)
if (ret_insn == insn)
return ret_insn;
- if (bb->end == insn)
- bb->end = ret_insn;
-
df_insns_modify (df, bb, NEXT_INSN (insn), ret_insn);
return ret_insn;
}
@@ -3023,7 +3017,7 @@ df_insn_move_before (df, bb, insn, before_bb, before_insn)
/* ???? Perhaps all the insns moved should be stored on a list
which df_analyse removes when it recalculates data flow. */
- return emit_block_insn_before (insn, before_insn, before_bb);
+ return emit_insn_before (insn, before_insn);
}
/* Functions to query dataflow information. */
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 863ad294..82bff92 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -2574,7 +2574,7 @@ try_split (pat, trial, last)
if (GET_CODE (XVECEXP (seq, 0, i)) == INSN)
mark_label_nuses (PATTERN (XVECEXP (seq, 0, i)));
- tem = emit_insn_after (seq, before);
+ tem = emit_insn_after (seq, trial);
delete_insn (trial);
if (has_barrier)
@@ -2710,6 +2710,7 @@ add_insn_after (insn, after)
rtx insn, after;
{
rtx next = NEXT_INSN (after);
+ basic_block bb;
if (optimize && INSN_DELETED_P (after))
abort ();
@@ -2740,6 +2741,21 @@ add_insn_after (insn, after)
abort ();
}
+ if (basic_block_for_insn
+ && (unsigned int)INSN_UID (after) < basic_block_for_insn->num_elements
+ && (bb = BLOCK_FOR_INSN (after)))
+ {
+ set_block_for_insn (insn, bb);
+ /* Should not happen as first in the BB is always
+ eigther NOTE or LABEL. */
+ if (bb->end == after
+ /* Avoid clobbering of structure when creating new BB. */
+ && GET_CODE (insn) != BARRIER
+ && (GET_CODE (insn) != NOTE
+ || NOTE_LINE_NUMBER (insn) != NOTE_INSN_BASIC_BLOCK))
+ bb->end = insn;
+ }
+
NEXT_INSN (after) = insn;
if (GET_CODE (after) == INSN && GET_CODE (PATTERN (after)) == SEQUENCE)
{
@@ -2758,6 +2774,7 @@ add_insn_before (insn, before)
rtx insn, before;
{
rtx prev = PREV_INSN (before);
+ basic_block bb;
if (optimize && INSN_DELETED_P (before))
abort ();
@@ -2791,6 +2808,21 @@ add_insn_before (insn, before)
abort ();
}
+ if (basic_block_for_insn
+ && (unsigned int)INSN_UID (before) < basic_block_for_insn->num_elements
+ && (bb = BLOCK_FOR_INSN (before)))
+ {
+ set_block_for_insn (insn, bb);
+ /* Should not happen as first in the BB is always
+ eigther NOTE or LABEl. */
+ if (bb->head == insn
+ /* Avoid clobbering of structure when creating new BB. */
+ && GET_CODE (insn) != BARRIER
+ && (GET_CODE (insn) != NOTE
+ || NOTE_LINE_NUMBER (insn) != NOTE_INSN_BASIC_BLOCK))
+ abort ();
+ }
+
PREV_INSN (before) = insn;
if (GET_CODE (before) == INSN && GET_CODE (PATTERN (before)) == SEQUENCE)
PREV_INSN (XVECEXP (PATTERN (before), 0, 0)) = insn;
@@ -2879,7 +2911,7 @@ delete_insns_since (from)
called after delay-slot filling has been done. */
void
-reorder_insns (from, to, after)
+reorder_insns_nobb (from, to, after)
rtx from, to, after;
{
/* Splice this bunch out of where it is now. */
@@ -2903,6 +2935,38 @@ reorder_insns (from, to, after)
last_insn = to;
}
+/* Same as function above, but take care to update BB boundaries. */
+void
+reorder_insns (from, to, after)
+ rtx from, to, after;
+{
+ rtx prev = PREV_INSN (from);
+ basic_block bb, bb2;
+
+ reorder_insns_nobb (from, to, after);
+
+ if (basic_block_for_insn
+ && (unsigned int)INSN_UID (after) < basic_block_for_insn->num_elements
+ && (bb = BLOCK_FOR_INSN (after)))
+ {
+ rtx x;
+
+ if (basic_block_for_insn
+ && (unsigned int)INSN_UID (from) < basic_block_for_insn->num_elements
+ && (bb2 = BLOCK_FOR_INSN (from)))
+ {
+ if (bb2->end == to)
+ bb2->end = prev;
+ }
+
+ if (bb->end == after)
+ bb->end = to;
+
+ for (x = from; x != NEXT_INSN (to); x = NEXT_INSN (x))
+ set_block_for_insn (x, bb);
+ }
+}
+
/* Return the line note insn preceding INSN. */
static rtx
@@ -3089,20 +3153,6 @@ emit_insn_before (pattern, before)
return insn;
}
-/* Similar to emit_insn_before, but update basic block boundaries as well. */
-
-rtx
-emit_block_insn_before (pattern, before, block)
- rtx pattern, before;
- basic_block block;
-{
- rtx prev = PREV_INSN (before);
- rtx r = emit_insn_before (pattern, before);
- if (block && block->head == before)
- block->head = NEXT_INSN (prev);
- return r;
-}
-
/* Make an instruction with body PATTERN and code JUMP_INSN
and output it before the instruction BEFORE. */
@@ -3243,19 +3293,6 @@ emit_insn_after_with_line_notes (pattern, after, from)
insn);
}
-/* Similar to emit_insn_after, but update basic block boundaries as well. */
-
-rtx
-emit_block_insn_after (pattern, after, block)
- rtx pattern, after;
- basic_block block;
-{
- rtx r = emit_insn_after (pattern, after);
- if (block && block->end == after)
- block->end = r;
- return r;
-}
-
/* Make an insn of code JUMP_INSN with body PATTERN
and output it after the insn AFTER. */
@@ -3431,6 +3468,7 @@ emit_insns_after (first, after)
{
register rtx last;
register rtx after_after;
+ basic_block bb;
if (!after)
abort ();
@@ -3438,8 +3476,19 @@ emit_insns_after (first, after)
if (!first)
return first;
- for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
- continue;
+ if (basic_block_for_insn
+ && (unsigned int)INSN_UID (after) < basic_block_for_insn->num_elements
+ && (bb = BLOCK_FOR_INSN (after)))
+ {
+ for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
+ set_block_for_insn (last, bb);
+ set_block_for_insn (last, bb);
+ if (bb->end == after)
+ bb->end = last;
+ }
+ else
+ for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
+ continue;
after_after = NEXT_INSN (after);
diff --git a/gcc/flow.c b/gcc/flow.c
index b5a6e37..24352bf 100644
--- a/gcc/flow.c
+++ b/gcc/flow.c
@@ -377,8 +377,6 @@ check_function_return_warnings ()
{
/* Recompute insn->block mapping, since the initial mapping is
set before we delete unreachable blocks. */
- compute_bb_for_insn (max_uid);
-
if (BLOCK_FOR_INSN (cfun->x_clobber_return_insn) != NULL)
warning ("control reaches end of non-void function");
}
@@ -739,12 +737,6 @@ void
free_basic_block_vars (keep_head_end_p)
int keep_head_end_p;
{
- if (basic_block_for_insn)
- {
- VARRAY_FREE (basic_block_for_insn);
- basic_block_for_insn = NULL;
- }
-
if (! keep_head_end_p)
{
if (basic_block_info)
@@ -3099,10 +3091,6 @@ attempt_auto_inc (pbi, inc, insn, mem, incr, incr_reg)
insns = get_insns ();
end_sequence ();
- if (basic_block_for_insn)
- for (temp = insns; temp; temp = NEXT_INSN (temp))
- set_block_for_insn (temp, pbi->bb);
-
/* If we can't make the auto-inc, or can't make the
replacement into Y, exit. There's no point in making
the change below if we can't do the auto-inc and doing
diff --git a/gcc/function.c b/gcc/function.c
index f2beb9f..e6a269e 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -7118,16 +7118,7 @@ emit_return_into_block (bb, line_note)
end = emit_jump_insn_after (gen_return (), bb->end);
if (line_note)
emit_line_note_after (NOTE_SOURCE_FILE (line_note),
- NOTE_LINE_NUMBER (line_note), bb->end);
-
- while (1)
- {
- set_block_for_insn (p, bb);
- if (p == bb->end)
- break;
- p = PREV_INSN (p);
- }
- bb->end = end;
+ NOTE_LINE_NUMBER (line_note), PREV_INSN (bb->end));
}
#endif /* HAVE_return */
@@ -7418,10 +7409,6 @@ epilogue_done:
i = PREV_INSN (insn);
newinsn = emit_insn_before (seq, insn);
- /* Update the UID to basic block map. */
- for (i = NEXT_INSN (i); i != insn; i = NEXT_INSN (i))
- set_block_for_insn (i, bb);
-
/* Retain a map of the epilogue insns. Used in life analysis to
avoid getting rid of sibcall epilogue insns. */
record_insns (GET_CODE (seq) == SEQUENCE
diff --git a/gcc/gcse.c b/gcc/gcse.c
index a6ea791..8e3187b 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -3508,9 +3508,6 @@ handle_avail_expr (insn, expr)
SET_DEST (expr_set)),
insn_computes_expr);
- /* Keep block number table up to date. */
- set_block_for_new_insns (new_insn, BLOCK_FOR_INSN (insn_computes_expr));
-
/* Keep register set table up to date. */
record_one_set (REGNO (to), new_insn);
@@ -4636,7 +4633,7 @@ insert_insn_end_bb (expr, bb, pre)
}
#endif
/* FIXME: What if something in cc0/jump uses value set in new insn? */
- new_insn = emit_block_insn_before (pat, insn, bb);
+ new_insn = emit_insn_before (pat, insn);
}
/* Likewise if the last insn is a call, as will happen in the presence
@@ -4674,13 +4671,10 @@ insert_insn_end_bb (expr, bb, pre)
|| NOTE_INSN_BASIC_BLOCK_P (insn))
insn = NEXT_INSN (insn);
- new_insn = emit_block_insn_before (pat, insn, bb);
+ new_insn = emit_insn_before (pat, insn);
}
else
- {
- new_insn = emit_insn_after (pat, insn);
- bb->end = new_insn;
- }
+ new_insn = emit_insn_after (pat, insn);
/* Keep block number table up to date.
Note, PAT could be a multiple insn sequence, we have to make
@@ -4690,8 +4684,6 @@ insert_insn_end_bb (expr, bb, pre)
for (i = 0; i < XVECLEN (pat, 0); i++)
{
rtx insn = XVECEXP (pat, 0, i);
-
- set_block_for_insn (insn, bb);
if (INSN_P (insn))
add_label_notes (PATTERN (insn), new_insn);
@@ -4701,7 +4693,6 @@ insert_insn_end_bb (expr, bb, pre)
else
{
add_label_notes (SET_SRC (pat), new_insn);
- set_block_for_new_insns (new_insn, bb);
/* Keep register set table up to date. */
record_one_set (regno, new_insn);
@@ -4815,20 +4806,14 @@ pre_insert_copy_insn (expr, insn)
int indx = expr->bitmap_index;
rtx set = single_set (insn);
rtx new_insn;
- basic_block bb = BLOCK_FOR_INSN (insn);
if (!set)
abort ();
new_insn = emit_insn_after (gen_move_insn (reg, SET_DEST (set)), insn);
- /* Keep block number table up to date. */
- set_block_for_new_insns (new_insn, bb);
-
/* Keep register set table up to date. */
record_one_set (regno, new_insn);
- if (insn == bb->end)
- bb->end = new_insn;
gcse_create_count++;
@@ -6254,7 +6239,6 @@ update_ld_motion_stores (expr)
copy = gen_move_insn ( reg, SET_SRC (pat));
new = emit_insn_before (copy, insn);
record_one_set (REGNO (reg), new);
- set_block_for_new_insns (new, BLOCK_FOR_INSN (insn));
SET_SRC (pat) = reg;
/* un-recognize this pattern since it's probably different now. */
@@ -6753,11 +6737,6 @@ insert_insn_start_bb (insn, bb)
insn = emit_insn_after (insn, prev);
- if (prev == bb->end)
- bb->end = insn;
-
- set_block_for_new_insns (insn, bb);
-
if (gcse_file)
{
fprintf (gcse_file, "STORE_MOTION insert store at start of BB %d:\n",
@@ -6846,7 +6825,6 @@ replace_store_insn (reg, del, bb)
insn = gen_move_insn (reg, SET_SRC (PATTERN (del)));
insn = emit_insn_after (insn, del);
- set_block_for_new_insns (insn, bb);
if (gcse_file)
{
@@ -6858,12 +6836,6 @@ replace_store_insn (reg, del, bb)
fprintf(gcse_file, "\n");
}
- if (bb->end == del)
- bb->end = insn;
-
- if (bb->head == del)
- bb->head = insn;
-
delete_insn (del);
}
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index d341f37..fe4153d 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -1971,7 +1971,11 @@ sched_init (dump_file)
&& GET_CODE (insn) != CODE_LABEL
/* Don't emit a NOTE if it would end up before a BARRIER. */
&& GET_CODE (NEXT_INSN (insn)) != BARRIER))
- emit_note_after (NOTE_INSN_DELETED, BLOCK_END (n_basic_blocks - 1));
+ {
+ emit_note_after (NOTE_INSN_DELETED, BLOCK_END (n_basic_blocks - 1));
+ /* Make insn to appear outside BB. */
+ BLOCK_END (n_basic_blocks - 1) = PREV_INSN (BLOCK_END (n_basic_blocks - 1));
+ }
/* Compute INSN_REG_WEIGHT for all blocks. We must do this before
removing death notes. */
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index ee6397f..4a76d22 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -1796,7 +1796,7 @@ noce_process_if_block (test_bb, then_bb, else_bb, join_bb)
insn_b = gen_sequence ();
end_sequence ();
- test_bb->end = emit_insn_after (insn_b, test_bb->end);
+ emit_insn_after (insn_b, test_bb->end);
}
/* Merge the blocks! */
@@ -2723,9 +2723,6 @@ if_convert (x_life_data_ok)
if (rtl_dump_file)
fflush (rtl_dump_file);
- /* Rebuild basic_block_for_insn for update_life_info and for gcse. */
- compute_bb_for_insn (get_max_uid ());
-
/* Rebuild life info for basic blocks that require it. */
if (num_removed_blocks && life_data_ok)
{
diff --git a/gcc/lcm.c b/gcc/lcm.c
index c69dee0..95cc8fb 100644
--- a/gcc/lcm.c
+++ b/gcc/lcm.c
@@ -1251,7 +1251,7 @@ optimize_mode_switching (file)
the case of EH edges, EH entry points also start
in normal mode, so a similar reasoning applies. */
else if (GET_CODE (src_bb->end) == INSN)
- src_bb->end = emit_insn_after (mode_set, src_bb->end);
+ emit_insn_after (mode_set, src_bb->end);
else
abort ();
bb_info[j][src_bb->index].computing = mode;
@@ -1313,7 +1313,7 @@ optimize_mode_switching (file)
if (GET_CODE (eg->src->end) == JUMP_INSN)
emit_insn_before (mode_set, eg->src->end);
else if (GET_CODE (eg->src->end) == INSN)
- eg->src->end = emit_insn_after (mode_set, eg->src->end);
+ emit_insn_after (mode_set, eg->src->end);
else
abort ();
}
@@ -1345,11 +1345,9 @@ optimize_mode_switching (file)
if (GET_CODE (ptr->insn_ptr) == NOTE
&& (NOTE_LINE_NUMBER (ptr->insn_ptr)
== NOTE_INSN_BASIC_BLOCK))
- emit_block_insn_after (mode_set, ptr->insn_ptr,
- BASIC_BLOCK (ptr->bbnum));
+ emit_insn_after (mode_set, ptr->insn_ptr);
else
- emit_block_insn_before (mode_set, ptr->insn_ptr,
- BASIC_BLOCK (ptr->bbnum));
+ emit_insn_before (mode_set, ptr->insn_ptr);
}
free (ptr);
diff --git a/gcc/recog.c b/gcc/recog.c
index c7d1dd7..21de5e5 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -2742,10 +2742,14 @@ split_all_insns (upd_life)
last = split_insn (insn);
if (last)
{
+ /* The split sequence may include barrier, but the
+ BB boundary we are interested in will be set to previous
+ one. */
+
+ while (GET_CODE (last) == BARRIER)
+ last = PREV_INSN (last);
SET_BIT (blocks, i);
changed = 1;
- if (insn == bb->end)
- bb->end = last;
insn = last;
}
@@ -2759,7 +2763,6 @@ split_all_insns (upd_life)
if (changed)
{
- compute_bb_for_insn (get_max_uid ());
for (i = 0; i < n_basic_blocks; i++)
find_sub_basic_blocks (BASIC_BLOCK (i));
}
@@ -3061,14 +3064,8 @@ peephole2_optimize (dump_file)
i -= MAX_INSNS_PER_PEEP2 + 1;
/* Replace the old sequence with the new. */
+ try = emit_insn_after (try, peep2_insn_data[i].insn);
flow_delete_insn_chain (insn, peep2_insn_data[i].insn);
- try = emit_insn_after (try, prev);
-
- /* Adjust the basic block boundaries. */
- if (peep2_insn_data[i].insn == bb->end)
- bb->end = try;
- if (insn == bb->head)
- bb->head = NEXT_INSN (prev);
#ifdef HAVE_conditional_execution
/* With conditional execution, we cannot back up the
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c
index 2c542c6..a8a9ef1 100644
--- a/gcc/reg-stack.c
+++ b/gcc/reg-stack.c
@@ -964,9 +964,9 @@ emit_pop_insn (insn, regstack, reg, where)
FP_MODE_REG (FIRST_STACK_REG, DFmode));
if (where == EMIT_AFTER)
- pop_insn = emit_block_insn_after (pop_rtx, insn, current_block);
+ pop_insn = emit_insn_after (pop_rtx, insn);
else
- pop_insn = emit_block_insn_before (pop_rtx, insn, current_block);
+ pop_insn = emit_insn_before (pop_rtx, insn);
REG_NOTES (pop_insn)
= gen_rtx_EXPR_LIST (REG_DEAD, FP_MODE_REG (FIRST_STACK_REG, DFmode),
@@ -1062,9 +1062,9 @@ emit_swap_insn (insn, regstack, reg)
FP_MODE_REG (FIRST_STACK_REG, XFmode));
if (i1)
- emit_block_insn_after (swap_rtx, i1, current_block);
+ emit_insn_after (swap_rtx, i1);
else if (current_block)
- emit_block_insn_before (swap_rtx, current_block->head, current_block);
+ emit_insn_before (swap_rtx, current_block->head);
else
emit_insn_before (swap_rtx, insn);
}
@@ -2748,7 +2748,7 @@ convert_regs_1 (file, block)
set = gen_rtx_SET (VOIDmode, FP_MODE_REG (reg, SFmode),
nan);
- insn = emit_block_insn_after (set, insn, block);
+ insn = emit_insn_after (set, insn);
subst_stack_regs (insn, &regstack);
}
}
diff --git a/gcc/reload1.c b/gcc/reload1.c
index c405981..32303a5 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -1266,6 +1266,7 @@ reload (first, global)
/* Free all the insn_chain structures at once. */
obstack_free (&reload_obstack, reload_startobj);
unused_insn_chains = 0;
+ compute_bb_for_insn (get_max_uid ());
fixup_abnormal_edges ();
return failure;
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 95063c4..0ac125e 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1743,6 +1743,7 @@ extern void mark_reg_pointer PARAMS ((rtx, int));
extern void mark_user_reg PARAMS ((rtx));
extern void reset_used_flags PARAMS ((rtx));
extern void reorder_insns PARAMS ((rtx, rtx, rtx));
+extern void reorder_insns_nobb PARAMS ((rtx, rtx, rtx));
extern int get_max_uid PARAMS ((void));
extern int in_sequence_p PARAMS ((void));
extern void force_next_line_note PARAMS ((void));
diff --git a/gcc/ssa.c b/gcc/ssa.c
index f2ede4d..82be677 100644
--- a/gcc/ssa.c
+++ b/gcc/ssa.c
@@ -2121,7 +2121,7 @@ rename_equivalent_regs (reg_partition)
PATTERN (insn) = XVECEXP (s, 0, slen-1);
for (i = 0; i < slen - 1; i++)
- emit_block_insn_before (XVECEXP (s, 0, i), insn, b);
+ emit_insn_before (XVECEXP (s, 0, i), insn);
}
}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index d09dcca..6364305 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2751,6 +2751,9 @@ rest_of_compilation (decl)
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
optimize = saved_optimize;
+
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
}
current_function_nothrow = nothrow_function_p ();
@@ -2859,6 +2862,9 @@ rest_of_compilation (decl)
rebuild_jump_labels (insns);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP);
+
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
copy_loop_headers (insns);
purge_line_number_notes (insns);
@@ -2940,6 +2946,8 @@ rest_of_compilation (decl)
timevar_pop (TV_FROM_SSA);
ggc_collect ();
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
}
timevar_push (TV_JUMP);
@@ -2957,6 +2965,8 @@ rest_of_compilation (decl)
if_convert (0);
timevar_pop (TV_IFCVT);
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
/* Try to identify useless null pointer tests and delete them. */
if (flag_delete_null_pointer_checks)
delete_null_pointer_checks (insns);
@@ -3006,6 +3016,8 @@ rest_of_compilation (decl)
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
timevar_pop (TV_JUMP);
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
}
/* Run this after jump optmizations remove all the unreachable code
@@ -3021,6 +3033,8 @@ rest_of_compilation (decl)
cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
delete_null_pointer_checks (insns);
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
timevar_pop (TV_JUMP);
}
@@ -3059,6 +3073,8 @@ rest_of_compilation (decl)
save_cfj = flag_cse_follow_jumps;
flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
/* If -fexpensive-optimizations, re-run CSE to clean up things done
by gcse. */
if (flag_expensive_optimizations)
@@ -3080,6 +3096,8 @@ rest_of_compilation (decl)
delete_trivially_dead_insns (insns, max_reg_num (), 0);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
timevar_pop (TV_JUMP);
if (flag_expensive_optimizations)
@@ -3105,6 +3123,7 @@ rest_of_compilation (decl)
{
timevar_push (TV_LOOP);
open_dump_file (DFI_loop, decl);
+ free_bb_for_insn ();
if (flag_rerun_loop_opt)
{
@@ -3166,6 +3185,8 @@ rest_of_compilation (decl)
timevar_pop (TV_JUMP);
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
reg_scan (insns, max_reg_num (), 0);
tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
@@ -3175,6 +3196,8 @@ rest_of_compilation (decl)
rebuild_jump_labels (insns);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
cleanup_cfg (CLEANUP_EXPENSIVE);
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
timevar_pop (TV_JUMP);
}
}
@@ -3488,8 +3511,6 @@ rest_of_compilation (decl)
verify_flow_info ();
#endif
- compute_bb_for_insn (get_max_uid ());
-
/* If optimizing, then go ahead and split insns now. */
if (optimize > 0)
split_all_insns (0);
@@ -3594,7 +3615,7 @@ rest_of_compilation (decl)
reg_to_stack (insns, rtl_dump_file);
- close_dump_file (DFI_stack, print_rtl, insns);
+ close_dump_file (DFI_stack, print_rtl_with_bb, insns);
timevar_pop (TV_REG_STACK);
ggc_collect ();
@@ -3619,6 +3640,9 @@ rest_of_compilation (decl)
}
compute_alignments ();
+ /* CFG is no longer maitained up-to-date. */
+ free_bb_for_insn ();
+
/* If a machine dependent reorganization is needed, call it. */
#ifdef MACHINE_DEPENDENT_REORG
timevar_push (TV_MACH_DEP);
@@ -3632,8 +3656,6 @@ rest_of_compilation (decl)
ggc_collect ();
#endif
- /* CFG no longer kept up to date. */
-
purge_line_number_notes (insns);
cleanup_barriers ();