aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2011-04-03 11:13:09 +0000
committerMichael Matz <matz@gcc.gnu.org>2011-04-03 11:13:09 +0000
commit0038d4e09077594de90e1b1a53e5ff8e76cd735d (patch)
treecffddfa016b791b26c7af434581e9984b8129eea /gcc
parent91f2fae8cc58e1b1dae3b62e2407903190ed1af4 (diff)
downloadgcc-0038d4e09077594de90e1b1a53e5ff8e76cd735d.zip
gcc-0038d4e09077594de90e1b1a53e5ff8e76cd735d.tar.gz
gcc-0038d4e09077594de90e1b1a53e5ff8e76cd735d.tar.bz2
cgraphbuild.c (record_reference): Canonicalize constructor values.
* 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/cgraphbuild.c6
-rw-r--r--gcc/cgraphunit.c5
-rw-r--r--gcc/gimple-fold.c7
4 files changed, 23 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 801e52b..a4b56f2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
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
default priority.
(decl_fini_priority_insert): Ditto.
diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index 6b8116a..3948cf6 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -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:
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index c397fe5..93d5c06 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -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. */
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 367e40e..f1eb98e 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -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));
}