This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions


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

             Bug #: 55747
           Summary: Extra registers are saved in functions that only call
                    noreturn functions
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: josh.m.conner@gmail.com


On architectures such as ARM, where a link register is used to save the return
address, this value does not need to be saved in a function that only calls
noreturn functions.

For example, if I build the following source:

  __attribute__((noreturn))
  extern void bar (void);

  int x;

  void foo (void)
  {
    if (x)
      bar ();
  }

Using the options "-O2", the link register is saved:

  stmfd   sp!, {r3, lr}
  ...
  ldmeqfd sp!, {r3, pc}

However, this is unnecessary since the only way the link register cannot be
corrupted since any calls to "bar" will not return.

Note that I am not filing this as an ARM target bug since the issue appears to
be a general problem related to dataflow analysis not tracking the difference
between calls to normal functions and calls to noreturn functions.  At any
rate, I see a similar problem in our custom target as well.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]