This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 04/50] caller-save.c:add_used_regs
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 03 Aug 2014 14:48:05 +0100
- Subject: [PATCH 04/50] caller-save.c:add_used_regs
- Authentication-results: sourceware.org; auth=none
- References: <87y4v5d77q dot fsf at googlemail dot com>
As noted in https://gcc.gnu.org/ml/gcc-patches/2014-02/msg01391.html
a bitmap-related cleanup turned add_used_regs_1 into a no-op for pseudo
registers, because the result of:
regno = reg_renumber[regno];
is never used. This patch does as Steven requested and adds an
assert that no allocated pseudos are seen here.
gcc/
* caller-save.c: Include rtl-iter.h.
(add_used_regs_1): Delete.
(add_used_regs): Use FOR_EACH_SUBRTX rather than for_each_rtx
to iterate over subrtxes. Assert that any remaining pseudos
have been spilled.
Index: gcc/caller-save.c
===================================================================
--- gcc/caller-save.c 2014-08-03 11:25:10.514960134 +0100
+++ gcc/caller-save.c 2014-08-03 11:25:21.155065328 +0100
@@ -37,6 +37,7 @@ Software Foundation; either version 3, o
#include "addresses.h"
#include "ggc.h"
#include "dumpfile.h"
+#include "rtl-iter.h"
#define MOVE_MAX_WORDS (MOVE_MAX / UNITS_PER_WORD)
@@ -1336,36 +1337,26 @@ insert_save (struct insn_chain *chain, i
return numregs - 1;
}
-/* A for_each_rtx callback used by add_used_regs. Add the hard-register
- equivalent of each REG to regset DATA. */
-
-static int
-add_used_regs_1 (rtx *loc, void *data)
-{
- unsigned int regno;
- regset live;
- rtx x;
-
- x = *loc;
- live = (regset) data;
- if (REG_P (x))
- {
- regno = REGNO (x);
- if (HARD_REGISTER_NUM_P (regno))
- bitmap_set_range (live, regno, hard_regno_nregs[regno][GET_MODE (x)]);
- else
- regno = reg_renumber[regno];
- }
- return 0;
-}
-
/* A note_uses callback used by insert_one_insn. Add the hard-register
equivalent of each REG to regset DATA. */
static void
add_used_regs (rtx *loc, void *data)
{
- for_each_rtx (loc, add_used_regs_1, data);
+ subrtx_iterator::array_type array;
+ FOR_EACH_SUBRTX (iter, array, *loc, NONCONST)
+ {
+ const_rtx x = *iter;
+ if (REG_P (x))
+ {
+ unsigned int regno = REGNO (x);
+ if (HARD_REGISTER_NUM_P (regno))
+ bitmap_set_range ((regset) data, regno,
+ hard_regno_nregs[regno][GET_MODE (x)]);
+ else
+ gcc_checking_assert (reg_renumber[regno] < 0);
+ }
+ }
}
/* Emit a new caller-save insn and set the code. */