This is the mail archive of the gcc-patches@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]

Committed: fix PR38609 by papering over a reload bug


(Made you look!)  See the PR.  To wit: a target should *never*
have to resort to
#define FRAME_POINTER_REQUIRED (!current_function_sp_is_unchanging)
 or the IMO less correct
#define FRAME_POINTER_REQUIRED (cfun->calls_alloca)
*unless* it has a weird way of implementing alloca which cannot
be optimized away e.g. as an initial stack-pointer adjustment.
(NB: I'm not arguing that it's a common thing worthwhile of
optimization.)

The target-independent parts of GCC are supposed to handle
whether this causes a frame-pointer to be required, AFAICT.  GCC
tries to do so in e.g. reload1.c:set_label_offsets.  The problem
is that all (code at) nonlocal-labels is assumed to have the
*initial* offsets between frame-pointer and stack-pointer (the
one just after the function prologue), which fails if there's
any alloca - even if the size is determinable to be constant and
it's executed at the top of the function.  The
gcc.c-torture/execute/built-in-setjmp.c test-case doesn't fail
on many targets, presumably because of reasons mentioned in the
cloned PR 39499 and common target cop-outs such as the one above
(forcing a frame-pointer).

Anyway, this target patch seemed more suitable at this stage
than arguing a reload patch (it wouldn't suffice to simply
change "1" to "initial_p" anyway for the particular recursive
call - you need to know every possible call site too).
Regtested cris-elf, committed to trunk.

gcc:
	PR middle-end/38609
	* config/cris/cris.h (FRAME_POINTER_REQUIRED): Force for all
	functions with dynamic stack-pointer adjustments.

Index: gcc/config/cris/cris.h
===================================================================
--- gcc/config/cris/cris.h	(revision 144947)
+++ gcc/config/cris/cris.h	(working copy)
@@ -851,8 +851,9 @@ enum reg_class
 /* Node: Elimination */
 
 /* Really only needed if the stack frame has variable length (alloca
-   or variable sized local arguments (GNU C extension).  */
-#define FRAME_POINTER_REQUIRED 0
+   or variable sized local arguments (GNU C extension).  See PR39499 and
+   PR38609 for the reason this isn't just 0.  */
+#define FRAME_POINTER_REQUIRED (!current_function_sp_is_unchanging)
 
 #define ELIMINABLE_REGS				\
  {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM},	\

brgds, H-P


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