* basic-block.h (set_new_block_for_insns): New Prototype.
(set_block_num): Delete prototype.
* flow.c (set_block_num): Remove obsolete function.
(set_block_for_new_insns): Set BB for single or multiple insns.
* gcse.c (handle_avail_expr): Use set_block_for_new_insns.
(process_insn_end_bb): Use set_block_for_new_insns or
set_block_for_insn instead of set_block_num.
(pre_insert_copy_insn): Use set_block_for_new_insns.
(update_ld_motion_stores): Use set_block_for_new_insns.
(insert_insn_start_bb): Use set_block_for_new_insns.
(replace_store_insn): Use set_block_for_new_insns.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41208
138bc75d-0d04-0410-961f-
82ee72b054a4
2001-04-09 Andrew MacLeod <amacleod@redhat.com>
+
+ * basic-block.h (set_new_block_for_insns): New Prototype.
+ (set_block_num): Delete prototype.
+ * flow.c (set_block_num): Remove obsolete function.
+ (set_block_for_new_insns): Set BB for single or multiple insns.
+ * gcse.c (handle_avail_expr): Use set_block_for_new_insns.
+ (process_insn_end_bb): Use set_block_for_new_insns or
+ set_block_for_insn instead of set_block_num.
+ (pre_insert_copy_insn): Use set_block_for_new_insns.
+ (update_ld_motion_stores): Use set_block_for_new_insns.
+ (insert_insn_start_bb): Use set_block_for_new_insns.
+ (replace_store_insn): Use set_block_for_new_insns.
+
+2001-04-09 Andrew MacLeod <amacleod@redhat.com>
Jeff Law <law@redhat.com>
* alias.c (get_addr): Externalize.
extern void compute_bb_for_insn PARAMS ((int));
extern void update_bb_for_insn PARAMS ((basic_block));
extern void set_block_for_insn PARAMS ((rtx, basic_block));
-extern void set_block_num PARAMS ((rtx, int));
+extern void set_block_for_new_insns PARAMS ((rtx, basic_block));
extern void free_basic_block_vars PARAMS ((int));
VARRAY_BB (basic_block_for_insn, uid) = bb;
}
-/* Record INSN's block number as BB. */
-/* ??? This has got to go. */
+/* When a new insn has been inserted into an existing block, it will
+ sometimes emit more than a single insn. This routine will set the
+ block number for the specified insn, and look backwards in the insn
+ chain to see if there are any other uninitialized insns immediately
+ previous to this one, and set the block number for them too. */
void
-set_block_num (insn, bb)
+set_block_for_new_insns (insn, bb)
rtx insn;
- int bb;
+ basic_block bb;
{
- set_block_for_insn (insn, BASIC_BLOCK (bb));
+ set_block_for_insn (insn, bb);
+
+ /* We dont scan to set the block to 0 since this is the default value.
+ If we did, we'd end up scanning/setting the entire prologue block
+ everytime we insert an insn into it. */
+ if (bb->index == 0)
+ return;
+
+ /* Scan the previous instructions setting the block number until we find
+ an instruction that has the block number set, or we find a note
+ of any kind. */
+ for (insn = PREV_INSN (insn); insn != NULL_RTX; insn = PREV_INSN (insn))
+ {
+ if (GET_CODE (insn) == NOTE)
+ break;
+ if ((size_t)INSN_UID (insn) >= basic_block_for_insn->num_elements
+ || BLOCK_NUM (insn) == 0)
+ set_block_for_insn (insn, bb);
+ else
+ break;
+ }
}
\f
/* Verify the CFG consistency. This function check some CFG invariants and
insn_computes_expr);
/* Keep block number table up to date. */
- set_block_num (new_insn, BLOCK_NUM (insn_computes_expr));
+ 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);
{
rtx insn = XVECEXP (pat, 0, i);
- set_block_num (insn, bb);
+ set_block_for_insn (insn, BASIC_BLOCK (bb));
if (INSN_P (insn))
add_label_notes (PATTERN (insn), new_insn);
else
{
add_label_notes (SET_SRC (pat), new_insn);
- set_block_num (new_insn, bb);
+ set_block_for_new_insns (new_insn, BASIC_BLOCK (bb));
/* Keep register set table up to date. */
record_one_set (regno, new_insn);
insn);
/* Keep block number table up to date. */
- set_block_num (new_insn, bb);
+ set_block_for_new_insns (new_insn, BASIC_BLOCK (bb));
/* Keep register set table up to date. */
record_one_set (regno, new_insn);
copy = gen_move_insn ( reg, SET_SRC (pat));
i = emit_insn_before (copy, insn);
record_one_set (REGNO (reg), i);
- set_block_num (i, BLOCK_NUM (insn));
+ set_block_for_new_insns (i, BLOCK_FOR_INSN (insn));
SET_SRC (pat) = reg;
/* un-recognize this pattern since it's probably different now. */
if (prev == BLOCK_END (bb))
BLOCK_END (bb) = insn;
- while (insn != prev)
- {
- set_block_num (insn, bb);
- insn = PREV_INSN (insn);
- }
+
+ set_block_for_new_insns (insn, BASIC_BLOCK (bb));
if (gcse_file)
{
insn = gen_move_insn (reg, SET_SRC (PATTERN (del)));
insn = emit_insn_after (insn, del);
- set_block_num (insn, bb);
+ set_block_for_new_insns (insn, BASIC_BLOCK (bb));
if (gcse_file)
{