/* Dead-code elimination pass for the GNU compiler.
- Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Written by Jeffrey D. Oldham <oldham@codesourcery.com>.
This file is part of GCC.
\f
/* A map from blocks to the edges on which they are control dependent. */
typedef struct {
- /* An dynamically allocated array. The Nth element corresponds to
+ /* A dynamically allocated array. The Nth element corresponds to
the block with index N + 2. The Ith bit in the bitmap is set if
that block is dependent on the Ith edge. */
bitmap *data;
/* Local function prototypes. */
static control_dependent_block_to_edge_map control_dependent_block_to_edge_map_create
- PARAMS((size_t num_basic_blocks));
+ (size_t num_basic_blocks);
static void set_control_dependent_block_to_edge_map_bit
- PARAMS ((control_dependent_block_to_edge_map c, basic_block bb,
- int edge_index));
+ (control_dependent_block_to_edge_map c, basic_block bb, int edge_index);
static void control_dependent_block_to_edge_map_free
- PARAMS ((control_dependent_block_to_edge_map c));
+ (control_dependent_block_to_edge_map c);
static void find_all_control_dependences
- PARAMS ((struct edge_list *el, dominance_info pdom,
- control_dependent_block_to_edge_map cdbte));
+ (struct edge_list *el, dominance_info pdom,
+ control_dependent_block_to_edge_map cdbte);
static void find_control_dependence
- PARAMS ((struct edge_list *el, int edge_index, dominance_info pdom,
- control_dependent_block_to_edge_map cdbte));
-static basic_block find_pdom
- PARAMS ((dominance_info pdom, basic_block block));
-static int inherently_necessary_register_1
- PARAMS ((rtx *current_rtx, void *data));
-static int inherently_necessary_register
- PARAMS ((rtx current_rtx));
-static int find_inherently_necessary
- PARAMS ((rtx current_rtx));
-static int propagate_necessity_through_operand
- PARAMS ((rtx *current_rtx, void *data));
-static void note_inherently_necessary_set
- PARAMS ((rtx, rtx, void *));
+ (struct edge_list *el, int edge_index, dominance_info pdom,
+ control_dependent_block_to_edge_map cdbte);
+static basic_block find_pdom (dominance_info pdom, basic_block block);
+static int inherently_necessary_register_1 (rtx *current_rtx, void *data);
+static int inherently_necessary_register (rtx current_rtx);
+static int find_inherently_necessary (rtx current_rtx);
+static int propagate_necessity_through_operand (rtx *current_rtx, void *data);
+static void note_inherently_necessary_set (rtx, rtx, void *);
\f
/* Unnecessary insns are indicated using insns' in_struct bit. */
#define RESURRECT_INSN(INSN) INSN_DEAD_CODE_P(INSN) = 0
/* Return nonzero if INSN is unnecessary. */
#define UNNECESSARY_P(INSN) INSN_DEAD_CODE_P(INSN)
-static void mark_all_insn_unnecessary
- PARAMS ((void));
+static void mark_all_insn_unnecessary (void);
/* Execute CODE with free variable INSN for all unnecessary insns in
an unspecified order, producing no output. */
#define EXECUTE_IF_UNNECESSARY(INSN, CODE) \
rtx INSN; \
\
for (INSN = get_insns (); INSN != NULL_RTX; INSN = NEXT_INSN (INSN)) \
- if (INSN_DEAD_CODE_P (INSN)) { \
- CODE; \
- } \
+ if (INSN_P (insn) && INSN_DEAD_CODE_P (INSN)) \
+ { \
+ CODE; \
+ } \
}
+
/* Find the label beginning block BB. */
-static rtx find_block_label
- PARAMS ((basic_block bb));
+static rtx find_block_label (basic_block bb);
/* Remove INSN, updating its basic block structure. */
-static void delete_insn_bb
- PARAMS ((rtx insn));
+static void delete_insn_bb (rtx insn);
\f
/* Recording which blocks are control dependent on which edges. We
expect each block to be control dependent on very few edges so we
control_dependent_block_to_edge_map_free (). */
static control_dependent_block_to_edge_map
-control_dependent_block_to_edge_map_create (num_basic_blocks)
- size_t num_basic_blocks;
+control_dependent_block_to_edge_map_create (size_t num_basic_blocks)
{
int i;
control_dependent_block_to_edge_map c
control-dependent. */
static void
-set_control_dependent_block_to_edge_map_bit (c, bb, edge_index)
- control_dependent_block_to_edge_map c;
- basic_block bb;
- int edge_index;
+set_control_dependent_block_to_edge_map_bit (control_dependent_block_to_edge_map c,
+ basic_block bb, int edge_index)
{
if (bb->index - (INVALID_BLOCK+1) >= c->length)
abort ();
/* Destroy a control_dependent_block_to_edge_map C. */
static void
-control_dependent_block_to_edge_map_free (c)
- control_dependent_block_to_edge_map c;
+control_dependent_block_to_edge_map_free (control_dependent_block_to_edge_map c)
{
int i;
for (i = 0; i < c->length; ++i)
BITMAP_XFREE (c->data[i]);
- free ((PTR) c);
+ free (c);
}
/* Record all blocks' control dependences on all edges in the edge
which should be empty. */
static void
-find_all_control_dependences (el, pdom, cdbte)
- struct edge_list *el;
- dominance_info pdom;
- control_dependent_block_to_edge_map cdbte;
+find_all_control_dependences (struct edge_list *el, dominance_info pdom,
+ control_dependent_block_to_edge_map cdbte)
{
int i;
with zeros in each (block b', edge) position. */
static void
-find_control_dependence (el, edge_index, pdom, cdbte)
- struct edge_list *el;
- int edge_index;
- dominance_info pdom;
- control_dependent_block_to_edge_map cdbte;
+find_control_dependence (struct edge_list *el, int edge_index,
+ dominance_info pdom,
+ control_dependent_block_to_edge_map cdbte)
{
basic_block current_block;
basic_block ending_block;
negative numbers. */
static basic_block
-find_pdom (pdom, block)
- dominance_info pdom;
- basic_block block;
+find_pdom (dominance_info pdom, basic_block block)
{
if (!block)
abort ();
particular PC values. */
static int
-inherently_necessary_register_1 (current_rtx, data)
- rtx *current_rtx;
- void *data ATTRIBUTE_UNUSED;
+inherently_necessary_register_1 (rtx *current_rtx,
+ void *data ATTRIBUTE_UNUSED)
{
rtx x = *current_rtx;
/* Return nonzero if the insn CURRENT_RTX is inherently necessary. */
static int
-inherently_necessary_register (current_rtx)
- rtx current_rtx;
+inherently_necessary_register (rtx current_rtx)
{
return for_each_rtx (¤t_rtx,
&inherently_necessary_register_1, NULL);
nonzero value in inherently_necessary_p if such a store is found. */
static void
-note_inherently_necessary_set (dest, set, data)
- rtx set ATTRIBUTE_UNUSED;
- rtx dest;
- void *data;
+note_inherently_necessary_set (rtx dest, rtx set ATTRIBUTE_UNUSED, void *data)
{
int *inherently_necessary_set_p = (int *) data;
Return nonzero iff inherently necessary. */
static int
-find_inherently_necessary (x)
- rtx x;
+find_inherently_necessary (rtx x)
{
if (x == NULL_RTX)
return 0;
instructions. */
static int
-propagate_necessity_through_operand (current_rtx, data)
- rtx *current_rtx;
- void *data;
+propagate_necessity_through_operand (rtx *current_rtx, void *data)
{
rtx x = *current_rtx;
varray_type *unprocessed_instructions = (varray_type *) data;
/* Indicate all insns initially assumed to be unnecessary. */
static void
-mark_all_insn_unnecessary ()
+mark_all_insn_unnecessary (void)
{
rtx insn;
- for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn))
- KILL_INSN (insn);
+ for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn)) {
+ if (INSN_P (insn))
+ KILL_INSN (insn);
+ }
+
}
/* Find the label beginning block BB, adding one if necessary. */
static rtx
-find_block_label (bb)
- basic_block bb;
+find_block_label (basic_block bb)
{
rtx insn = bb->head;
if (LABEL_P (insn))
/* Remove INSN, updating its basic block structure. */
static void
-delete_insn_bb (insn)
- rtx insn;
+delete_insn_bb (rtx insn)
{
if (!insn)
abort ();
/* Perform the dead-code elimination. */
void
-ssa_eliminate_dead_code ()
+ssa_eliminate_dead_code (void)
{
rtx insn;
basic_block bb;
/* Find inherently necessary instructions. */
for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn))
- if (find_inherently_necessary (insn))
+ if (find_inherently_necessary (insn) && INSN_P (insn))
{
RESURRECT_INSN (insn);
VARRAY_PUSH_RTX (unprocessed_instructions, insn);
/* Propagate through the operands. */
for_each_rtx (¤t_instruction,
&propagate_necessity_through_operand,
- (PTR) &unprocessed_instructions);
+ &unprocessed_instructions);
/* PHI nodes are somewhat special in that each PHI alternative
has data and control dependencies. The data dependencies
}
}
/* Release allocated memory. */
- for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn))
- RESURRECT_INSN (insn);
+ for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn)) {
+ if (INSN_P (insn))
+ RESURRECT_INSN (insn);
+ }
+
if (VARRAY_ACTIVE_SIZE (unprocessed_instructions) != 0)
abort ();
control_dependent_block_to_edge_map_free (cdbte);
- free ((PTR) pdom);
+ free (pdom);
free_edge_list (el);
}