cgraphbuild.c (record_reference): Canonicalize constructor values.
authorMichael Matz <matz@suse.de>
Sun, 3 Apr 2011 11:13:09 +0000 (11:13 +0000)
committerMichael Matz <matz@gcc.gnu.org>
Sun, 3 Apr 2011 11:13:09 +0000 (11:13 +0000)
* cgraphbuild.c (record_reference): Canonicalize constructor
values.
* gimple-fold.c (canonicalize_constructor_val): Accept being called
without function context.
* cgraphunit.c (cgraph_finalize_compilation_unit): Clear
current_function_decl and cfun.

From-SVN: r171903

gcc/ChangeLog
gcc/cgraphbuild.c
gcc/cgraphunit.c
gcc/gimple-fold.c

index 801e52bd227c4d7e51627a20cd31f13247dce95f..a4b56f2400ca753d5a9ea87b486b77da45a19f55 100644 (file)
@@ -1,3 +1,12 @@
+2011-04-03  Michael Matz  <matz@suse.de>
+
+       * cgraphbuild.c (record_reference): Canonicalize constructor
+       values.
+       * gimple-fold.c (canonicalize_constructor_val): Accept being called
+       without function context.
+       * cgraphunit.c (cgraph_finalize_compilation_unit): Clear
+       current_function_decl and cfun.
+
 2011-04-03  Michael Matz  <matz@suse.de>
 
        * tree.c (decl_init_priority_insert): Don't create entry for
index 6b8116a612a53bc1de2c2c8625a890f3705d6707..3948cf628024e875a8c56a0e3b843293b0644a79 100644 (file)
@@ -53,6 +53,12 @@ record_reference (tree *tp, int *walk_subtrees, void *data)
   tree decl;
   struct record_reference_ctx *ctx = (struct record_reference_ctx *)data;
 
+  t = canonicalize_constructor_val (t);
+  if (!t)
+    t = *tp;
+  else if (t != *tp)
+    *tp = t;
+
   switch (TREE_CODE (t))
     {
     case VAR_DECL:
index c397fe53f6c8a0eff480b007e3d556e8fa655bef..93d5c06ce97ae4e923b862977e9360e9272ac035 100644 (file)
@@ -1066,6 +1066,11 @@ cgraph_finalize_compilation_unit (void)
 {
   timevar_push (TV_CGRAPH);
 
+  /* If we're here there's no current function anymore.  Some frontends
+     are lazy in clearing these.  */
+  current_function_decl = NULL;
+  set_cfun (NULL);
+
   /* Do not skip analyzing the functions if there were errors, we
      miss diagnostics for following functions otherwise.  */
 
index 367e40e30295a696dd872c09ef77d8d0b27b4cb5..f1eb98e329ffe8d247f86c92e92c8728218f28e4 100644 (file)
@@ -106,7 +106,7 @@ can_refer_decl_in_current_unit_p (tree decl)
   return true;
 }
 
-/* CVAL is value taken from DECL_INITIAL of variable.  Try to transorm it into
+/* CVAL is value taken from DECL_INITIAL of variable.  Try to transform it into
    acceptable form for is_gimple_min_invariant.   */
 
 tree
@@ -131,10 +131,9 @@ canonicalize_constructor_val (tree cval)
              || TREE_CODE (base) == FUNCTION_DECL)
          && !can_refer_decl_in_current_unit_p (base))
        return NULL_TREE;
-      if (base && TREE_CODE (base) == VAR_DECL)
+      if (cfun && base && TREE_CODE (base) == VAR_DECL)
        add_referenced_var (base);
-      /* We never have the chance to fixup types in global initializers
-         during gimplification.  Do so here.  */
+      /* Fixup types in global initializers.  */
       if (TREE_TYPE (TREE_TYPE (cval)) != TREE_TYPE (TREE_OPERAND (cval, 0)))
        cval = build_fold_addr_expr (TREE_OPERAND (cval, 0));
     }