summaryrefslogtreecommitdiff
path: root/gcc/alias.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-03-01 08:22:06 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-03-01 08:22:06 +0000
commite6eacdc9451bbee54c80d6b85d22ba390fd2c7c4 (patch)
tree351106ed56d48df57047be4534967c2e4d1300b3 /gcc/alias.c
parent54178a01107b911813609693dd8d91968ac06819 (diff)
Tighten use of HARD_FRAME_POINTER_REGNUM in alias.c (PR 84538)
RTL code needs to be consistent about whether it uses the stack pointer, the frame pointer or the argument pointer to access a given part of the frame. alias.c used this to divide accesses into three independent areas. The problem in the PR is that we did this for HARD_FRAME_POINTER_REGNUM even when the register wasn't being used as a frame pointer. We can't do that because the frame pointer is then just any old allocatable register and could certainly point to info accessed through the argument pointer or stack pointer. 2018-03-01 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR rtl-optimization/84538 * alias.c (init_alias_target): Add commentary. (init_alias_analysis): Only give HARD_FRAME_POINTER_REGNUM a unique base value if the frame pointer is not eliminated to the stack pointer. gcc/testsuite/ PR rtl-optimization/84538 * gcc.dg/torture/pr84538.c: New test. From-SVN: r258094
Diffstat (limited to 'gcc/alias.c')
-rw-r--r--gcc/alias.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/alias.c b/gcc/alias.c
index 4c7965de807..5fa15cbd102 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -3191,12 +3191,21 @@ init_alias_target (void)
&& targetm.hard_regno_mode_ok (i, Pmode))
static_reg_base_value[i] = arg_base_value;
+ /* RTL code is required to be consistent about whether it uses the
+ stack pointer, the frame pointer or the argument pointer to
+ access a given area of the frame. We can therefore use the
+ base address to distinguish between the different areas. */
static_reg_base_value[STACK_POINTER_REGNUM]
= unique_base_value (UNIQUE_BASE_VALUE_SP);
static_reg_base_value[ARG_POINTER_REGNUM]
= unique_base_value (UNIQUE_BASE_VALUE_ARGP);
static_reg_base_value[FRAME_POINTER_REGNUM]
= unique_base_value (UNIQUE_BASE_VALUE_FP);
+
+ /* The above rules extend post-reload, with eliminations applying
+ consistently to each of the three pointers. Cope with cases in
+ which the frame pointer is eliminated to the hard frame pointer
+ rather than the stack pointer. */
if (!HARD_FRAME_POINTER_IS_FRAME_POINTER)
static_reg_base_value[HARD_FRAME_POINTER_REGNUM]
= unique_base_value (UNIQUE_BASE_VALUE_HFP);
@@ -3329,7 +3338,14 @@ init_alias_analysis (void)
/* Initialize the alias information for this pass. */
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- if (static_reg_base_value[i])
+ if (static_reg_base_value[i]
+ /* Don't treat the hard frame pointer as special if we
+ eliminated the frame pointer to the stack pointer instead. */
+ && !(i == HARD_FRAME_POINTER_REGNUM
+ && reload_completed
+ && !frame_pointer_needed
+ && targetm.can_eliminate (FRAME_POINTER_REGNUM,
+ STACK_POINTER_REGNUM)))
{
new_reg_base_value[i] = static_reg_base_value[i];
bitmap_set_bit (reg_seen, i);