public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/38534]  New: gcc 4.2.1 and above: No need to save called-saved registers in 'noreturn' function
@ 2008-12-15 19:00 thutt at vmware dot com
  2008-12-15 23:27 ` [Bug rtl-optimization/38534] " pinskia at gcc dot gnu dot org
  2008-12-16 14:05 ` thutt at vmware dot com
  0 siblings, 2 replies; 46+ messages in thread
From: thutt at vmware dot com @ 2008-12-15 19:00 UTC (permalink / raw)
  To: gcc-bugs

/* When a function has been defined using the 'noreturn' attribute,
 * there is no reason to save the callee-saved registers, mainly
 * because the function is not going to return to the caller.
 *
 * This can save a few bytes of code generation for embedded-type
 * applications which may use 'noreturn' functions to restart, for
 * example, by jumping to a different address rather than returning to
 * the caller.
 *
 * gcc information:
 *
 *     Using built-in specs.
 *     Target: x86_64-redhat-linux
 *
 *     Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
 *                      --infodir=/usr/share/info --enable-shared
 *                      --enable-threads=posix --enable-checking=release
 *                      --with-system-zlib --enable-__cxa_atexit
 *                      --disable-libunwind-exceptions
--enable-libgcj-multifile
 *                      --enable-languages=c,c++,objc,obj-c++,java,fortran,ada
 *                      --enable-java-awt=gtk --disable-dssi --enable-plugin
 *                     
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
 *                      --with-cpu=generic --host=x86_64-redhat-linux
 *     Thread model: posix
 *     gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)
 *
 * compilation & disassembly information:
 *
 *   gcc -c -O3 -o noreturn.o noreturn.c
 *   objdump --disassemble --reloc noreturn.o
 *
 *      Notice in the disassembly of 'return_to_caller' that the
 *      registers pushed in the preamble are restored before
 *      returning.  But, in the 'no_return_to_caller', they are not
 *      restored; since they are no restored, there is no reason to
 *      even save them.
 */
#include <stdlib.h>

extern unsigned array[1024][1024][1024];
extern unsigned value(int i, int j, int k);

#define LOOP_BODY                                               \
   do {                                                         \
      unsigned i, j, k;                                         \
      for (i = 1024; i > 0; --i) {                              \
         for (j = 1024; j > 0; --j) {                           \
            for (k = 1024; k > 0; --k) {                        \
               array[i - 1][j - 1][k - 1] = value(i, j, k);     \
            }                                                   \
         }                                                      \
      }                                                         \
   } while (0)

void
return_to_caller(int a, int b, int c, int d)
{
   LOOP_BODY;
}

void __attribute__((noreturn))
no_return_to_caller(int a, int b, int c, int d)
{
   LOOP_BODY;
   while (1);
}


-- 
           Summary: gcc 4.2.1 and above: No need to save called-saved
                    registers in 'noreturn' function
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thutt at vmware dot com


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


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

end of thread, other threads:[~2024-03-08  8:31 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-38534-4@http.gcc.gnu.org/bugzilla/>
2011-11-07  0:15 ` [Bug rtl-optimization/38534] gcc 4.2.1 and above: No need to save called-saved registers in 'noreturn' function js at alien8 dot de
2024-01-12 21:22 ` hjl.tools at gmail dot com
2024-01-13  6:05 ` sjames at gcc dot gnu.org
2024-01-14 12:05 ` lukas.graetz@tu-darmstadt.de
2024-01-14 12:08 ` lukas.graetz@tu-darmstadt.de
2024-01-14 14:12 ` hjl.tools at gmail dot com
2024-01-14 22:32 ` lukas.graetz@tu-darmstadt.de
2024-01-14 22:44 ` hjl.tools at gmail dot com
2024-01-14 22:54 ` lukas.graetz@tu-darmstadt.de
2024-01-15 10:22 ` lukas.graetz@tu-darmstadt.de
2024-01-15 10:49 ` lukas.graetz@tu-darmstadt.de
2024-01-15 12:23 ` lukas.graetz@tu-darmstadt.de
2024-01-27 12:19 ` cvs-commit at gcc dot gnu.org
2024-01-27 12:54 ` jakub at gcc dot gnu.org
2024-01-27 13:09 ` jakub at gcc dot gnu.org
2024-01-27 13:31 ` hjl.tools at gmail dot com
2024-01-27 13:45 ` jakub at gcc dot gnu.org
2024-01-27 13:47 ` jakub at gcc dot gnu.org
2024-01-27 15:05 ` aburgess at redhat dot com
2024-01-27 16:08 ` hjl.tools at gmail dot com
2024-01-27 20:42 ` hjl.tools at gmail dot com
2024-01-29 13:29 ` cvs-commit at gcc dot gnu.org
2024-02-01 12:23 ` lukas.graetz@tu-darmstadt.de
2024-02-01 12:43 ` jakub at gcc dot gnu.org
2024-02-01 14:40 ` lukas.graetz@tu-darmstadt.de
2024-02-27 10:18 ` jakub at gcc dot gnu.org
2024-02-27 12:17 ` lukas.graetz@tu-darmstadt.de
2024-02-27 12:32 ` jakub at gcc dot gnu.org
2024-02-27 13:07 ` lukas.graetz@tu-darmstadt.de
2024-02-27 13:17 ` jakub at gcc dot gnu.org
2024-02-27 13:38 ` lukas.graetz@tu-darmstadt.de
2024-02-27 14:03 ` jakub at gcc dot gnu.org
2024-02-27 14:39 ` jakub at gcc dot gnu.org
2024-02-27 17:00 ` lukas.graetz@tu-darmstadt.de
2024-02-27 17:10 ` jakub at gcc dot gnu.org
2024-02-27 18:15 ` lukas.graetz@tu-darmstadt.de
2024-02-27 23:54 ` tromey at gcc dot gnu.org
2024-02-28  8:09 ` lukas.graetz@tu-darmstadt.de
2024-02-28  8:15 ` jakub at gcc dot gnu.org
2024-02-28  9:43 ` lukas.graetz@tu-darmstadt.de
2024-02-28 13:31 ` lukas.graetz@tu-darmstadt.de
2024-02-29 17:56 ` lukas.graetz@tu-darmstadt.de
2024-02-29 20:12 ` lukas.graetz@tu-darmstadt.de
2024-03-08  8:30 ` cvs-commit at gcc dot gnu.org
2008-12-15 19:00 [Bug c/38534] New: " thutt at vmware dot com
2008-12-15 23:27 ` [Bug rtl-optimization/38534] " pinskia at gcc dot gnu dot org
2008-12-16 14:05 ` thutt at vmware 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).