public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/11736] New: Stackpointer messed up on SuperH
@ 2003-07-30 22:25 marcus at mc dot pp dot se
  2003-07-30 22:26 ` [Bug target/11736] " marcus at mc dot pp dot se
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: marcus at mc dot pp dot se @ 2003-07-30 22:25 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Stackpointer messed up on SuperH
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: marcus at mc dot pp dot se
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.8
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sh-elf

When a function with 5 arguments is called in both branches of a
conditional, and only the last argument differs, the code to push that
last argument on the stack gets confused.  Example function:

---8<--- r15bug.c ---8<---
extern void bar(int, int, int, int, int); 
 
void foo(int a) 
{ 
  if (a) 
    bar( 0, 0, 0, 0, 1 ); 
  else 
    bar( 0, 0, 0, 0, 0 ); 
} 
---8<---

Compiling with `sh-elf-gcc -O1 -S r15bug.c', I get this:

---8<--- r15bug.s ---8<---
        .file   "r15bug.c" 
        .text 
        .text 
        .align 1 
        .global _foo 
        .type   _foo, @function 
_foo: 
        mov.l   r14,@-r15 
        sts.l   pr,@-r15 
        mov     r15,r14 
        tst     r4,r4 
        add     #-4,r15   ! A
        mov     #1,r1 
        bf      .L4 
        add     #-4,r15   ! B
        mov     #0,r1 
.L4: 
        mov.l   r1,@r15 
        mov     #0,r4 
        mov     #0,r5 
        mov     #0,r6 
        mov.l   .L5,r1 
        jsr     @r1 
        mov     #0,r7
        add     #4,r15 
        mov     r14,r15 
        lds.l   @r15+,pr 
        rts      
        mov.l   @r15+,r14 
.L6: 
        .align 2 
.L5: 
        .long   _bar 
        .size   _foo, .-_foo 
        .ident  "GCC: (GNU) 3.3" 
---8<---

Space for the fifth argument is reserved on the stack by the
instruction I have marked as "A".  However, if the else-branch is
taken the stackpointer is decremented _again_ at "B".  This
decrementation is never restored, and it is only due to the
restoration of r15 from r14 that the function works at all.  With
-fomit-frame-pointer it will crash.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug target/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
@ 2003-07-30 22:26 ` marcus at mc dot pp dot se
  2003-08-11 12:43 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marcus at mc dot pp dot se @ 2003-07-30 22:26 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


marcus at mc dot pp dot se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug target/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
  2003-07-30 22:26 ` [Bug target/11736] " marcus at mc dot pp dot se
@ 2003-08-11 12:43 ` pinskia at gcc dot gnu dot org
  2003-08-25 16:06 ` dhazeghi at yahoo dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-11 12:43 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug target/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
  2003-07-30 22:26 ` [Bug target/11736] " marcus at mc dot pp dot se
  2003-08-11 12:43 ` pinskia at gcc dot gnu dot org
@ 2003-08-25 16:06 ` dhazeghi at yahoo dot com
  2003-08-25 21:46 ` marcus at mc dot pp dot se
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-25 16:06 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
  GCC build triplet|sparc-sun-solaris2.8        |
   GCC host triplet|sparc-sun-solaris2.8        |


------- Additional Comments From dhazeghi at yahoo dot com  2003-08-25 16:06 -------
Confirmed with mainline (20030825). Is the code produced by -O0 likewise bad?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug target/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
                   ` (2 preceding siblings ...)
  2003-08-25 16:06 ` dhazeghi at yahoo dot com
@ 2003-08-25 21:46 ` marcus at mc dot pp dot se
  2003-08-26  8:03 ` [Bug optimization/11736] " dhazeghi at yahoo dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marcus at mc dot pp dot se @ 2003-08-25 21:46 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From marcus at mc dot pp dot se  2003-08-25 21:46 -------
Subject: Re:  Stackpointer messed up on SuperH


"dhazeghi at yahoo dot com" <gcc-bugzilla@gcc.gnu.org> writes:

