public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/10592: [arm] caller-save incorrectly handles a reloaded SET_DEST operand
@ 2003-05-02 13:15 rearnsha
0 siblings, 0 replies; 3+ messages in thread
From: rearnsha @ 2003-05-02 13:15 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, ryan.pipkin
Old Synopsis: apcs frame causing register mishandling
New Synopsis: [arm] caller-save incorrectly handles a reloaded SET_DEST operand
State-Changed-From-To: open->analyzed
State-Changed-By: rearnsha
State-Changed-When: Fri May 2 13:15:22 2003
State-Changed-Why:
This is a bug in the caller-save code. You can work around it for now by using -fno-caller-saves.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10592
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: optimization/10592: [arm] caller-save incorrectly handles a reloaded SET_DEST operand
@ 2003-05-02 14:06 Richard Earnshaw
0 siblings, 0 replies; 3+ messages in thread
From: Richard Earnshaw @ 2003-05-02 14:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/10592; it has been noted by GNATS.
From: Richard Earnshaw <rearnsha@arm.com>
To: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org,
ryan.pipkin@inet.com, law@redhat.com
Cc: Richard.Earnshaw@arm.com
Subject: Re: optimization/10592: [arm] caller-save incorrectly handles a
reloaded SET_DEST operand
Date: Fri, 02 May 2003 15:02:10 +0100
This is a multipart MIME message.
--==_Exmh_-1003055900
Content-Type: text/plain; charset=us-ascii
This patch implements the idea I just suggested, it does indeed seem to
solve the problem:
With the patch, the relevant bit of the code is now:
str ip, [fp, #-44]
bl strncpy
ldr ip, [fp, #-44]
add r2, r9, #156
add lr, r9, #16
str r2, [ip, #540]
I'll do a full testsuite run to check for regressions.
<date> Richard Earnshaw <rearnsha@arm.com>
* caller-save.c (mark_referenced_regs): Don't short-circuit a reg
or subreg in SET_DEST if it isn't a hard register.
R.
--==_Exmh_-1003055900
Content-Type: text/plain ; name="caller-save.patch"; charset=us-ascii
Content-Description: caller-save.patch
Content-Disposition: attachment; filename="caller-save.patch"
Index: caller-save.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/caller-save.c,v
retrieving revision 1.54
diff -p -r1.54 caller-save.c
*** caller-save.c 16 Dec 2002 18:19:05 -0000 1.54
--- caller-save.c 2 May 2003 13:57:25 -0000
*************** mark_referenced_regs (x)
*** 575,582 ****
{
x = SET_DEST (x);
code = GET_CODE (x);
! if (code == REG || code == PC || code == CC0
|| (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG
/* If we're setting only part of a multi-word register,
we shall mark it as referenced, because the words
that are not being set should be restored. */
--- 575,584 ----
{
x = SET_DEST (x);
code = GET_CODE (x);
! if ((code == REG && REGNO (x) < FIRST_PSEUDO_REGISTER)
! || code == PC || code == CC0
|| (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG
+ && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER
/* If we're setting only part of a multi-word register,
we shall mark it as referenced, because the words
that are not being set should be restored. */
--==_Exmh_-1003055900--
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: optimization/10592: [arm] caller-save incorrectly handles a reloaded SET_DEST operand
@ 2003-05-02 13:46 Richard Earnshaw
0 siblings, 0 replies; 3+ messages in thread
From: Richard Earnshaw @ 2003-05-02 13:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/10592; it has been noted by GNATS.
From: Richard Earnshaw <rearnsha@arm.com>
To: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org,
ryan.pipkin@inet.com, law@redhat.com
Cc: Richard.Earnshaw@arm.com
Subject: Re: optimization/10592: [arm] caller-save incorrectly handles a
reloaded SET_DEST operand
Date: Fri, 02 May 2003 14:45:33 +0100
[Jeff, I've put you on CC because you appear to be the original author of
the relevant code (back in Oct 98).]
Some more detailed analysis...
The problem we have here comes from the use of caller-save register
allocation and the failure to allocate a register to a pseudo that is
equivalent to a memory location that is derived from a caller-saved
register value. Specifically, we have the sequence prior to reload of
(call_insn:HI 249 227 326 2 0x4067c5d8 (parallel [
(set (reg:SI 0 r0)
(call (mem:SI (symbol_ref:SI ("strncpy") <function_decl
0x40330af8 strncpy>) [0 S4 A32])
(const_int 0 [0x0])))
(use (const_int 0 [0x0]))
(clobber (reg:SI 14 lr))
]) 190 {*call_value_symbol} (insn_list:REG_DEP_ANTI 76 (insn_list
248 (insn_list 247 (insn_list 246 (insn_list:REG_DEP_ANTI 30
(insn_list:REG_DEP_ANTI 172 (insn_list 210 (insn_list:REG_DEP_ANTI 75
(insn_list:REG_DEP_ANTI 74 (insn_list 47 (insn_list 227 (nil))))))))))))
(expr_list:REG_DEAD (reg:SI 1 r1 [ pName ])
(expr_list:REG_DEAD (reg:SI 2 r2)
(expr_list:REG_UNUSED (reg:SI 0 r0)
(expr_list:REG_UNUSED (reg:SI 14 lr)
(expr_list:REG_EH_REGION (const_int 0 [0x0])
(nil))))))
(expr_list (use (reg:SI 2 r2))
(expr_list (use (reg:SI 1 r1 [ pName ]))
(expr_list (use (reg:SI 0 r0))
(nil)))))
(insn:HI 326 249 331 2 0x40658dc0 (set (reg:SI 98)
(plus:SI (reg/v:SI 49 [ base ])
(const_int 156 [0x9c]))) 4 {*arm_addsi3} (insn_list 4
(insn_list:REG_DEP_ANTI 249 (nil)))
(expr_list:REG_EQUIV (mem/s:SI (plus:SI (reg/v/u/f:SI 48 [ this ])
(const_int 540 [0x21c])) [39 <variable>.pValue3+0 S4 A32])
(nil)))
Note that pseudo 98 has a REG_EQUIV of mem(plus (r48, 540))
Now global-alloc assigns r48 to the call-clobbered register r12, but
spills r98 back into its reg_equiv location. When save_call_clobbered_res
runs, therefore, r12 is stored to the stack before the call insn, but when
scanning r326 mark_referenced_regs ignores the SET_DEST in insn 326
because it is a REG:
if (code == SET || code == CLOBBER)
{
x = SET_DEST (x);
code = GET_CODE (x);
if (code == REG || code == PC || code == CC0
|| (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG
/* If we're setting only part of a multi-word register,
we shall mark it as referenced, because the words
that are not being set should be restored. */
&& ((GET_MODE_SIZE (GET_MODE (x))
>= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
|| (GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))
<= UNITS_PER_WORD))))
return;
We thus end up with the sequence of instructions
str ip, [frame+xxx]
call strncpy
add tmp, r9, #156
str tmp, [ip+540] // ip not restored first
I think the fix may be to make mark_referenced_regs only return if REG is
a hard register (similarly for SUBREG).
Jeff, any thoughts?
R.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-05-02 14:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-02 13:15 optimization/10592: [arm] caller-save incorrectly handles a reloaded SET_DEST operand rearnsha
2003-05-02 13:46 Richard Earnshaw
2003-05-02 14:06 Richard Earnshaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).