public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
@ 2010-11-04 11:14 ` avr at gjlay dot de
  2010-11-09 10:24 ` anitha.boyapati at atmel dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: avr at gjlay dot de @ 2010-11-04 11:14 UTC (permalink / raw)
  To: gcc-bugs

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

Georg Lay <avr at gjlay dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |avr at gjlay dot de

--- Comment #13 from Georg Lay <avr at gjlay dot de> 2010-11-04 11:14:15 UTC ---
Implement TARGET_CANNOT_MODIFY_JUMPS_P and respect epilogue_completed and
cfun->machine->is_naked. This will stop BB reorder and similar post-epilogue
passes from moving the non-code-producing return-insn up.


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
  2010-11-04 11:14 ` [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function avr at gjlay dot de
@ 2010-11-09 10:24 ` anitha.boyapati at atmel dot com
  2010-11-09 10:26 ` anitha.boyapati at atmel dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anitha.boyapati at atmel dot com @ 2010-11-09 10:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Anitha Boyapati <anitha.boyapati at atmel dot com> 2010-11-09 10:24:11 UTC ---
Created attachment 22339
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22339
Initial patch to fix the bug

BB reordering pass is suppressed for naked functions. Also suppressed when the
end of epilogue is reached.


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
  2010-11-04 11:14 ` [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function avr at gjlay dot de
  2010-11-09 10:24 ` anitha.boyapati at atmel dot com
@ 2010-11-09 10:26 ` anitha.boyapati at atmel dot com
  2010-11-09 17:16 ` avr at gjlay dot de
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anitha.boyapati at atmel dot com @ 2010-11-09 10:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Anitha Boyapati <anitha.boyapati at atmel dot com> 2010-11-09 10:26:04 UTC ---
(In reply to comment #13)
> Implement TARGET_CANNOT_MODIFY_JUMPS_P and respect epilogue_completed and
> cfun->machine->is_naked. This will stop BB reorder and similar post-epilogue
> passes from moving the non-code-producing return-insn up.

Yes, BB reordering pass is shifting jump blocks. Attached patch solves the
issue. The output is: 

.brsh .L11        |     brlo .L5
                  >     ldi r24, lo8(0)
                  >     ldi r25, hi8(0)
                  >     rjmp .L6
                  >     L5:
.L11:             <
 ldi r24, lo8(0)  <
 ldi r25, hi8(0)  <
 rjmp .L6         <


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2010-11-09 10:26 ` anitha.boyapati at atmel dot com
@ 2010-11-09 17:16 ` avr at gjlay dot de
  2010-11-09 17:21 ` avr at gjlay dot de
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: avr at gjlay dot de @ 2010-11-09 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Georg Lay <avr at gjlay dot de> 2010-11-09 17:16:02 UTC ---
Created attachment 22349
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22349
PR target/42240


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2010-11-09 17:16 ` avr at gjlay dot de
@ 2010-11-09 17:21 ` avr at gjlay dot de
  2010-11-10 10:38 ` anitha.boyapati at atmel dot com
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: avr at gjlay dot de @ 2010-11-09 17:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from Georg Lay <avr at gjlay dot de> 2010-11-09 17:20:59 UTC ---
(In reply to comment #14)
> Created attachment 22339 [details]
> Initial patch to fix the bug
> 
> BB reordering pass is suppressed for naked functions. Also suppressed when the
> end of epilogue is reached.

BBreordering (or other passes doing similar things) need not to be disabled.
What do you think? Moreover, there is a gap between reload_completed and
epilogue_completed because the naked return insn is allowed since after reload.

Georg


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2010-11-09 17:21 ` avr at gjlay dot de
@ 2010-11-10 10:38 ` anitha.boyapati at atmel dot com
  2010-11-10 13:01 ` avr at gjlay dot de
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anitha.boyapati at atmel dot com @ 2010-11-10 10:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Anitha Boyapati <anitha.boyapati at atmel dot com> 2010-11-10 10:38:33 UTC ---
(In reply to comment #17)
> (In reply to comment #14)
> > Created attachment 22339 [details] [details]
> > Initial patch to fix the bug
> > 
> > BB reordering pass is suppressed for naked functions. Also suppressed when the
> > end of epilogue is reached.
> 
> BBreordering (or other passes doing similar things) need not to be disabled.
> What do you think? 

I think BBreordering after the end of epilogue in case of normal functions is
little confusing. For e.g., the same testcase with naked removed generates the
following code without the patch.

.L6:
        sts (seedram)+1,r25
        sts seedram,r24
/* epilogue start */
        ret
.L11:
        ldi r24,lo8(0)
        ldi r25,hi8(0)
        rjmp .L6


I am not sure what additional advantage we get by allowing this to happen after
epilogue. Hence I tried to disable this. Ofcourse, I still need to run entire
regression to see if this causes any side affect.

> Moreover, there is a gap between reload_completed and
> epilogue_completed 

Agreed. Thanks for catching that.


> because the naked return insn is allowed since after reload.

I dindn't quite get this. Can you give some example?


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2010-11-10 10:38 ` anitha.boyapati at atmel dot com
@ 2010-11-10 13:01 ` avr at gjlay dot de
  2011-02-27  9:33 ` denisc at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: avr at gjlay dot de @ 2010-11-10 13:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Georg Lay <avr at gjlay dot de> 2010-11-10 13:00:47 UTC ---
(In reply to comment #18)

> I think BBreordering after the end of epilogue in case of normal functions is
> little confusing.

Yes, optimized code is often confusing.

> I am not sure what additional advantage we get by allowing this to happen after 
> epilogue. Hence I tried to disable this. 

There is no bug for functions not attributed naked. I do not see why that
should be changed. Note that the backend is lying about branch costs and sets
them to zero -- both in space and time. Therefore, .bbro has fun and jumps
around. Tweaking that is of no concern here.

> > Moreover, there is a gap between reload_completed and
> > epilogue_completed 
> 
> Agreed. Thanks for catching that.
> 
> 
> > because the naked return insn is allowed since after reload.
> 
> I dindn't quite get this. Can you give some example?

avr.h allows that insn after reload:

(define_insn "return_from_naked_epilogue"
  [(return)]
  "(reload_completed 
    && cfun->machine 
    && cfun->machine->is_naked)"
  ...

so it might be emitted after reload. Because it is non-simple, it will occur
just once, but it must be in the right place (ensured by .pro_and_epilogue) and
must not be moved around (ensured by new target hook). Observe a simple test
case like lined out below, and how the compiler transform with/without naked,
optimize size/speed, branch cost 0/!=0

char c;

void foo (char i) 
{
  c = 17;
  switch (i)
    {
    case 0 : c = 1; break;
    case 3 : c = 2; break;
    case 7 : c = 12; break;
    case 9 : c = 32; break;
    }
}


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2010-11-10 13:01 ` avr at gjlay dot de
@ 2011-02-27  9:33 ` denisc at gcc dot gnu.org
  2011-03-03 16:59 ` denisc at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: denisc at gcc dot gnu.org @ 2011-02-27  9:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from denisc at gcc dot gnu.org 2011-02-27 08:36:58 UTC ---
Author: denisc
Date: Sun Feb 27 08:36:55 2011
New Revision: 170534

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170534
Log:
2011-02-22  Georg-Johann Lay  <avr@gjlay.de>

    PR target/42240
    * config/avr/avr.c (avr_cannot_modify_jumps_p): New function.
    (TARGET_CANNOT_MODIFY_JUMPS_P): Define.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.c


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2011-02-27  9:33 ` denisc at gcc dot gnu.org
@ 2011-03-03 16:59 ` denisc at gcc dot gnu.org
  2011-04-14 15:38 ` gjl at gcc dot gnu.org
  2012-01-26 23:44 ` gjl at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: denisc at gcc dot gnu.org @ 2011-03-03 16:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from denisc at gcc dot gnu.org 2011-03-03 16:58:34 UTC ---
Author: denisc
Date: Thu Mar  3 16:58:26 2011
New Revision: 170657

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170657
Log:
    Backport from mainline
    2011-02-22  Georg-Johann Lay  <avr@gjlay.de>

    PR target/42240
    * config/avr/avr.c (avr_cannot_modify_jumps_p): New function.
    (TARGET_CANNOT_MODIFY_JUMPS_P): Define.


Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/avr/avr.c


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2011-03-03 16:59 ` denisc at gcc dot gnu.org
@ 2011-04-14 15:38 ` gjl at gcc dot gnu.org
  2012-01-26 23:44 ` gjl at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-04-14 15:38 UTC (permalink / raw)
  To: gcc-bugs

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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |gjl at gcc dot gnu.org
      Known to work|                            |4.5.3, 4.6.0
         Resolution|                            |FIXED
      Known to fail|                            |

--- Comment #22 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-04-14 15:37:51 UTC ---
Closed as resolved+fixed in 4.5.3, 4.6.0


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
       [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2011-04-14 15:38 ` gjl at gcc dot gnu.org
@ 2012-01-26 23:44 ` gjl at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: gjl at gcc dot gnu.org @ 2012-01-26 23:44 UTC (permalink / raw)
  To: gcc-bugs

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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
   Target Milestone|4.3.6                       |4.5.3


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

* [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function
  2009-12-01 16:18 [Bug c/42240] New: wrong Epilog on nacked function stefan dot dreyer at yahoo dot de
@ 2010-07-31 10:22 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-31 10:22 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.3/4.4 Regression, avr]   |[4.3/4.4 Regression] wrong
                   |wrong epilogue on naked     |epilogue on naked function
                   |function                    |
   Target Milestone|---                         |4.3.6


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


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

end of thread, other threads:[~2012-01-26 22:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
2010-11-04 11:14 ` [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function avr at gjlay dot de
2010-11-09 10:24 ` anitha.boyapati at atmel dot com
2010-11-09 10:26 ` anitha.boyapati at atmel dot com
2010-11-09 17:16 ` avr at gjlay dot de
2010-11-09 17:21 ` avr at gjlay dot de
2010-11-10 10:38 ` anitha.boyapati at atmel dot com
2010-11-10 13:01 ` avr at gjlay dot de
2011-02-27  9:33 ` denisc at gcc dot gnu.org
2011-03-03 16:59 ` denisc at gcc dot gnu.org
2011-04-14 15:38 ` gjl at gcc dot gnu.org
2012-01-26 23:44 ` gjl at gcc dot gnu.org
2009-12-01 16:18 [Bug c/42240] New: wrong Epilog on nacked function stefan dot dreyer at yahoo dot de
2010-07-31 10:22 ` [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function rguenth at gcc dot gnu dot org

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