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]

Re: Expansion of __builtin_frame_address


Sorry, I just mistakenly sent this to gcc@ (where it was being
discussed) instead of gcc-patches@.

Mark

--

Mark Mitchell wrote:
Mark Shinwell wrote:
As for the remaining problem, I suggest that we could:

(i) always return the hard frame pointer, and disable FP elimination in
the current function; or

(iii) ...the same as option (i), but allow targets to define another macro
that will cause the default code to use the soft frame pointer rather than
the hard frame pointer, and hence allow FP elimination.  (If such a macro
were set by a particular target, am I right in thinking that it would be
safe to use the soft frame pointer even in the count >= 1 cases?)

I tend to think that option (iii) might be best, although perhaps it
is overkill and option (i) would do.  But I'm not entirely sure;
still being a gcc novice I have to admit to not being quite thoroughly
clear on this myself at this stage.  So any advice or comments would be
appreciated!

I agree that option (iii) is best, as it provides the ability to optimize on platforms where that is feasible, and still provides a working default elsewhere. I will review and approve a suitable patch to implement (iii), assuming that there are no objections from Jim or others.

This having been discussed some more, and my understanding improved, I now believe that option (i) is in fact the correct thing to do. The attach patch implements this, which basically amounts to the same logic that is currently in the compiler save for the removal of the special case when count == 0.

OK for mainline?

Mark

--

2006-06-01 Mark Shinwell <shinwell@codesourcery.com>

	* gcc/builtins.c (expand_builtin_return_addr): Always use
	hard_frame_pointer_rtx and prevent frame pointer elimination
	if INITIAL_FRAME_ADDRESS_RTX isn't set.

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 114277)
+++ gcc/builtins.c	(working copy)
@@ -496,20 +496,14 @@ expand_builtin_return_addr (enum built_i
 #else
   rtx tem;
 
-  /* For a zero count, we don't care what frame address we return, so frame
-     pointer elimination is OK, and using the soft frame pointer is OK.
-     For a non-zero count, we require a stable offset from the current frame
-     pointer to the previous one, so we must use the hard frame pointer, and
-     we must disable frame pointer elimination.  */
-  if (count == 0)
-    tem = frame_pointer_rtx;
-  else 
-    {
-      tem = hard_frame_pointer_rtx;
+  /* We require a stable offset from the current frame pointer to the
+     previous one, so we must use the hard frame pointer, and we must
+     disable frame pointer elimination.  */
 
-      /* Tell reload not to eliminate the frame pointer.  */
-      current_function_accesses_prior_frames = 1;
-    }
+  tem = hard_frame_pointer_rtx;
+
+  /* Tell reload not to eliminate the frame pointer.  */
+  current_function_accesses_prior_frames = 1;
 #endif
 
   /* Some machines need special handling before we can access


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