public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/38203]  New: attribute `noreturn' isn't effective when -mthumb param is active
@ 2008-11-20 16:42 alexandre dot nunes at gmail dot com
  2008-11-20 16:53 ` [Bug target/38203] " alexandre dot nunes at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: alexandre dot nunes at gmail dot com @ 2008-11-20 16:42 UTC (permalink / raw)
  To: gcc-bugs

A small testcase:

#include <stdlib.h>
extern unsigned int whatever(unsigned char *);

__attribute__((noreturn)) int main(void)
{
  whatever(NULL);
  for(;;);
}

If you compile this code without -mthumb, gcc asm output is as such:

       .file   "pqp.c"
        .text
        .align  2
        .global main
        .type   main, %function
main:
        @ Volatile: function does not return.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        mov     r0, #0
        bl      whatever
.L2:
        b       .L2
        .size   main, .-main
        .ident  "GCC: (GNU) 4.3.2"


... Or, in other words, it correctly avoids to preserve the link register.

With -mthumb, it pushes lr to the stack, which is the same behaviour as
removing the noreturn attribute.

The thing becomes relevant when main is a complex function that does not
return: it pushes not only lr, but several otherwise clobbered registers to the
stack which it won't pull back in, thus wasting stack space forever. As you can
imagined, in embedded targets every byte counts. when compiling to arm mode
(not thumb), it avoids preserving these since it has nowhere to return them to.


-- 
           Summary: attribute `noreturn' isn't effective when -mthumb param
                    is active
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexandre dot nunes at gmail dot com
GCC target triplet: arm-unknown-elf


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


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

* [Bug target/38203] attribute `noreturn' isn't effective when -mthumb param is active
  2008-11-20 16:42 [Bug target/38203] New: attribute `noreturn' isn't effective when -mthumb param is active alexandre dot nunes at gmail dot com
@ 2008-11-20 16:53 ` alexandre dot nunes at gmail dot com
  2009-03-24 18:34 ` ramana dot r at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: alexandre dot nunes at gmail dot com @ 2008-11-20 16:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from alexandre dot nunes at gmail dot com  2008-11-20 16:52 -------
Created an attachment (id=16728)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16728&action=view)
A more involved testcase.

This testcase shows the preserving behaviour on multiple call-clobbered
registers, in spite of noreturn attribute.


-- 


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


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

* [Bug target/38203] attribute `noreturn' isn't effective when -mthumb param is active
  2008-11-20 16:42 [Bug target/38203] New: attribute `noreturn' isn't effective when -mthumb param is active alexandre dot nunes at gmail dot com
  2008-11-20 16:53 ` [Bug target/38203] " alexandre dot nunes at gmail dot com
@ 2009-03-24 18:34 ` ramana dot r at gmail dot com
  2009-04-20 15:38 ` ramana at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: ramana dot r at gmail dot com @ 2009-03-24 18:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ramana dot r at gmail dot com  2009-03-24 18:34 -------
(In reply to comment #1)
> Created an attachment (id=16728)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16728&action=view) [edit]
> A more involved testcase.
> 
> This testcase shows the preserving behaviour on multiple call-clobbered
> registers, in spite of noreturn attribute.
> 

The save of registers appears on


Using built-in specs.
Target: arm-none-eabi
Configured with: /home/ramana/cos/mycos/combined-arm-none-eabi/configure
--target=arm-none-eabi --enable-languages=c,c++ : (reconfigured)
/home/ramana/cos/mycos/combined-arm-none-eabi/configure --target=arm-none-eabi
--enable-languages=c,c++ : (reconfigured)
/home/ramana/cos/mycos/combined-arm-none-eabi/configure --target=arm-none-eabi
target_alias=arm-none-eabi --enable-languages=c,c++ --no-create --no-recursion
Thread model: single
gcc version 4.4.0 20090324 (experimental) [trunk revision 143499] (GCC) 

and might be related to PR #38570 . 


-- 

ramana dot r at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rearnsha at gcc dot gnu dot
                   |                            |org, ramana dot r at gmail
                   |                            |dot com


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


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

* [Bug target/38203] attribute `noreturn' isn't effective when -mthumb param is active
  2008-11-20 16:42 [Bug target/38203] New: attribute `noreturn' isn't effective when -mthumb param is active alexandre dot nunes at gmail dot com
  2008-11-20 16:53 ` [Bug target/38203] " alexandre dot nunes at gmail dot com
  2009-03-24 18:34 ` ramana dot r at gmail dot com
@ 2009-04-20 15:38 ` ramana at gcc dot gnu dot org
  2009-10-26 11:38 ` ramana at gcc dot gnu dot org
  2009-12-14 23:35 ` rearnsha at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-04-20 15:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ramana at gcc dot gnu dot org  2009-04-20 15:38 -------
Confirmed with gcc version 4.5.0 20090416 (experimental) [trunk revision
146149] (GCC)


-- 

ramana at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ramana at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-04-20 15:38:42
               date|                            |


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


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

* [Bug target/38203] attribute `noreturn' isn't effective when -mthumb param is active
  2008-11-20 16:42 [Bug target/38203] New: attribute `noreturn' isn't effective when -mthumb param is active alexandre dot nunes at gmail dot com
                   ` (2 preceding siblings ...)
  2009-04-20 15:38 ` ramana at gcc dot gnu dot org
@ 2009-10-26 11:38 ` ramana at gcc dot gnu dot org
  2009-12-14 23:35 ` rearnsha at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-10-26 11:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ramana at gcc dot gnu dot org  2009-10-26 11:38 -------
Not working on this.


-- 

ramana at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|ramana at gcc dot gnu dot   |unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW


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


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

* [Bug target/38203] attribute `noreturn' isn't effective when -mthumb param is active
  2008-11-20 16:42 [Bug target/38203] New: attribute `noreturn' isn't effective when -mthumb param is active alexandre dot nunes at gmail dot com
                   ` (3 preceding siblings ...)
  2009-10-26 11:38 ` ramana at gcc dot gnu dot org
@ 2009-12-14 23:35 ` rearnsha at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2009-12-14 23:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rearnsha at gcc dot gnu dot org  2009-12-14 23:35 -------
There's a lot of debate about whether the ARM behaviour is a good thing or not.
 Not pushing the return address means that the debugger cannot generate a
back-trace in the event that the no-return function is something like abort();
however, we could avoid pushing most of the other registers.


-- 

rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement


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


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

* [Bug target/38203] attribute `noreturn' isn't effective when -mthumb param is active
       [not found] <bug-38203-4@http.gcc.gnu.org/bugzilla/>
@ 2011-02-28 20:57 ` alexandre.nunes at gmail dot com
  0 siblings, 0 replies; 7+ messages in thread
From: alexandre.nunes at gmail dot com @ 2011-02-28 20:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Alexandre Pereira Nunes <alexandre.nunes at gmail dot com> 2011-02-28 20:30:24 UTC ---
(In reply to comment #5)
> There's a lot of debate about whether the ARM behaviour is a good thing or not.
>  Not pushing the return address means that the debugger cannot generate a
> back-trace in the event that the no-return function is something like abort();
> however, we could avoid pushing most of the other registers.

In a hosted environment, the tradeoff is clear. On a more constrained one, it
would depend on whether or not debugging is an option and if not, there's just
wasted stack. -f(no)omit-frame-pointer could be respected by the port, imho.


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

end of thread, other threads:[~2011-02-28 20:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-20 16:42 [Bug target/38203] New: attribute `noreturn' isn't effective when -mthumb param is active alexandre dot nunes at gmail dot com
2008-11-20 16:53 ` [Bug target/38203] " alexandre dot nunes at gmail dot com
2009-03-24 18:34 ` ramana dot r at gmail dot com
2009-04-20 15:38 ` ramana at gcc dot gnu dot org
2009-10-26 11:38 ` ramana at gcc dot gnu dot org
2009-12-14 23:35 ` rearnsha at gcc dot gnu dot org
     [not found] <bug-38203-4@http.gcc.gnu.org/bugzilla/>
2011-02-28 20:57 ` alexandre.nunes at gmail dot com

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