public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Remove expand_expr_stmt
@ 2012-07-14 17:35 Steven Bosscher
  2012-07-16  9:27 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Bosscher @ 2012-07-14 17:35 UTC (permalink / raw)
  To: GCC Patches

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

Hello,

This patch removes expand_expr_stmt and inlines+folds it into its only user.

This relies on TARGET_STACK_PROTECT_FAIL being a CALL_EXPR. The
documentation only says "a tree expression that (...) should involve a
call to a @code{noreturn} function". I've changed this to explicitly
state that the hook must return a CALL_EXPR.

Bootstrapped and tested on powerpc64-unknown-linux-gnu.
OK for trunk?

Ciao!
Steven


        * function.c (stack_protect_epilogue): Use expand_call to expand
        targetm.stack_protect_fail.
        * stmt.c (expand_expr_stmt): Remove now-unused function.
        * tree.h (expand_expr_stmt): Remove prototype.
        * doc/tm.texi.in (TARGET_STACK_PROTECT_FAIL): Document that this
        hook must return a CALL_EXPR.
        * doc/tm.texi: Regenerate.

[-- Attachment #2: remove_expand_expr_stmt.diff --]
[-- Type: application/octet-stream, Size: 3469 bytes --]

	* function.c (stack_protect_epilogue): Use expand_call to expand
	targetm.stack_protect_fail.
	* stmt.c (expand_expr_stmt): Remove now-unused function.
	* tree.h (expand_expr_stmt): Remove prototype.
	* doc/tm.texi.in (TARGET_STACK_PROTECT_FAIL): Document that this
	hook must return a CALL_EXPR.
	* doc/tm.texi: Regenerate.

Index: function.c
===================================================================
--- function.c	(revision 189478)
+++ function.c	(working copy)
@@ -4661,7 +4661,8 @@ stack_protect_epilogue (void)
   if (JUMP_P (tmp))
     predict_insn_def (tmp, PRED_NORETURN, TAKEN);
 
-  expand_expr_stmt (targetm.stack_protect_fail ());
+  expand_call (targetm.stack_protect_fail (), NULL_RTX, /*ignore=*/true);
+  free_temp_slots ();
   emit_label (label);
 }
 \f
Index: stmt.c
===================================================================
--- stmt.c	(revision 189478)
+++ stmt.c	(working copy)
@@ -1399,42 +1399,6 @@ resolve_operand_name_1 (char *p, tree outputs, tre
   return p;
 }
 \f
-/* Generate RTL to evaluate the expression EXP.  */
-
-void
-expand_expr_stmt (tree exp)
-{
-  rtx value;
-  tree type;
-
-  value = expand_expr (exp, const0_rtx, VOIDmode, EXPAND_NORMAL);
-  type = TREE_TYPE (exp);
-
-  /* If all we do is reference a volatile value in memory,
-     copy it to a register to be sure it is actually touched.  */
-  if (value && MEM_P (value) && TREE_THIS_VOLATILE (exp))
-    {
-      if (TYPE_MODE (type) == VOIDmode)
-	;
-      else if (TYPE_MODE (type) != BLKmode)
-	copy_to_reg (value);
-      else
-	{
-	  rtx lab = gen_label_rtx ();
-
-	  /* Compare the value with itself to reference it.  */
-	  emit_cmp_and_jump_insns (value, value, EQ,
-				   expand_normal (TYPE_SIZE (type)),
-				   BLKmode, 0, lab);
-	  emit_label (lab);
-	}
-    }
-
-  /* Free any temporaries used to evaluate this expression.  */
-  free_temp_slots ();
-}
-
-\f
 /* Generate RTL to return from the current function, with no value.
    (That is, we do not do anything about returning any value.)  */
 
Index: tree.h
===================================================================
--- tree.h	(revision 189478)
+++ tree.h	(working copy)
@@ -5206,7 +5206,6 @@ extern tree unshare_expr (tree);
 \f
 /* In stmt.c */
 
-extern void expand_expr_stmt (tree);
 extern void expand_label (tree);
 extern void expand_goto (tree);
 
Index: doc/tm.texi.in
===================================================================
--- doc/tm.texi.in	(revision 189478)
+++ doc/tm.texi.in	(working copy)
@@ -4934,7 +4934,7 @@ The default version of this hook creates a variabl
 @end deftypefn
 
 @hook TARGET_STACK_PROTECT_FAIL
-This hook returns a tree expression that alerts the runtime that the
+This hook returns a @code{CALL_EXPR} that alerts the runtime that the
 stack protect guard variable has been modified.  This expression should
 involve a call to a @code{noreturn} function.
 
Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 189478)
+++ doc/tm.texi	(working copy)
@@ -4993,7 +4993,7 @@ The default version of this hook creates a variabl
 @end deftypefn
 
 @deftypefn {Target Hook} tree TARGET_STACK_PROTECT_FAIL (void)
-This hook returns a tree expression that alerts the runtime that the
+This hook returns a @code{CALL_EXPR} that alerts the runtime that the
 stack protect guard variable has been modified.  This expression should
 involve a call to a @code{noreturn} function.
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Remove expand_expr_stmt
  2012-07-14 17:35 [patch] Remove expand_expr_stmt Steven Bosscher
@ 2012-07-16  9:27 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2012-07-16  9:27 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: GCC Patches

On Sat, Jul 14, 2012 at 7:34 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> This patch removes expand_expr_stmt and inlines+folds it into its only user.
>
> This relies on TARGET_STACK_PROTECT_FAIL being a CALL_EXPR. The
> documentation only says "a tree expression that (...) should involve a
> call to a @code{noreturn} function". I've changed this to explicitly
> state that the hook must return a CALL_EXPR.
>
> Bootstrapped and tested on powerpc64-unknown-linux-gnu.
> OK for trunk?

Ok.

Thanks,
Richard.

> Ciao!
> Steven
>
>
>         * function.c (stack_protect_epilogue): Use expand_call to expand
>         targetm.stack_protect_fail.
>         * stmt.c (expand_expr_stmt): Remove now-unused function.
>         * tree.h (expand_expr_stmt): Remove prototype.
>         * doc/tm.texi.in (TARGET_STACK_PROTECT_FAIL): Document that this
>         hook must return a CALL_EXPR.
>         * doc/tm.texi: Regenerate.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-16  9:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-14 17:35 [patch] Remove expand_expr_stmt Steven Bosscher
2012-07-16  9:27 ` Richard Guenther

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).