Commit 2b145ea8 by Richard Kenner

(global_const_equiv_map_size): New variable.

(expand_inline_function): Set it.
(expand_inline_function, copy_rtx_and_substitute, try_constants):
Never access const_equiv_map without checking for out-of-range.
(mark_stores): Likewise.

From-SVN: r6061
parent e26f388a
...@@ -1105,6 +1105,7 @@ copy_for_inline (orig) ...@@ -1105,6 +1105,7 @@ copy_for_inline (orig)
is used properly in the presence of recursion. */ is used properly in the presence of recursion. */
rtx *global_const_equiv_map; rtx *global_const_equiv_map;
int global_const_equiv_map_size;
#define FIXED_BASE_PLUS_P(X) \ #define FIXED_BASE_PLUS_P(X) \
(GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == CONST_INT \ (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == CONST_INT \
...@@ -1376,7 +1377,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add ...@@ -1376,7 +1377,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
if (GET_CODE (copy) != REG) if (GET_CODE (copy) != REG)
{ {
temp = copy_addr_to_reg (copy); temp = copy_addr_to_reg (copy);
if (CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy)) if ((CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
&& REGNO (temp) < map->const_equiv_map_size)
{ {
map->const_equiv_map[REGNO (temp)] = copy; map->const_equiv_map[REGNO (temp)] = copy;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM; map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
...@@ -1413,7 +1415,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add ...@@ -1413,7 +1415,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
{ {
temp = copy_to_mode_reg (GET_MODE (loc), copy); temp = copy_to_mode_reg (GET_MODE (loc), copy);
REG_USERVAR_P (temp) = REG_USERVAR_P (loc); REG_USERVAR_P (temp) = REG_USERVAR_P (loc);
if (CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy)) if ((CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
&& REGNO (temp) < map->const_equiv_map_size)
{ {
map->const_equiv_map[REGNO (temp)] = copy; map->const_equiv_map[REGNO (temp)] = copy;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM; map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
...@@ -1447,7 +1450,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add ...@@ -1447,7 +1450,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
{ {
temp = copy_to_mode_reg (GET_MODE (locreal), copyreal); temp = copy_to_mode_reg (GET_MODE (locreal), copyreal);
REG_USERVAR_P (temp) = REG_USERVAR_P (locreal); REG_USERVAR_P (temp) = REG_USERVAR_P (locreal);
if (CONSTANT_P (copyreal) || FIXED_BASE_PLUS_P (copyreal)) if ((CONSTANT_P (copyreal) || FIXED_BASE_PLUS_P (copyreal))
&& REGNO (temp) < map->const_equiv_map_size)
{ {
map->const_equiv_map[REGNO (temp)] = copyreal; map->const_equiv_map[REGNO (temp)] = copyreal;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM; map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
...@@ -1464,7 +1468,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add ...@@ -1464,7 +1468,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
{ {
temp = copy_to_mode_reg (GET_MODE (locimag), copyimag); temp = copy_to_mode_reg (GET_MODE (locimag), copyimag);
REG_USERVAR_P (temp) = REG_USERVAR_P (locimag); REG_USERVAR_P (temp) = REG_USERVAR_P (locimag);
if (CONSTANT_P (copyimag) || FIXED_BASE_PLUS_P (copyimag)) if ((CONSTANT_P (copyimag) || FIXED_BASE_PLUS_P (copyimag))
&& REGNO (temp) < map->const_equiv_map_size)
{ {
map->const_equiv_map[REGNO (temp)] = copyimag; map->const_equiv_map[REGNO (temp)] = copyimag;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM; map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
...@@ -1537,10 +1542,11 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add ...@@ -1537,10 +1542,11 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
{ {
temp = force_reg (Pmode, structure_value_addr); temp = force_reg (Pmode, structure_value_addr);
map->reg_map[REGNO (XEXP (loc, 0))] = temp; map->reg_map[REGNO (XEXP (loc, 0))] = temp;
if (CONSTANT_P (structure_value_addr) if ((CONSTANT_P (structure_value_addr)
|| (GET_CODE (structure_value_addr) == PLUS || (GET_CODE (structure_value_addr) == PLUS
&& XEXP (structure_value_addr, 0) == virtual_stack_vars_rtx && XEXP (structure_value_addr, 0) == virtual_stack_vars_rtx
&& GET_CODE (XEXP (structure_value_addr, 1)) == CONST_INT)) && GET_CODE (XEXP (structure_value_addr, 1)) == CONST_INT))
&& REGNO (temp) < map->const_equiv_map_size)
{ {
map->const_equiv_map[REGNO (temp)] = structure_value_addr; map->const_equiv_map[REGNO (temp)] = structure_value_addr;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM; map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
...@@ -1608,6 +1614,7 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add ...@@ -1608,6 +1614,7 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
/* Save a copy of the location of const_equiv_map for mark_stores, called /* Save a copy of the location of const_equiv_map for mark_stores, called
via note_stores. */ via note_stores. */
global_const_equiv_map = map->const_equiv_map; global_const_equiv_map = map->const_equiv_map;
global_const_equiv_map_size = map->const_equiv_map_size;
/* Now copy the insns one by one. Do this in two passes, first the insns and /* Now copy the insns one by one. Do this in two passes, first the insns and
then their REG_NOTES, just like save_for_inline. */ then their REG_NOTES, just like save_for_inline. */
...@@ -2013,8 +2020,12 @@ copy_rtx_and_substitute (orig, map) ...@@ -2013,8 +2020,12 @@ copy_rtx_and_substitute (orig, map)
#endif #endif
map->reg_map[regno] = temp map->reg_map[regno] = temp
= force_reg (Pmode, force_operand (loc, NULL_RTX)); = force_reg (Pmode, force_operand (loc, NULL_RTX));
map->const_equiv_map[REGNO (temp)] = loc;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM; if (REGNO (temp) < map->const_equiv_map_size)
{
map->const_equiv_map[REGNO (temp)] = loc;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
}
seq = gen_sequence (); seq = gen_sequence ();
end_sequence (); end_sequence ();
...@@ -2039,8 +2050,12 @@ copy_rtx_and_substitute (orig, map) ...@@ -2039,8 +2050,12 @@ copy_rtx_and_substitute (orig, map)
#endif #endif
map->reg_map[regno] = temp map->reg_map[regno] = temp
= force_reg (Pmode, force_operand (loc, NULL_RTX)); = force_reg (Pmode, force_operand (loc, NULL_RTX));
map->const_equiv_map[REGNO (temp)] = loc;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM; if (REGNO (temp) < map->const_equiv_map_size)
{
map->const_equiv_map[REGNO (temp)] = loc;
map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
}
seq = gen_sequence (); seq = gen_sequence ();
end_sequence (); end_sequence ();
...@@ -2372,11 +2387,12 @@ try_constants (insn, map) ...@@ -2372,11 +2387,12 @@ try_constants (insn, map)
{ {
int regno = REGNO (map->equiv_sets[i].dest); int regno = REGNO (map->equiv_sets[i].dest);
if (map->const_equiv_map[regno] == 0 if (regno < map->const_equiv_map_size
/* Following clause is a hack to make case work where GNU C++ && (map->const_equiv_map[regno] == 0
reassigns a variable to make cse work right. */ /* Following clause is a hack to make case work where GNU C++
|| ! rtx_equal_p (map->const_equiv_map[regno], reassigns a variable to make cse work right. */
map->equiv_sets[i].equiv)) || ! rtx_equal_p (map->const_equiv_map[regno],
map->equiv_sets[i].equiv)))
{ {
map->const_equiv_map[regno] = map->equiv_sets[i].equiv; map->const_equiv_map[regno] = map->equiv_sets[i].equiv;
map->const_age_map[regno] = map->const_age; map->const_age_map[regno] = map->const_age;
...@@ -2689,7 +2705,8 @@ mark_stores (dest, x) ...@@ -2689,7 +2705,8 @@ mark_stores (dest, x)
int i; int i;
for (i = regno; i <= last_reg; i++) for (i = regno; i <= last_reg; i++)
global_const_equiv_map[i] = 0; if (i < global_const_equiv_map_size)
global_const_equiv_map[i] = 0;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment