http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28896

--- Comment #8 from Larry Baker <baker at usgs dot gov> 2012-07-04 01:40:23 UTC 
---
Andreas,

I posted my negative findings that -mcpu=68020 still causes the
-fstack-limit-symbol code path to fail.  I believe the fundamental problem
there is the allocation of two different rtx registers that should actually
refer to the same rtx register.  Consider the code in gcc/config/m68k/m68k.c:

>   /* If the stack limit is a symbol, we can check it here,
>      before actually allocating the space.  */
>   if (crtl->limit_stack
>       && GET_CODE (stack_limit_rtx) == SYMBOL_REF)
>     {
>       limit = plus_constant (stack_limit_rtx, current_frame.size + 4);
>       if (!m68k_legitimate_constant_p (Pmode, limit))
>       {
>         emit_move_insn (gen_rtx_REG (Pmode, D0_REG), limit);
>         limit = gen_rtx_REG (Pmode, D0_REG);
>       }
>       emit_insn (gen_ctrapsi4 (gen_rtx_LTU (VOIDmode,
>                                           stack_pointer_rtx, limit),
>                              stack_pointer_rtx, limit,
>                              const1_rtx));
>     }
> 
>   fsize_with_regs = current_frame.size;

My analysis is (I am NOT a compiler developer, so I could be way off base here)
that gen_rtx_REG returns an rtx register reference to an unlimited pool of rtx
registers.  Somehow, later, the binding of the physical register D0_REG takes
place -- I guess in the code generator.  The emit_move_insn copies the limit
rtx expression into an unnamed rtx register.  That rtx register is valid, i.e.,
has a value.  The next line seems to be intended to modify limit to refer to
the rtx register containing the original limit value for use in emit_insn( trap
).  However, the rtx expression assigned to limit is not the rtx register that
has been set up; it is a new rtx register that is not valid, i.e., has no
value.

This code gets skipped if the limit rtx expression is already a valid constant.
 Which, I assume means it is a numeric constant, not a symbolic constant.

I think the proper code should name the rtx register allocated for the
emit_move_insn and then copy the value of that name into the limit rtx
expression:

>       {
>         rtx d0reg = gen_rtx_REG (Pmode, D0_REG);
>         emit_move_insn (d0reg, limit);
>         limit =d0reg;
>       }


What do you think?

Larry Baker
US Geological Survey
650-329-5608
ba...@usgs.gov



On 3 Jul 2012, at 2:47 AM, sch...@linux-m68k.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28896
> 
> Andreas Schwab <sch...@linux-m68k.org> changed:
> 
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Status|NEW                         |RESOLVED
>         Resolution|                            |FIXED
>   Target Milestone|---                         |4.8.0
> 
> --- Comment #6 from Andreas Schwab <sch...@linux-m68k.org> 2012-07-03 
> 09:47:41 UTC ---
> Fixed in 4.8.
> 
> -- 
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.

Reply via email to