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]

[trunk][patch] gimplify type sizes in a pointer type


My previous idea of changing the C++ FE to create a temp var to avoid
having a SAVE_EXPR on a type turned out to be hard to implement in the
case of new being used in static initialization. The middle end
complains about a non static variable being used :-(

I decide to try to find out why the gimplifier avoids recursing into
pointer types, but I couldn't. Adding the recursion solves the problem
on the lto branch and introduces no problems on trunk. I have
bootstrapped gcc and there is no regression on the tests.

I assume that the case it was getting to uninitialized types no longer
exists (that code is from 2006).

Is the attached patch OK for trunk?

2008-06-11  Rafael Espindola  <espindola@google.com>

	* gimplify.c (gimplify_target_expr): Always gimplify the type of INIT.
	(gimplify_type_sizes): Recurse on pointer types.


Cheers,
-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 47a2fe7..3fb69ea 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4622,14 +4622,13 @@ gimplify_target_expr (tree *expr_p, tree *pre_p, tree *post_p)
 
   if (init)
     {
+      if (!TYPE_SIZES_GIMPLIFIED (TREE_TYPE (temp)))
+	gimplify_type_sizes (TREE_TYPE (temp), pre_p);
+
       /* TARGET_EXPR temps aren't part of the enclosing block, so add it
 	 to the temps list.  Handle also variable length TARGET_EXPRs.  */
       if (TREE_CODE (DECL_SIZE (temp)) != INTEGER_CST)
-	{
-	  if (!TYPE_SIZES_GIMPLIFIED (TREE_TYPE (temp)))
-	    gimplify_type_sizes (TREE_TYPE (temp), pre_p);
-	  gimplify_vla_decl (temp, pre_p);
-	}
+	gimplify_vla_decl (temp, pre_p);
       else
 	gimple_add_tmp_var (temp);
 
@@ -6548,18 +6547,7 @@ gimplify_type_sizes (tree type, tree *list_p)
 
     case POINTER_TYPE:
     case REFERENCE_TYPE:
-	/* We used to recurse on the pointed-to type here, which turned out to
-	   be incorrect because its definition might refer to variables not
-	   yet initialized at this point if a forward declaration is involved.
-
-	   It was actually useful for anonymous pointed-to types to ensure
-	   that the sizes evaluation dominates every possible later use of the
-	   values.  Restricting to such types here would be safe since there
-	   is no possible forward declaration around, but would introduce an
-	   undesirable middle-end semantic to anonymity.  We then defer to
-	   front-ends the responsibility of ensuring that the sizes are
-	   evaluated both early and late enough, e.g. by attaching artificial
-	   type declarations to the tree.  */
+      gimplify_type_sizes (TREE_TYPE (type), list_p);
       break;
 
     default:

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