Makefile.in (reload1.o): Add dedendancy on except.h

* Makefile.in (reload1.o): Add dedendancy on except.h
        * basic-block.h (purge_all_dead_edges, purge_dead_edges): Update
        prototypes.
        * flow.c (purge_dead_edges, purge_all_dead_edges): Return bool
        indicating wehther edges has been cleaned up.
        * reload1.c: Inlucde except.h
        (fixup_abnormal_edges): Accept deleted insns.
        * toplev.c (rest_of_compilation): Purge dead edges unconditionally
        after combine.

From-SVN: r44654
This commit is contained in:
Jan Hubicka 2001-08-05 23:39:21 -07:00 committed by Richard Henderson
parent 9765f97213
commit 39f95a2c8e
6 changed files with 113 additions and 72 deletions

View File

@ -1,3 +1,15 @@
2001-08-05 Jan Hubicka <jh@suse.cz>
* Makefile.in (reload1.o): Add dedendancy on except.h
* basic-block.h (purge_all_dead_edges, purge_dead_edges): Update
prototypes.
* flow.c (purge_dead_edges, purge_all_dead_edges): Return bool
indicating wehther edges has been cleaned up.
* reload1.c: Inlucde except.h
(fixup_abnormal_edges): Accept deleted insns.
* toplev.c (rest_of_compilation): Purge dead edges unconditionally
after combine.
2001-08-06 Neil Booth <neil@daikokuya.demon.co.uk> 2001-08-06 Neil Booth <neil@daikokuya.demon.co.uk>
* cpplib.c (do_line): Correct line number after pop_buffer. * cpplib.c (do_line): Correct line number after pop_buffer.

View File

@ -1510,7 +1510,8 @@ reload.o : reload.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h output.h $(EXPR_H)
function.h real.h toplev.h $(TM_P_H) function.h real.h toplev.h $(TM_P_H)
reload1.o : reload1.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) real.h flags.h $(EXPR_H) \ reload1.o : reload1.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) real.h flags.h $(EXPR_H) \
reload.h $(REGS_H) hard-reg-set.h insn-config.h \ reload.h $(REGS_H) hard-reg-set.h insn-config.h \
$(BASIC_BLOCK_H) $(RECOG_H) output.h function.h toplev.h cselib.h $(TM_P_H) $(BASIC_BLOCK_H) $(RECOG_H) output.h function.h toplev.h cselib.h $(TM_P_H) \
except.h
caller-save.o : caller-save.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h \ caller-save.o : caller-save.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h \
$(REGS_H) hard-reg-set.h insn-config.h $(BASIC_BLOCK_H) function.h \ $(REGS_H) hard-reg-set.h insn-config.h $(BASIC_BLOCK_H) function.h \
$(RECOG_H) reload.h $(EXPR_H) toplev.h $(TM_P_H) $(RECOG_H) reload.h $(EXPR_H) toplev.h $(TM_P_H)

View File

@ -615,8 +615,8 @@ extern basic_block redirect_edge_and_branch_force PARAMS ((edge, basic_block));
extern bool redirect_edge_and_branch PARAMS ((edge, basic_block)); extern bool redirect_edge_and_branch PARAMS ((edge, basic_block));
extern rtx block_label PARAMS ((basic_block)); extern rtx block_label PARAMS ((basic_block));
extern bool forwarder_block_p PARAMS ((basic_block)); extern bool forwarder_block_p PARAMS ((basic_block));
extern void purge_all_dead_edges PARAMS ((void)); extern bool purge_all_dead_edges PARAMS ((void));
extern void purge_dead_edges PARAMS ((basic_block)); extern bool purge_dead_edges PARAMS ((basic_block));
extern void find_sub_basic_blocks PARAMS ((basic_block)); extern void find_sub_basic_blocks PARAMS ((basic_block));

View File

@ -10187,26 +10187,28 @@ init_flow ()
} }
/* Assume that the preceeding pass has possibly eliminated jump instructions /* Assume that the preceeding pass has possibly eliminated jump instructions
or converted the unconditional jumps. Eliminate the edges from CFG. */ or converted the unconditional jumps. Eliminate the edges from CFG.
Return true if any edges are eliminated. */
void bool
purge_dead_edges (bb) purge_dead_edges (bb)
basic_block bb; basic_block bb;
{ {
edge e, next; edge e, next;
rtx insn = bb->end; rtx insn = bb->end;
bool purged = false;
if (GET_CODE (insn) == JUMP_INSN && !simplejump_p (insn)) if (GET_CODE (insn) == JUMP_INSN && !simplejump_p (insn))
return; return false;
if (GET_CODE (insn) == JUMP_INSN) if (GET_CODE (insn) == JUMP_INSN)
{ {
int removed = 0;
rtx note; rtx note;
edge b,f; edge b,f;
/* We do care only about conditional jumps and simplejumps. */ /* We do care only about conditional jumps and simplejumps. */
if (!any_condjump_p (insn) if (!any_condjump_p (insn)
&& !returnjump_p (insn) && !returnjump_p (insn)
&& !simplejump_p (insn)) && !simplejump_p (insn))
return; return false;
for (e = bb->succ; e; e = next) for (e = bb->succ; e; e = next)
{ {
next = e->succ_next; next = e->succ_next;
@ -10221,15 +10223,15 @@ purge_dead_edges (bb)
if (e->dest == EXIT_BLOCK_PTR if (e->dest == EXIT_BLOCK_PTR
&& returnjump_p (insn)) && returnjump_p (insn))
continue; continue;
removed = 1; purged = true;
remove_edge (e); remove_edge (e);
} }
if (!bb->succ || !removed) if (!bb->succ || !purged)
return; return false;
if (rtl_dump_file) if (rtl_dump_file)
fprintf (rtl_dump_file, "Purged edges from bb %i\n", bb->index); fprintf (rtl_dump_file, "Purged edges from bb %i\n", bb->index);
if (!optimize) if (!optimize)
return; return purged;
/* Redistribute probabilities. */ /* Redistribute probabilities. */
if (!bb->succ->succ_next) if (!bb->succ->succ_next)
@ -10241,7 +10243,7 @@ purge_dead_edges (bb)
{ {
note = find_reg_note (insn, REG_BR_PROB, NULL); note = find_reg_note (insn, REG_BR_PROB, NULL);
if (!note) if (!note)
return; return purged;
b = BRANCH_EDGE (bb); b = BRANCH_EDGE (bb);
f = FALLTHRU_EDGE (bb); f = FALLTHRU_EDGE (bb);
b->probability = INTVAL (XEXP (note, 0)); b->probability = INTVAL (XEXP (note, 0));
@ -10249,8 +10251,22 @@ purge_dead_edges (bb)
b->count = bb->count * b->probability / REG_BR_PROB_BASE; b->count = bb->count * b->probability / REG_BR_PROB_BASE;
f->count = bb->count * f->probability / REG_BR_PROB_BASE; f->count = bb->count * f->probability / REG_BR_PROB_BASE;
} }
return; return purged;
} }
/* Cleanup abnormal edges caused by throwing insns that have been
eliminated. */
if (! can_throw_internal (bb->end))
for (e = bb->succ; e; e = next)
{
next = e->succ_next;
if (e->flags & EDGE_EH)
{
remove_edge (e);
purged = true;
}
}
/* If we don't see a jump insn, we don't know exactly why the block would /* If we don't see a jump insn, we don't know exactly why the block would
have been broken at this point. Look for a simple, non-fallthru edge, have been broken at this point. Look for a simple, non-fallthru edge,
as these are only created by conditional branches. If we find such an as these are only created by conditional branches. If we find such an
@ -10259,12 +10275,12 @@ purge_dead_edges (bb)
for (e = bb->succ; e && (e->flags & (EDGE_COMPLEX | EDGE_FALLTHRU)); for (e = bb->succ; e && (e->flags & (EDGE_COMPLEX | EDGE_FALLTHRU));
e = e->succ_next); e = e->succ_next);
if (!e) if (!e)
return; return purged;
for (e = bb->succ; e; e = next) for (e = bb->succ; e; e = next)
{ {
next = e->succ_next; next = e->succ_next;
if (!(e->flags & EDGE_FALLTHRU)) if (!(e->flags & EDGE_FALLTHRU))
remove_edge (e); remove_edge (e), purged = true;
} }
if (!bb->succ || bb->succ->succ_next) if (!bb->succ || bb->succ->succ_next)
abort (); abort ();
@ -10274,15 +10290,19 @@ purge_dead_edges (bb)
if (rtl_dump_file) if (rtl_dump_file)
fprintf (rtl_dump_file, "Purged non-fallthru edges from bb %i\n", fprintf (rtl_dump_file, "Purged non-fallthru edges from bb %i\n",
bb->index); bb->index);
return; return purged;
} }
/* Search all basic blocks for potentionally dead edges and purge them. */ /* Search all basic blocks for potentionally dead edges and purge them.
void Return true ifif some edge has been elliminated.
*/
bool
purge_all_dead_edges () purge_all_dead_edges ()
{ {
int i; int i, purged = false;
for (i = 0; i < n_basic_blocks; i++) for (i = 0; i < n_basic_blocks; i++)
purge_dead_edges (BASIC_BLOCK (i)); purged |= purge_dead_edges (BASIC_BLOCK (i));
return purged;
} }

View File

@ -39,6 +39,7 @@ Boston, MA 02111-1307, USA. */
#include "cselib.h" #include "cselib.h"
#include "real.h" #include "real.h"
#include "toplev.h" #include "toplev.h"
#include "except.h"
#if !defined PREFERRED_STACK_BOUNDARY && defined STACK_BOUNDARY #if !defined PREFERRED_STACK_BOUNDARY && defined STACK_BOUNDARY
#define PREFERRED_STACK_BOUNDARY STACK_BOUNDARY #define PREFERRED_STACK_BOUNDARY STACK_BOUNDARY
@ -9506,7 +9507,11 @@ fixup_abnormal_edges ()
for (e = bb->succ; e; e = e->succ_next) for (e = bb->succ; e; e = e->succ_next)
if (e->flags & EDGE_FALLTHRU) if (e->flags & EDGE_FALLTHRU)
break; break;
while (GET_CODE (insn) == INSN && !can_throw_internal (insn)) /* Get past the new insns generated. Allow notes, as the insns may
be already deleted. */
while ((GET_CODE (insn) == INSN || GET_CODE (insn) == NOTE)
&& !can_throw_internal (insn)
&& insn != bb->head)
insn = PREV_INSN (insn); insn = PREV_INSN (insn);
if (GET_CODE (insn) != CALL_INSN && !can_throw_internal (insn)) if (GET_CODE (insn) != CALL_INSN && !can_throw_internal (insn))
abort (); abort ();

View File

@ -3267,6 +3267,10 @@ rest_of_compilation (decl)
rebuild_jump_labels_after_combine rebuild_jump_labels_after_combine
= combine_instructions (insns, max_reg_num ()); = combine_instructions (insns, max_reg_num ());
/* Always purge dead edges, as we may eliminate an insn throwing
exception. */
rebuild_jump_labels_after_combine |= purge_all_dead_edges ();
/* Combining insns may have turned an indirect jump into a /* Combining insns may have turned an indirect jump into a
direct jump. Rebuid the JUMP_LABEL fields of jumping direct jump. Rebuid the JUMP_LABEL fields of jumping
instructions. */ instructions. */
@ -3277,7 +3281,6 @@ rest_of_compilation (decl)
timevar_pop (TV_JUMP); timevar_pop (TV_JUMP);
timevar_push (TV_FLOW); timevar_push (TV_FLOW);
purge_all_dead_edges ();
cleanup_cfg (CLEANUP_EXPENSIVE); cleanup_cfg (CLEANUP_EXPENSIVE);
/* Blimey. We've got to have the CFG up to date for the call to /* Blimey. We've got to have the CFG up to date for the call to