> Confirmed with mainline (20030825). Is the code produced by -O0 likewise bad?

No, with -O0 the code becomes

        [...]
        tst     r1,r1
        bt      .L2
        add     #-4,r15
        [...]

with another "add #-4,r15" at .L2:.  Since bt does not have the /s
flag, only one (and exactly one) of the adds will be executed.


  // Marcus


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
                   ` (3 preceding siblings ...)
  2003-08-25 21:46 ` marcus at mc dot pp dot se
@ 2003-08-26  8:03 ` dhazeghi at yahoo dot com
  2003-08-26  8:46 ` marcus at mc dot pp dot se
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-26  8:03 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
          Component|target                      |optimization
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-26 08:03:01
               date|                            |


------- Additional Comments From dhazeghi at yahoo dot com  2003-08-26 08:03 -------
Okay thanks. This makes it an optimization bug then...


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
                   ` (4 preceding siblings ...)
  2003-08-26  8:03 ` [Bug optimization/11736] " dhazeghi at yahoo dot com
@ 2003-08-26  8:46 ` marcus at mc dot pp dot se
  2003-09-15 18:14 ` dank at kegel dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marcus at mc dot pp dot se @ 2003-08-26  8:46 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From marcus at mc dot pp dot se  2003-08-26 08:46 -------
Subject: Re:  Stackpointer messed up on SuperH

Yes, it looks like the error occurs when the optimizer merges the
code for the two branches into one basic block.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
                   ` (5 preceding siblings ...)
  2003-08-26  8:46 ` marcus at mc dot pp dot se
@ 2003-09-15 18:14 ` dank at kegel dot com
  2004-01-05  0:27 ` kazu at cs dot umass dot edu
  2004-01-05  8:18 ` kazu at cs dot umass dot edu
  8 siblings, 0 replies; 10+ messages in thread
From: dank at kegel dot com @ 2003-09-15 18:14 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From dank at kegel dot com  2003-09-15 17:45 -------
I've prepared a patch to add a testcase for this PR to the testsuite; see
http://www.kegel.com/crosstool/current/patches/gcc-3.3.1/pr11736-1-test.patch
I'll submit it to gcc-patches in a couple days if nobody squawks.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
                   ` (6 preceding siblings ...)
  2003-09-15 18:14 ` dank at kegel dot com
@ 2004-01-05  0:27 ` kazu at cs dot umass dot edu
  2004-01-05  8:18 ` kazu at cs dot umass dot edu
  8 siblings, 0 replies; 10+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-01-05  0:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-01-05 00:27 -------
After the following patch, the problem does not occur at -O1.

http://gcc.gnu.org/ml/gcc-cvs/2004-01/msg00018.html

The problem might have gone away just because cross jumping was disabled.
It's probably a good idea to analyze the failure right before the above patch.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kazu at cs dot umass dot edu


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11736] Stackpointer messed up on SuperH
  2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
                   ` (7 preceding siblings ...)
  2004-01-05  0:27 ` kazu at cs dot umass dot edu
@ 2004-01-05  8:18 ` kazu at cs dot umass dot edu
  8 siblings, 0 replies; 10+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-01-05  8:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-01-05 08:18 -------
The problem still occurs with -O1 -fcross-jumping.

-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-01-05  8:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-30 22:25 [Bug target/11736] New: Stackpointer messed up on SuperH marcus at mc dot pp dot se
2003-07-30 22:26 ` [Bug target/11736] " marcus at mc dot pp dot se
2003-08-11 12:43 ` pinskia at gcc dot gnu dot org
2003-08-25 16:06 ` dhazeghi at yahoo dot com
2003-08-25 21:46 ` marcus at mc dot pp dot se
2003-08-26  8:03 ` [Bug optimization/11736] " dhazeghi at yahoo dot com
2003-08-26  8:46 ` marcus at mc dot pp dot se
2003-09-15 18:14 ` dank at kegel dot com
2004-01-05  0:27 ` kazu at cs dot umass dot edu
2004-01-05  8:18 ` kazu at cs dot umass dot edu

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).