/* RTL dead code elimination.
- Copyright (C) 2005-2014 Free Software Foundation, Inc.
+ Copyright (C) 2005-2015 Free Software Foundation, Inc.
This file is part of GCC.
#include "config.h"
#include "system.h"
#include "coretypes.h"
-#include "hashtab.h"
#include "tm.h"
#include "rtl.h"
+#include "alias.h"
+#include "symtab.h"
#include "tree.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "flags.h"
#include "except.h"
+#include "dominance.h"
+#include "cfg.h"
+#include "cfgrtl.h"
+#include "cfgbuild.h"
+#include "cfgcleanup.h"
+#include "predict.h"
+#include "basic-block.h"
#include "df.h"
#include "cselib.h"
#include "dce.h"
/* Instructions that have been marked but whose dependencies have not
yet been processed. */
-static vec<rtx> worklist;
+static vec<rtx_insn *> worklist;
/* Bitmap of instructions marked as needed indexed by INSN_UID. */
static sbitmap marked;
static bitmap_obstack dce_blocks_bitmap_obstack;
static bitmap_obstack dce_tmp_bitmap_obstack;
-static bool find_call_stack_args (rtx, bool, bool, bitmap);
+static bool find_call_stack_args (rtx_call_insn *, bool, bool, bitmap);
/* A subroutine for which BODY is part of the instruction being tested;
either the top-level pattern, or an element of a PARALLEL. The
the DCE pass. */
static bool
-deletable_insn_p (rtx insn, bool fast, bitmap arg_stores)
+deletable_insn_p (rtx_insn *insn, bool fast, bitmap arg_stores)
{
rtx body, x;
int i;
infinite loop. */
&& (RTL_CONST_OR_PURE_CALL_P (insn)
&& !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
- return find_call_stack_args (insn, false, fast, arg_stores);
+ return find_call_stack_args (as_a <rtx_call_insn *> (insn), false,
+ fast, arg_stores);
/* Don't delete jumps, notes and the like. */
if (!NONJUMP_INSN_P (insn))
if (HARD_REGISTER_NUM_P (DF_REF_REGNO (def))
&& global_regs[DF_REF_REGNO (def)])
return false;
+ /* Initialization of pseudo PIC register should never be removed. */
+ else if (DF_REF_REG (def) == pic_offset_table_rtx
+ && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER)
+ return false;
body = PATTERN (insn);
switch (GET_CODE (body))
/* Return true if INSN has been marked as needed. */
static inline int
-marked_insn_p (rtx insn)
+marked_insn_p (rtx_insn *insn)
{
/* Artificial defs are always needed and they do not have an insn.
We should never see them here. */
the worklist. */
static void
-mark_insn (rtx insn, bool fast)
+mark_insn (rtx_insn *insn, bool fast)
{
if (!marked_insn_p (insn))
{
&& !SIBLING_CALL_P (insn)
&& (RTL_CONST_OR_PURE_CALL_P (insn)
&& !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
- find_call_stack_args (insn, true, fast, NULL);
+ find_call_stack_args (as_a <rtx_call_insn *> (insn), true, fast, NULL);
}
}
mark_nonreg_stores_1 (rtx dest, const_rtx pattern, void *data)
{
if (GET_CODE (pattern) != CLOBBER && !REG_P (dest))
- mark_insn ((rtx) data, true);
+ mark_insn ((rtx_insn *) data, true);
}
mark_nonreg_stores_2 (rtx dest, const_rtx pattern, void *data)
{
if (GET_CODE (pattern) != CLOBBER && !REG_P (dest))
- mark_insn ((rtx) data, false);
+ mark_insn ((rtx_insn *) data, false);
}
/* Mark INSN if BODY stores to a non-register destination. */
static void
-mark_nonreg_stores (rtx body, rtx insn, bool fast)
+mark_nonreg_stores (rtx body, rtx_insn *insn, bool fast)
{
if (fast)
note_stores (body, mark_nonreg_stores_1, insn);
going to be marked called again with DO_MARK true. */
static bool
-find_call_stack_args (rtx call_insn, bool do_mark, bool fast,
+find_call_stack_args (rtx_call_insn *call_insn, bool do_mark, bool fast,
bitmap arg_stores)
{
- rtx p, insn, prev_insn;
+ rtx p;
+ rtx_insn *insn, *prev_insn;
bool ret;
HOST_WIDE_INT min_sp_off, max_sp_off;
bitmap sp_bytes;
HOST_WIDE_INT off;
if (insn == BB_HEAD (BLOCK_FOR_INSN (call_insn)))
- prev_insn = NULL_RTX;
+ prev_insn = NULL;
else
prev_insn = PREV_INSN (insn);
writes to. */
static void
-remove_reg_equal_equiv_notes_for_defs (rtx insn)
+remove_reg_equal_equiv_notes_for_defs (rtx_insn *insn)
{
df_ref def;
reset_unmarked_insns_debug_uses (void)
{
basic_block bb;
- rtx insn, next;
+ rtx_insn *insn, *next;
FOR_EACH_BB_REVERSE_FN (bb, cfun)
FOR_BB_INSNS_REVERSE_SAFE (bb, insn, next)
struct df_link *defs;
for (defs = DF_REF_CHAIN (use); defs; defs = defs->next)
{
- rtx ref_insn;
+ rtx_insn *ref_insn;
if (DF_REF_IS_ARTIFICIAL (defs->ref))
continue;
ref_insn = DF_REF_INSN (defs->ref);
delete_unmarked_insns (void)
{
basic_block bb;
- rtx insn, next;
+ rtx_insn *insn, *next;
bool must_clean = false;
FOR_EACH_BB_REVERSE_FN (bb, cfun)
prescan_insns_for_dce (bool fast)
{
basic_block bb;
- rtx insn, prev;
+ rtx_insn *insn, *prev;
bitmap arg_stores = NULL;
if (dump_file)
{
basic_block bb;
struct df_link *defs;
- df_ref *use_rec;
+ df_ref use;
FOR_ALL_BB_FN (bb, cfun)
- {
- for (use_rec = df_get_artificial_uses (bb->index);
- *use_rec; use_rec++)
- for (defs = DF_REF_CHAIN (*use_rec); defs; defs = defs->next)
- if (! DF_REF_IS_ARTIFICIAL (defs->ref))
- mark_insn (DF_REF_INSN (defs->ref), false);
- }
+ FOR_EACH_ARTIFICIAL_USE (use, bb->index)
+ for (defs = DF_REF_CHAIN (use); defs; defs = defs->next)
+ if (!DF_REF_IS_ARTIFICIAL (defs->ref))
+ mark_insn (DF_REF_INSN (defs->ref), false);
}
/* Mark every instruction that defines a register value that INSN uses. */
static void
-mark_reg_dependencies (rtx insn)
+mark_reg_dependencies (rtx_insn *insn)
{
struct df_link *defs;
df_ref use;
static unsigned int
rest_of_handle_ud_dce (void)
{
- rtx insn;
+ rtx_insn *insn;
init_dce (false);
RTL_PASS, /* type */
"ud_dce", /* name */
OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_execute */
TV_DCE, /* tv_id */
0, /* properties_required */
0, /* properties_provided */
struct dead_debug_global *global_debug)
{
bitmap local_live = BITMAP_ALLOC (&dce_tmp_bitmap_obstack);
- rtx insn;
+ rtx_insn *insn;
bool block_changed;
struct dead_debug_local debug;
struct dead_debug_global *global_debug)
{
bitmap local_live = BITMAP_ALLOC (&dce_tmp_bitmap_obstack);
- rtx insn;
+ rtx_insn *insn;
bool block_changed;
df_ref def;
struct dead_debug_local debug;
RTL_PASS, /* type */
"rtl_dce", /* name */
OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_execute */
TV_DCE, /* tv_id */
0, /* properties_required */
0, /* properties_provided */