* gimplify.c (gimplify_var_or_parm_decl): Split out from ...
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Oct 2005 05:08:26 +0000 (05:08 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Oct 2005 05:08:26 +0000 (05:08 +0000)
        (gimplify_expr): ... here.
        (gimplify_compound_lval): Use it in initial scan loop.  Allow
        fb_lvalue in base expression.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105458 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimplify.c

index 23ccab6..9384f17 100644 (file)
@@ -1,5 +1,12 @@
 2005-10-15  Richard Henderson  <rth@redhat.com>
 
+       * gimplify.c (gimplify_var_or_parm_decl): Split out from ...
+       (gimplify_expr): ... here.
+       (gimplify_compound_lval): Use it in initial scan loop.  Allow
+       fb_lvalue in base expression.
+
+2005-10-15  Richard Henderson  <rth@redhat.com>
+
        PR 23714
        * builtins.c (expand_builtin_trap): Export.
        * expr.h (expand_builtin_trap): Declare.
 2005-10-06  Daniel Berlin  <dberlin@dberlin.org>
        
        * tree-ssa-structalias.c (check_for_overlaps): Fix bug in last
-        change.
+       change.
 
 2005-10-06  Richard Henderson  <rth@redhat.com>
 
 2005-09-23  Fariborz Jahanian <fjahanian@apple.com>
 
        PR target/23847
-        * config/rs6000/rs6000.c (rs6000_function_value): Parallel pattern
-        for __complex__ double in -mcpu=G5 mode.
+       * config/rs6000/rs6000.c (rs6000_function_value): Parallel pattern
+       for __complex__ double in -mcpu=G5 mode.
 
 2005-09-26  Sebastian Pop  <pop@cri.ensmp.fr>
 
 
 2005-09-26    Fariborz Jahanian <fjahanian@apple.com>
 
-        * combine.c (make_extraction): Check for valid use of subreg.
+       * combine.c (make_extraction): Check for valid use of subreg.
 
 2005-09-26  Uros Bizjak  <uros@kss-loka.si>
 
 
 2005-09-22  David Edelsohn  <edelsohn@gnu.org>
 
-        PR target/24007
-        * config/rs6000/rs6000.md (movsf_hardfloat): Ignore special
-        registers when choosing register preferences.
-        (movdf_hardfloat64): Same.
+       PR target/24007
+       * config/rs6000/rs6000.md (movsf_hardfloat): Ignore special
+       registers when choosing register preferences.
+       (movdf_hardfloat64): Same.
 
 2005-09-22  Andreas Krebbel  <krebbel1@de.ibm.com>
 
index 52012eb..b7d891e 100644 (file)
@@ -1468,6 +1468,40 @@ gimplify_conversion (tree *expr_p)
   return GS_OK;
 }
 
+/* Gimplify a VAR_DECL or PARM_DECL.  Returns GS_OK if we expanded a 
+   DECL_VALUE_EXPR, and it's worth re-examining things.  */
+
+static enum gimplify_status
+gimplify_var_or_parm_decl (tree *expr_p)
+{
+  tree decl = *expr_p;
+
+  /* ??? If this is a local variable, and it has not been seen in any
+     outer BIND_EXPR, then it's probably the result of a duplicate
+     declaration, for which we've already issued an error.  It would
+     be really nice if the front end wouldn't leak these at all.
+     Currently the only known culprit is C++ destructors, as seen
+     in g++.old-deja/g++.jason/binding.C.  */
+  if (TREE_CODE (decl) == VAR_DECL
+      && !DECL_SEEN_IN_BIND_EXPR_P (decl)
+      && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl)
+      && decl_function_context (decl) == current_function_decl)
+    {
+      gcc_assert (errorcount || sorrycount);
+      return GS_ERROR;
+    }
+
+  /* If the decl is an alias for another expression, substitute it now.  */
+  if (DECL_HAS_VALUE_EXPR_P (decl))
+    {
+      *expr_p = unshare_expr (DECL_VALUE_EXPR (decl));
+      return GS_OK;
+    }
+
+  return GS_ALL_DONE;
+}
+
+
 /* Gimplify the COMPONENT_REF, ARRAY_REF, REALPART_EXPR or IMAGPART_EXPR
    node pointed to by EXPR_P.
 
@@ -1506,11 +1540,21 @@ gimplify_compound_lval (tree *expr_p, tree *pre_p,
   /* We can handle anything that get_inner_reference can deal with.  */
   for (p = expr_p; ; p = &TREE_OPERAND (*p, 0))
     {
+    restart:
       /* Fold INDIRECT_REFs now to turn them into ARRAY_REFs.  */
       if (TREE_CODE (*p) == INDIRECT_REF)
        *p = fold_indirect_ref (*p);
-      if (!handled_component_p (*p))
+
+      if (handled_component_p (*p))
+       ;
+      /* Expand DECL_VALUE_EXPR now.  In some cases that may expose
+        additional COMPONENT_REFs.  */
+      else if ((TREE_CODE (*p) == VAR_DECL || TREE_CODE (*p) == PARM_DECL)
+              && gimplify_var_or_parm_decl (p) == GS_OK)
+       goto restart;
+      else
        break;
+              
       VEC_safe_push (tree, heap, stack, *p);
     }
 
@@ -1592,8 +1636,11 @@ gimplify_compound_lval (tree *expr_p, tree *pre_p,
        }
     }
 
-  /* Step 2 is to gimplify the base expression.  */
-  tret = gimplify_expr (p, pre_p, post_p, is_gimple_min_lval, fallback);
+  /* Step 2 is to gimplify the base expression.  Make sure lvalue is set
+     so as to match the min_lval predicate.  Failure to do so may result
+     in the creation of large aggregate temporaries.  */
+  tret = gimplify_expr (p, pre_p, post_p, is_gimple_min_lval,
+                       fallback | fb_lvalue);
   ret = MIN (ret, tret);
 
   /* And finally, the indices and operands to BIT_FIELD_REF.  During this
@@ -4371,36 +4418,8 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
          break;
 
        case VAR_DECL:
-         /* ??? If this is a local variable, and it has not been seen in any
-            outer BIND_EXPR, then it's probably the result of a duplicate
-            declaration, for which we've already issued an error.  It would
-            be really nice if the front end wouldn't leak these at all.
-            Currently the only known culprit is C++ destructors, as seen
-            in g++.old-deja/g++.jason/binding.C.  */
-         tmp = *expr_p;
-         if (!TREE_STATIC (tmp) && !DECL_EXTERNAL (tmp)
-             && decl_function_context (tmp) == current_function_decl
-             && !DECL_SEEN_IN_BIND_EXPR_P (tmp))
-           {
-             gcc_assert (errorcount || sorrycount);
-             ret = GS_ERROR;
-             break;
-           }
-         /* FALLTHRU */
-
        case PARM_DECL:
-         tmp = *expr_p;
-
-         /* If this is a local variable sized decl, it must be accessed
-            indirectly.  Perform that substitution.  */
-         if (DECL_HAS_VALUE_EXPR_P (tmp))
-           {
-             *expr_p = unshare_expr (DECL_VALUE_EXPR (tmp));
-             ret = GS_OK;
-             break;
-           }
-
-         ret = GS_ALL_DONE;
+         ret = gimplify_var_or_parm_decl (expr_p);
          break;
 
        case SSA_NAME: