public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@libertysurf.fr>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix PR middle-end/17813
Date: Mon, 18 Oct 2004 22:11:00 -0000	[thread overview]
Message-ID: <200410182356.24785.ebotcazou@libertysurf.fr> (raw)
In-Reply-To: <200410162252.58887.ebotcazou@libertysurf.fr>

[-- Attachment #1: Type: text/plain, Size: 928 bytes --]

> This is the Ada compiler bootstrap failure on i586 and below, which again
> pertains to stack adjustments.  cstand.adb:Create_Standard is miscompiled
> because a stack adjustment is emitted right after a
> __builtin_stack_restore.

Here's the final patch I commited to mainline.  Bootstrapped/regtested (all 
languages except treelang with upcoming patch for PR middle-end/18045) on 
i486-mandrake-linux-gnu, approved offline by Roger.


2004-10-18  Eric Botcazou  <ebotcazou@libertysurf.fr>
              Roger Sayle  <roger@eyesopen.com>

	PR middle-end/17813
	* dojump.c (discard_pending_stack_adjust): New function.
	(clear_pending_stack_adjust): Call it.
	* expr.h (discard_pending_stack_adjust): Declare it.
	* explow.c (emit_stack_save): Emit pending stack adjustments
	before saving the stack pointer.
	(emit_stack_restore): Discard pending stack adjustments before
	restoring the stack pointer.


-- 
Eric Botcazou

[-- Attachment #2: pr17813-2.diff --]
[-- Type: text/x-diff, Size: 2799 bytes --]

Index: dojump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dojump.c,v
retrieving revision 1.29
diff -u -p -r1.29 dojump.c
--- dojump.c	8 Sep 2004 07:47:45 -0000	1.29
+++ dojump.c	18 Oct 2004 18:48:23 -0000
@@ -50,6 +50,15 @@ init_pending_stack_adjust (void)
   pending_stack_adjust = 0;
 }
 
+/* Discard any pending stack adjustment.  This avoid relying on the
+   RTL optimizers to remove useless adjustments when we know the
+   stack pointer value is dead.  */
+void discard_pending_stack_adjust (void)
+{
+  stack_pointer_delta -= pending_stack_adjust;
+  pending_stack_adjust = 0;
+}
+
 /* When exiting from function, if safe, clear out any pending stack adjust
    so the adjustment won't get done.
 
@@ -64,10 +73,7 @@ clear_pending_stack_adjust (void)
       && EXIT_IGNORE_STACK
       && ! (DECL_INLINE (current_function_decl) && ! flag_no_inline)
       && ! flag_inline_functions)
-    {
-      stack_pointer_delta -= pending_stack_adjust,
-      pending_stack_adjust = 0;
-    }
+    discard_pending_stack_adjust ();
 }
 
 /* Pop any previously-pushed arguments that have not been popped yet.  */
Index: explow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/explow.c,v
retrieving revision 1.139
diff -u -p -r1.139 explow.c
--- explow.c	8 Sep 2004 08:05:13 -0000	1.139
+++ explow.c	18 Oct 2004 18:48:33 -0000
@@ -965,6 +965,7 @@ emit_stack_save (enum save_level save_le
       rtx seq;
 
       start_sequence ();
+      do_pending_stack_adjust ();
       /* We must validize inside the sequence, to ensure that any instructions
 	 created by the validize call also get moved to the right place.  */
       if (sa != 0)
@@ -976,6 +977,7 @@ emit_stack_save (enum save_level save_le
     }
   else
     {
+      do_pending_stack_adjust ();
       if (sa != 0)
 	sa = validize_mem (sa);
       emit_insn (fcn (sa, stack_pointer_rtx));
@@ -1032,6 +1034,8 @@ emit_stack_restore (enum save_level save
 		    gen_rtx_MEM (BLKmode, stack_pointer_rtx)));
     }
 
+  discard_pending_stack_adjust ();
+
   if (after)
     {
       rtx seq;
Index: expr.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.h,v
retrieving revision 1.171
diff -u -p -r1.171 expr.h
--- expr.h	8 Sep 2004 18:44:56 -0000	1.171
+++ expr.h	18 Oct 2004 18:48:36 -0000
@@ -499,6 +499,9 @@ extern void expand_var (tree);
    arguments waiting to be popped.  */
 extern void init_pending_stack_adjust (void);
 
+/* Discard any pending stack adjustment.  */
+extern void discard_pending_stack_adjust (void);
+
 /* When exiting from function, if safe, clear out any pending stack adjust
    so the adjustment won't get done.  */
 extern void clear_pending_stack_adjust (void);

  parent reply	other threads:[~2004-10-18 22:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-16 21:22 Eric Botcazou
2004-10-17  1:28 ` Roger Sayle
2004-10-17  2:20   ` Jan Hubicka
2004-10-17 13:51   ` Eric Botcazou
2004-10-17 17:07     ` Roger Sayle
2004-10-17  9:58 ` Matthias Klose
2004-10-17 11:55   ` Eric Botcazou
2004-10-17 12:03     ` Matthias Klose
2004-10-17 17:57       ` Eric Botcazou
2004-10-17 19:40         ` Daniel Jacobowitz
2004-10-18 15:44           ` Eric Botcazou
2004-10-18 15:44             ` Arnaud Charlet
2004-10-18 16:30               ` Eric Botcazou
2004-10-18 12:16   ` Eric Botcazou
2004-10-18 22:11 ` Eric Botcazou [this message]
2004-10-17 18:48 Richard Kenner
2004-10-18  8:22 ` Eric Botcazou
2004-10-18 14:56 Richard Kenner
2004-10-18 16:03 ` Eric Botcazou
2004-10-18 17:18 Richard Kenner
2004-10-18 20:56 ` Eric Botcazou
2004-10-18 21:17   ` Laurent GUERBY
2004-10-18 21:04 Richard Kenner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200410182356.24785.ebotcazou@libertysurf.fr \
    --to=ebotcazou@libertysurf.fr \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).