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 to build1 for c/12553


We were setting TREE_SIDE_EFFECTS on the address of a volatile variable,
which is wrong, and confused tree-ssa.  Fixed thus.  The separate if (node)
format is to allow for easier merging of a patch of rth's to set
TREE_CONSTANT properly as well.

Tested x86_64-pc-linux-gnu, applied to trunk.  Test in gcc.dg/volatile1.c.

2003-10-20  Jason Merrill  <jason@redhat.com>

	PR c/12553
	* tree.c (build1) <ADDR_EXPR>: Set TREE_SIDE_EFFECTS
	appropriately.

*** tree.c.~1~	2003-10-15 14:47:08.000000000 -0400
--- tree.c	2003-10-20 17:19:01.000000000 -0400
*************** build1 (enum tree_code code, tree type, 
*** 2466,2471 ****
--- 2473,2501 ----
        TREE_READONLY (t) = 0;
        break;
  
+     case ADDR_EXPR:
+       if (node)
+ 	{
+ 	  /* The address of a volatile decl or reference does not have
+ 	     side-effects.  But be careful not to ignore side-effects from
+ 	     other sources deeper in the expression--if node is a _REF and
+ 	     one of its operands has side-effects, so do we.  */
+ 	  if (TREE_THIS_VOLATILE (node))
+ 	    {
+ 	      TREE_SIDE_EFFECTS (t) = 0;
+ 	      if (!DECL_P (node))
+ 		{
+ 		  int i = first_rtl_op (TREE_CODE (node));
+ 		  for (; i >= 0; --i)
+ 		    {
+ 		      if (TREE_SIDE_EFFECTS (TREE_OPERAND (node, i)))
+ 			TREE_SIDE_EFFECTS (t) = 1;
+ 		    }
+ 		}
+ 	    }
+ 	}
+       break;
+ 
      default:
        if (TREE_CODE_CLASS (code) == '1' && node && TREE_CONSTANT (node))
  	TREE_CONSTANT (t) = 1;

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