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]

PATCH: PR debug/36977: Incorrect debug info for stack variables with stack alignment


On Wed, Jul 30, 2008 at 09:10:55AM -0700, H.J. Lu wrote:
> In expand_stack_alignment, we decide we need to relign stack to support
> big outgoing stack boundary.  Reload will make frame pointer available
> for stack alignment by eliminating it to stack pointer.  After reload,
> we realize that we don't need to relign stack after all, for example,
> callee doesn't need such a big incoming stack boundary, and we won't
> generate the stack alignment instruction.  But as far as reload and
> debug info are concerned, skipping the stack alignment instruction is a
> codegen optimization and shouldn't make any difference for reload and
> debug info. However, dwarf2out.c checks the stack alignment instruction
> to see if stack is realigned.  When the stack alignment instruction is
> omitted, based_loc_descr doesn't know it should use stack pointer + offset
> to access stack variables.  I am checking in this patch to add a
> stack_realign_tried field to rtl_data so that based_loc_descr can
> generate debug info for stack variables even if the stack alignment
> instruction is omitted.
> 
> Thanks.
> 
> 
> H.J.
> ----
> 2008-07-30  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	* cfgexpand.c (expand_stack_alignment): Set stack_realign_tried.
> 
> 	* dwarf2out.c (based_loc_descr): Check crtl->stack_realign_tried
> 	for stack alignment.
> 
> 	* function.h (rtl_data): Add stack_realign_tried.  Update
> 	comments.
> 

This is the same patch.  I opened a bug against trunk:

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

Tested on Linux/ia32, Linux/ia64 and Linux/Intel64.  OK for trunk?

Thanks.


H.J.
----
2008-07-30  H.J. Lu  <hongjiu.lu@intel.com>

	PR debug/36977
	* cfgexpand.c (expand_stack_alignment): Set stack_realign_tried.

	* dwarf2out.c (based_loc_descr): Check crtl->stack_realign_tried
	for stack alignment.

	* function.h (rtl_data): Add stack_realign_tried.  Update
	comments.

--- ../../../../gcc-stack/gcc/cfgexpand.c	2008-07-29 15:50:06.000000000 -0700
+++ cfgexpand.c	2008-07-29 17:16:03.000000000 -0700
@@ -2217,6 +2217,7 @@ expand_stack_alignment (void)
 
   crtl->stack_realign_needed
     = INCOMING_STACK_BOUNDARY < crtl->stack_alignment_estimated;
+  crtl->stack_realign_tried = crtl->stack_realign_needed;
 
   crtl->stack_realign_processed = true;
 
--- ../../../../gcc-stack/gcc/dwarf2out.c	2008-07-29 15:50:05.000000000 -0700
+++ dwarf2out.c	2008-07-30 08:47:22.000000000 -0700
@@ -9287,8 +9287,7 @@ based_loc_descr (rtx reg, HOST_WIDE_INT 
 	     pointer + offset to access stack variables.  If stack
 	     is aligned without drap, use stack pointer + offset to
 	     access stack variables.  */
-	  if (fde
-	      && fde->stack_realign
+	  if (crtl->stack_realign_tried
 	      && cfa.reg == HARD_FRAME_POINTER_REGNUM
 	      && reg == frame_pointer_rtx)
 	    {
--- ../../../../gcc-stack/gcc/function.h	2008-07-29 15:50:05.000000000 -0700
+++ function.h	2008-07-29 17:21:09.000000000 -0700
@@ -417,20 +417,25 @@ struct rtl_data GTY(())
   /* When set, expand should optimize for speed.  */
   bool maybe_hot_insn_p;
 
-  /* Nonzero if function stack realignment is needed. This flag may be
-     set twice: before and after reload. It is set before reload wrt
-     stack alignment estimation before reload. It will be changed after 
-     reload if by then criteria of stack realignment is different. 
+  /* Nonzero if function stack realignment is needed.  This flag may be
+     set twice: before and after reload.  It is set before reload wrt
+     stack alignment estimation before reload.  It will be changed after
+     reload if by then criteria of stack realignment is different.
      The value set after reload is the accurate one and is finalized.  */
   bool stack_realign_needed;
 
+  /* Nonzero if function stack realignment is tried.  This flag is set
+     only once before reload.  It affects register elimination.  This
+     is used to generate DWARF debug info for stack variables.  */
+  bool stack_realign_tried;
+
   /* Nonzero if function being compiled needs dynamic realigned
      argument pointer (drap) if stack needs realigning.  */
   bool need_drap;
 
   /* Nonzero if function stack realignment estimation is done, namely
-     stack_realign_needed flag has been set before reload wrt
-     estimated stack alignment info.  */
+     stack_realign_needed flag has been set before reload wrt estimated
+     stack alignment info.  */
   bool stack_realign_processed;
 
   /* Nonzero if function stack realignment has been finalized, namely


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