re PR c++/52582 (g++ ICE when compiling qt-4.8.0 with -O2 on PPC (32bit))

2012-03-14  Richard Guenther  <rguenther@suse.de>

	PR middle-end/52582
	* gimple-fold.c (canonicalize_constructor_val): Make sure
	we have a cgraph node for a FUNCTION_DECL that comes from
	a constructor.
	(gimple_get_virt_method_for_binfo): Likewise.

From-SVN: r185381
This commit is contained in:
Richard Guenther 2012-03-14 13:01:46 +00:00 committed by Richard Biener
parent c205d0b3f5
commit 7501ca28e3
2 changed files with 25 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2012-03-14 Richard Guenther <rguenther@suse.de>
PR middle-end/52582
* gimple-fold.c (canonicalize_constructor_val): Make sure
we have a cgraph node for a FUNCTION_DECL that comes from
a constructor.
(gimple_get_virt_method_for_binfo): Likewise.
2012-03-14 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52571

View File

@ -131,18 +131,26 @@ canonicalize_constructor_val (tree cval)
if (TREE_CODE (cval) == ADDR_EXPR)
{
tree base = get_base_address (TREE_OPERAND (cval, 0));
if (!base)
return NULL_TREE;
if (base
&& (TREE_CODE (base) == VAR_DECL
|| TREE_CODE (base) == FUNCTION_DECL)
if ((TREE_CODE (base) == VAR_DECL
|| TREE_CODE (base) == FUNCTION_DECL)
&& !can_refer_decl_in_current_unit_p (base))
return NULL_TREE;
if (base && TREE_CODE (base) == VAR_DECL)
if (TREE_CODE (base) == VAR_DECL)
{
TREE_ADDRESSABLE (base) = 1;
if (cfun && gimple_referenced_vars (cfun))
add_referenced_var (base);
}
else if (TREE_CODE (base) == FUNCTION_DECL)
{
/* Make sure we create a cgraph node for functions we'll reference.
They can be non-existent if the reference comes from an entry
of an external vtable for example. */
cgraph_get_create_node (base);
}
/* 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));
@ -3115,6 +3123,11 @@ gimple_get_virt_method_for_binfo (HOST_WIDE_INT token, tree known_binfo)
if (!can_refer_decl_in_current_unit_p (fn))
return NULL_TREE;
/* Make sure we create a cgraph node for functions we'll reference.
They can be non-existent if the reference comes from an entry
of an external vtable for example. */
cgraph_get_create_node (fn);
return fn;
}