This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Disable optimization for volatile object
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 22 Apr 2009 21:30:20 +0200
- Subject: [PATCH] Disable optimization for volatile object
Hi,
gimplify_modify_expr_rhs can decide to directly propagate a constructor from
the DECL_INITIAL of the RHS of assignment to the LHS of the assignment. It
doesn't do it if the RHS is volatile but it shouldn't do it either if the LHS
is volatile as the assignment might end up being done on a per-field basis.
Tested on i586-suse-linux, OK for mainline?
2009-04-22 Eric Botcazou <ebotcazou@adacore.com>
* gimplify.c (gimplify_modify_expr_rhs) <VAR_DECL>: Do not do a direct
assignment from the constructor either if the target is volatile.
--
Eric Botcazou
Index: gimplify.c
===================================================================
--- gimplify.c (revision 146578)
+++ gimplify.c (working copy)
@@ -3982,11 +3982,14 @@ gimplify_modify_expr_rhs (tree *expr_p,
switch (TREE_CODE (*from_p))
{
case VAR_DECL:
- /* If we're assigning from a constant constructor, move the
- constructor expression to the RHS of the MODIFY_EXPR. */
+ /* If we're assigning from a read-only variable initialized with
+ a constructor, do the direct assignment from the constructor,
+ but only if neither source nor target are volatile since this
+ latter assignment might end up being done on a per-field basis. */
if (DECL_INITIAL (*from_p)
&& TREE_READONLY (*from_p)
&& !TREE_THIS_VOLATILE (*from_p)
+ && !TREE_THIS_VOLATILE (*to_p)
&& TREE_CODE (DECL_INITIAL (*from_p)) == CONSTRUCTOR)
{
tree old_from = *from_p;