summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-19 19:19:13 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-19 19:19:13 +0000
commitc86d86fffe04e33c7ac084e575b0298069b8e8f8 (patch)
tree25dcbcad495942e5f4d89b95ad979a56367bd84f
parent78bf41568c66b61419865b36f101121c8f5918a5 (diff)
downloadgcc-c86d86fffe04e33c7ac084e575b0298069b8e8f8.tar.gz
Make tablejump_p accept a rtx_jump_table_data **
2014-08-19 David Malcolm <dmalcolm@redhat.com> * rtl.h (tablejump_p): Strengthen third param from rtx * to rtx_jump_table_data **. * cfgbuild.c (make_edges): Introduce local "table", using it in place of "tmp" for jump table data. (find_bb_boundaries): Strengthen local "table" from rtx to rtx_jump_table_data *. * cfgcleanup.c (merge_blocks_move_successor_nojumps): Likewise. (outgoing_edges_match): Likewise for locals "table1" and "table2". (try_crossjump_to_edge): Likewise. * cfgrtl.c (try_redirect_by_replacing_jump): Likewise for local "table". (patch_jump_insn): Introduce local "table", using it in place of "tmp" for jump table data. (force_nonfallthru_and_redirect): Introduce local "table", so that call to tablejump_p can receive an rtx_jump_table_data **. Update logic around the call to overwrite "note" appropriately if tablejump_p returns non-zero. (get_last_bb_insn): Introduce local "table", using it in place of "tmp" for jump table data. * dwarf2cfi.c (create_trace_edges): Likewise. * config/arm/arm.c (get_jump_table_size): Strengthen param "insn" from rtx to rtx_jump_table_data *. (create_fix_barrier): Strengthen local "tmp" from rtx to rtx_jump_table_data *. (arm_reorg): Likewise for local "table". * config/s390/s390.c (s390_chunkify_start): Likewise. * config/spu/spu.c (spu_emit_branch_hint): Likewise. * jump.c (delete_related_insns): Strengthen local "lab_next" from rtx to rtx_jump_table_data *. * rtlanal.c (tablejump_p): Strengthen param "tablep" from rtx * to rtx_jump_table_data **. Add a checked cast when writing through the pointer: we know there that local "table" is non-NULL and that JUMP_TABLE_DATA_P (table) holds. (label_is_jump_target_p): Introduce local "table", using it in place of "tmp" for jump table data. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214184 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog44
-rw-r--r--gcc/cfgbuild.c11
-rw-r--r--gcc/cfgcleanup.c7
-rw-r--r--gcc/cfgrtl.c22
-rw-r--r--gcc/config/arm/arm.c8
-rw-r--r--gcc/config/s390/s390.c2
-rw-r--r--gcc/config/spu/spu.c2
-rw-r--r--gcc/dwarf2cfi.c6
-rw-r--r--gcc/jump.c3
-rw-r--r--gcc/rtl.h2
-rw-r--r--gcc/rtlanal.c11
11 files changed, 87 insertions, 31 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 900d616ac92..68f8001cc98 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,47 @@
+2014-08-19 David Malcolm <dmalcolm@redhat.com>
+
+ * rtl.h (tablejump_p): Strengthen third param from rtx * to
+ rtx_jump_table_data **.
+
+ * cfgbuild.c (make_edges): Introduce local "table", using it in
+ place of "tmp" for jump table data.
+ (find_bb_boundaries): Strengthen local "table" from rtx to
+ rtx_jump_table_data *.
+ * cfgcleanup.c (merge_blocks_move_successor_nojumps): Likewise.
+ (outgoing_edges_match): Likewise for locals "table1" and "table2".
+ (try_crossjump_to_edge): Likewise.
+ * cfgrtl.c (try_redirect_by_replacing_jump): Likewise for local
+ "table".
+ (patch_jump_insn): Introduce local "table", using it in place of
+ "tmp" for jump table data.
+ (force_nonfallthru_and_redirect): Introduce local "table", so that
+ call to tablejump_p can receive an rtx_jump_table_data **. Update
+ logic around the call to overwrite "note" appropriately if
+ tablejump_p returns non-zero.
+ (get_last_bb_insn): Introduce local "table", using it in place of
+ "tmp" for jump table data.
+ * dwarf2cfi.c (create_trace_edges): Likewise.
+
+ * config/arm/arm.c (get_jump_table_size): Strengthen param "insn"
+ from rtx to rtx_jump_table_data *.
+ (create_fix_barrier): Strengthen local "tmp" from rtx to
+ rtx_jump_table_data *.
+ (arm_reorg): Likewise for local "table".
+
+ * config/s390/s390.c (s390_chunkify_start): Likewise.
+
+ * config/spu/spu.c (spu_emit_branch_hint): Likewise.
+
+ * jump.c (delete_related_insns): Strengthen local "lab_next" from
+ rtx to rtx_jump_table_data *.
+
+ * rtlanal.c (tablejump_p): Strengthen param "tablep" from rtx * to
+ rtx_jump_table_data **. Add a checked cast when writing through
+ the pointer: we know there that local "table" is non-NULL and that
+ JUMP_TABLE_DATA_P (table) holds.
+ (label_is_jump_target_p): Introduce local "table", using it in
+ place of "tmp" for jump table data.
+
2014-08-19 Marek Polacek <polacek@redhat.com>
PR c++/62153
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index 76d3a99a8ed..848e13f51ab 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -252,6 +252,7 @@ make_edges (basic_block min, basic_block max, int update_p)
if (code == JUMP_INSN)
{
rtx tmp;
+ rtx_jump_table_data *table;
/* Recognize a non-local goto as a branch outside the
current function. */
@@ -259,15 +260,15 @@ make_edges (basic_block min, basic_block max, int update_p)
;
/* Recognize a tablejump and do the right thing. */
- else if (tablejump_p (insn, NULL, &tmp))
+ else if (tablejump_p (insn, NULL, &table))
{
rtvec vec;
int j;
- if (GET_CODE (PATTERN (tmp)) == ADDR_VEC)
- vec = XVEC (PATTERN (tmp), 0);
+ if (GET_CODE (PATTERN (table)) == ADDR_VEC)
+ vec = XVEC (PATTERN (table), 0);
else
- vec = XVEC (PATTERN (tmp), 1);
+ vec = XVEC (PATTERN (table), 1);
for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
make_label_edge (edge_cache, bb,
@@ -444,7 +445,7 @@ find_bb_boundaries (basic_block bb)
basic_block orig_bb = bb;
rtx insn = BB_HEAD (bb);
rtx end = BB_END (bb), x;
- rtx table;
+ rtx_jump_table_data *table;
rtx flow_transfer_insn = NULL_RTX;
edge fallthru = NULL;
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index d6d4bc04ebe..9f43912320d 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -704,7 +704,8 @@ static void
merge_blocks_move_successor_nojumps (basic_block a, basic_block b)
{
rtx barrier, real_b_end;
- rtx label, table;
+ rtx label;
+ rtx_jump_table_data *table;
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
@@ -1675,7 +1676,7 @@ outgoing_edges_match (int mode, basic_block bb1, basic_block bb2)
Return true if they are identical. */
{
rtx label1, label2;
- rtx table1, table2;
+ rtx_jump_table_data *table1, *table2;
if (tablejump_p (BB_END (bb1), &label1, &table1)
&& tablejump_p (BB_END (bb2), &label2, &table2)
@@ -1978,7 +1979,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
so replace the references to TABLE1 by references to TABLE2. */
{
rtx label1, label2;
- rtx table1, table2;
+ rtx_jump_table_data *table1, *table2;
if (tablejump_p (BB_END (osrc1), &label1, &table1)
&& tablejump_p (BB_END (osrc2), &label2, &table2)
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 2ff75223089..5babdf9d15f 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -1099,7 +1099,8 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
else
{
rtx target_label = block_label (target);
- rtx barrier, label, table;
+ rtx barrier, label;
+ rtx_jump_table_data *table;
emit_jump_insn_after_noloc (gen_jump (target_label), insn);
JUMP_LABEL (BB_END (src)) = target_label;
@@ -1172,9 +1173,10 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
static bool
patch_jump_insn (rtx insn, rtx old_label, basic_block new_bb)
{
+ rtx_jump_table_data *table;
rtx tmp;
/* Recognize a tablejump and adjust all matching cases. */
- if (tablejump_p (insn, NULL, &tmp))
+ if (tablejump_p (insn, NULL, &table))
{
rtvec vec;
int j;
@@ -1182,10 +1184,10 @@ patch_jump_insn (rtx insn, rtx old_label, basic_block new_bb)
if (new_bb == EXIT_BLOCK_PTR_FOR_FN (cfun))
return false;
- if (GET_CODE (PATTERN (tmp)) == ADDR_VEC)
- vec = XVEC (PATTERN (tmp), 0);
+ if (GET_CODE (PATTERN (table)) == ADDR_VEC)
+ vec = XVEC (PATTERN (table), 0);
else
- vec = XVEC (PATTERN (tmp), 1);
+ vec = XVEC (PATTERN (table), 1);
for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
if (XEXP (RTVEC_ELT (vec, j), 0) == old_label)
@@ -1607,7 +1609,10 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
/* If the old block ended with a tablejump, skip its table
by searching forward from there. Otherwise start searching
forward from the last instruction of the old block. */
- if (!tablejump_p (BB_END (e->src), NULL, &note))
+ rtx_jump_table_data *table;
+ if (tablejump_p (BB_END (e->src), NULL, &table))
+ note = table;
+ else
note = BB_END (e->src);
note = NEXT_INSN (note);
@@ -2234,12 +2239,13 @@ update_br_prob_note (basic_block bb)
rtx
get_last_bb_insn (basic_block bb)
{
+ rtx_jump_table_data *table;
rtx tmp;
rtx end = BB_END (bb);
/* Include any jump table following the basic block. */
- if (tablejump_p (end, NULL, &tmp))
- end = tmp;
+ if (tablejump_p (end, NULL, &table))
+ end = table;
/* Include any barriers that may follow the basic block. */
tmp = next_nonnote_insn_bb (end);
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 2f8d3274504..858f0d78950 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -108,7 +108,7 @@ static const char *output_multi_immediate (rtx *, const char *, const char *,
static const char *shift_op (rtx, HOST_WIDE_INT *);
static struct machine_function *arm_init_machine_status (void);
static void thumb_exit (FILE *, int);
-static HOST_WIDE_INT get_jump_table_size (rtx);
+static HOST_WIDE_INT get_jump_table_size (rtx_jump_table_data *);
static Mnode *move_minipool_fix_forward_ref (Mnode *, Mnode *, HOST_WIDE_INT);
static Mnode *add_minipool_forward_ref (Mfix *);
static Mnode *move_minipool_fix_backward_ref (Mnode *, Mnode *, HOST_WIDE_INT);
@@ -16122,7 +16122,7 @@ Mfix * minipool_barrier;
#endif
static HOST_WIDE_INT
-get_jump_table_size (rtx insn)
+get_jump_table_size (rtx_jump_table_data *insn)
{
/* ADDR_VECs only take room if read-only data does into the text
section. */
@@ -16710,7 +16710,7 @@ create_fix_barrier (Mfix *fix, HOST_WIDE_INT max_address)
while (from && count < max_count)
{
- rtx tmp;
+ rtx_jump_table_data *tmp;
int new_cost;
/* This code shouldn't have been called if there was a natural barrier
@@ -17355,7 +17355,7 @@ arm_reorg (void)
push_minipool_barrier (insn, address);
else if (INSN_P (insn))
{
- rtx table;
+ rtx_jump_table_data *table;
note_invalid_constants (insn, address, true);
address += get_attr_length (insn);
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index a2617a86e64..1dd7c015caf 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -7072,7 +7072,7 @@ s390_chunkify_start (void)
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
{
- rtx table;
+ rtx_jump_table_data *table;
/* Labels marked with LABEL_PRESERVE_P can be target
of non-local jumps, so we have to mark them.
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c
index 60d537ff64d..8816371cc34 100644
--- a/gcc/config/spu/spu.c
+++ b/gcc/config/spu/spu.c
@@ -2104,7 +2104,7 @@ spu_emit_branch_hint (rtx before, rtx branch, rtx target,
rtx branch_label = 0;
rtx hint;
rtx insn;
- rtx table;
+ rtx_jump_table_data *table;
if (before == 0 || branch == 0 || target == 0)
return;
diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
index 85cfb606836..665d41979c2 100644
--- a/gcc/dwarf2cfi.c
+++ b/gcc/dwarf2cfi.c
@@ -2291,14 +2291,16 @@ create_trace_edges (rtx insn)
if (JUMP_P (insn))
{
+ rtx_jump_table_data *table;
+
if (find_reg_note (insn, REG_NON_LOCAL_GOTO, NULL_RTX))
return;
- if (tablejump_p (insn, NULL, &tmp))
+ if (tablejump_p (insn, NULL, &table))
{
rtvec vec;
- tmp = PATTERN (tmp);
+ tmp = PATTERN (table);
vec = XVEC (tmp, GET_CODE (tmp) == ADDR_DIFF_VEC);
n = GET_NUM_ELEM (vec);
diff --git a/gcc/jump.c b/gcc/jump.c
index 87091a36e05..6a8b9d5b7b4 100644
--- a/gcc/jump.c
+++ b/gcc/jump.c
@@ -1295,7 +1295,8 @@ delete_related_insns (rtx insn)
if (jump_to_label_p (insn))
{
- rtx lab = JUMP_LABEL (insn), lab_next;
+ rtx lab = JUMP_LABEL (insn);
+ rtx_jump_table_data *lab_next;
if (LABEL_NUSES (lab) == 0)
/* This can delete NEXT or PREV,
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 76e24990ef8..79c0f691c7c 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2599,7 +2599,7 @@ extern int inequality_comparisons_p (const_rtx);
extern rtx replace_rtx (rtx, rtx, rtx);
extern int replace_label (rtx *, void *);
extern int rtx_referenced_p (rtx, rtx);
-extern bool tablejump_p (const_rtx, rtx *, rtx *);
+extern bool tablejump_p (const_rtx, rtx *, rtx_jump_table_data **);
extern int computed_jump_p (const_rtx);
extern bool tls_referenced_p (rtx);
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 0e8cb44c8b0..bc16437a257 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -2778,7 +2778,7 @@ rtx_referenced_p (rtx x, rtx body)
*LABELP and the jump table to *TABLEP. LABELP and TABLEP may be NULL. */
bool
-tablejump_p (const_rtx insn, rtx *labelp, rtx *tablep)
+tablejump_p (const_rtx insn, rtx *labelp, rtx_jump_table_data **tablep)
{
rtx label, table;
@@ -2793,7 +2793,7 @@ tablejump_p (const_rtx insn, rtx *labelp, rtx *tablep)
if (labelp)
*labelp = label;
if (tablep)
- *tablep = table;
+ *tablep = as_a <rtx_jump_table_data *> (table);
return true;
}
return false;
@@ -3794,14 +3794,15 @@ bool
label_is_jump_target_p (const_rtx label, const_rtx jump_insn)
{
rtx tmp = JUMP_LABEL (jump_insn);
+ rtx_jump_table_data *table;
if (label == tmp)
return true;
- if (tablejump_p (jump_insn, NULL, &tmp))
+ if (tablejump_p (jump_insn, NULL, &table))
{
- rtvec vec = XVEC (PATTERN (tmp),
- GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC);
+ rtvec vec = XVEC (PATTERN (table),
+ GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC);
int i, veclen = GET_NUM_ELEM (vec);
for (i = 0; i < veclen; ++i)