[patch] combine ICE fix
Cesar Philippidis
cesar@codesourcery.com
Fri Oct 11 16:45:00 GMT 2013
On 10/10/13 9:25 AM, Jakub Jelinek wrote:
> That looks broken. You leave everything from the last size till the current
> one uninitialized, so it would only work if combine_split_insns
> always increments max_reg_num () by at most one.
Good catch.
> Furthermore, there are macros which should be used to access
> the fields, and, if the vector is ever going to be resized, supposedly
> it should be vec.h vector rather than just array.
> Or perhaps take into account:
> /* If a pass need to change these values in some magical way or the
> pass needs to have accurate values for these and is not using
> incremental df scanning, then it should use REG_N_SETS and
> REG_N_USES. If the pass is doing incremental scanning then it
> should be getting the info from DF_REG_DEF_COUNT and
> DF_REG_USE_COUNT. */
> and not use REG_N_SETS etc. but instead the df stuff.
I was thinking about converting that array to a vec. But I don't want to
touch more code than I have to right now. Is this OK as a stopgap?
Thanks for the review!
Cesar
-------------- next part --------------
2013-10-11 Cesar Philippidis <cesar@codesourcery.com>
gcc/
* regs.h (REG_N_GROW): New function.
* combine.c (combine_split_insns): Call REG_N_GROW when
new registers are created.
Index: gcc/regs.h
===================================================================
--- gcc/regs.h (revision 203289)
+++ gcc/regs.h (working copy)
@@ -89,6 +89,20 @@ REG_N_SETS (int regno)
#define SET_REG_N_SETS(N,V) (regstat_n_sets_and_refs[N].sets = V)
#define INC_REG_N_SETS(N,V) (regstat_n_sets_and_refs[N].sets += V)
+/* Indexed by n, inserts new registers (old_regno+1)..new_regno. */
+static inline void
+REG_N_GROW (int new_regno, int old_regno)
+{
+ regstat_n_sets_and_refs = XRESIZEVEC (struct regstat_n_sets_and_refs_t,
+ regstat_n_sets_and_refs, new_regno+1);
+
+ for (int i = old_regno + 1; i <= new_regno; ++i)
+ {
+ SET_REG_N_SETS (i, 1);
+ SET_REG_N_REFS (i, 1);
+ }
+}
+
/* Given a REG, return TRUE if the reg is a PARM_DECL, FALSE otherwise. */
extern bool reg_is_parm_p (rtx);
Index: gcc/combine.c
===================================================================
--- gcc/combine.c (revision 203289)
+++ gcc/combine.c (working copy)
@@ -518,7 +518,10 @@ combine_split_insns (rtx pattern, rtx insn)
ret = split_insns (pattern, insn);
nregs = max_reg_num ();
if (nregs > reg_stat.length ())
- reg_stat.safe_grow_cleared (nregs);
+ {
+ REG_N_GROW (nregs, reg_stat.length ());
+ reg_stat.safe_grow_cleared (nregs);
+ }
return ret;
}
More information about the Gcc-patches
mailing list