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]

PATCH: Fix PR2907



This patch fixes a bug in the new EH code.  The problem was that we
were emitting stack adjustments in code that could be reached along
multiple paths, and so the stack adjustments were only valid for some
of the paths, with the result that we ended up moving the stack
pointer around wrongly.

Without -fomit-frame-pointer this problem was somewhat masked in that
we always fixed up the stack pointer on the way out of the frame by
restoring it from the frame pointer.  So, we tended not to get bitten.
But, with -fomit-frame-pointer we ended up in a state of total chaos.

I'm pretty sure this fix is correct, and there should be no
correctness issues with calling do_pending_stack_adjust more often
(only possible loss of performance) -- but I'd still appreciate
another pair of eyes on the patch.

Bootstrapped and tested on i686-pc-linux-gnu, installed on the
mainline and on the branch.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-06-08  Mark Mitchell  <mark@codesourcery.com>

	* except.c (expand_eh_region_end_allowed): Call
	do_pending_stack_adjust as necessary.

Index: except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/except.c,v
retrieving revision 1.143.2.11
diff -c -p -r1.143.2.11 except.c
*** except.c	2001/05/20 00:31:41	1.143.2.11
--- except.c	2001/06/08 16:01:17
*************** expand_eh_region_end_allowed (allowed, f
*** 857,867 ****
--- 857,875 ----
       throws a different exception, that it will be processed by the
       correct region.  */
  
+   /* If there are any pending stack adjustments, we must emit them
+      before we branch -- otherwise, we won't know how much adjustment
+      is required later.  */
+   do_pending_stack_adjust ();
    around_label = gen_label_rtx ();
    emit_jump (around_label);
  
    emit_label (region->label);
    expand_expr (failure, const0_rtx, VOIDmode, EXPAND_NORMAL);
+   /* We must adjust the stack before we reach the AROUND_LABEL because
+      the call to FAILURE does not occur on all paths to the
+      AROUND_LABEL.  */
+   do_pending_stack_adjust ();
  
    emit_label (around_label);
  }


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