gimple-fold.c (maybe_fold_reference): When canonicalizing MEM_REFs, preserve volatileness.

2010-11-22  Richard Guenther  <rguenther@suse.de>

	* gimple-fold.c (maybe_fold_reference): When canonicalizing
	MEM_REFs, preserve volatileness.
	* cgraphbuild.c (mark_address): Properly check for FUNCTION_DECL
	addresses.

From-SVN: r167030
This commit is contained in:
Richard Guenther 2010-11-22 13:18:48 +00:00 committed by Richard Biener
parent 993466f3d1
commit e961597133
3 changed files with 23 additions and 19 deletions

View File

@ -1,3 +1,10 @@
2010-11-22 Richard Guenther <rguenther@suse.de>
* gimple-fold.c (maybe_fold_reference): When canonicalizing
MEM_REFs, preserve volatileness.
* cgraphbuild.c (mark_address): Properly check for FUNCTION_DECL
addresses.
2010-11-22 Richard Guenther <rguenther@suse.de>
* tree-ssa-ccp.c (get_base_constructor): Remove superfluous breaks.

View File

@ -237,6 +237,7 @@ static bool
mark_address (gimple stmt ATTRIBUTE_UNUSED, tree addr,
void *data ATTRIBUTE_UNUSED)
{
addr = get_base_address (addr);
if (TREE_CODE (addr) == FUNCTION_DECL)
{
struct cgraph_node *node = cgraph_node (addr);
@ -245,24 +246,20 @@ mark_address (gimple stmt ATTRIBUTE_UNUSED, tree addr,
node, NULL,
IPA_REF_ADDR, stmt);
}
else
else if (addr && TREE_CODE (addr) == VAR_DECL
&& (TREE_STATIC (addr) || DECL_EXTERNAL (addr)))
{
addr = get_base_address (addr);
if (addr && TREE_CODE (addr) == VAR_DECL
&& (TREE_STATIC (addr) || DECL_EXTERNAL (addr)))
{
struct varpool_node *vnode = varpool_node (addr);
int walk_subtrees;
struct varpool_node *vnode = varpool_node (addr);
int walk_subtrees;
if (lang_hooks.callgraph.analyze_expr)
lang_hooks.callgraph.analyze_expr (&addr, &walk_subtrees);
varpool_mark_needed_node (vnode);
if (vnode->alias && vnode->extra_name)
vnode = vnode->extra_name;
ipa_record_reference ((struct cgraph_node *)data, NULL,
NULL, vnode,
IPA_REF_ADDR, stmt);
}
if (lang_hooks.callgraph.analyze_expr)
lang_hooks.callgraph.analyze_expr (&addr, &walk_subtrees);
varpool_mark_needed_node (vnode);
if (vnode->alias && vnode->extra_name)
vnode = vnode->extra_name;
ipa_record_reference ((struct cgraph_node *)data, NULL,
NULL, vnode,
IPA_REF_ADDR, stmt);
}
return false;

View File

@ -600,15 +600,15 @@ maybe_fold_reference (tree expr, bool is_lhs)
}
/* Canonicalize MEM_REFs invariant address operand. */
else if (TREE_CODE (*t) == MEM_REF
&& TREE_CODE (TREE_OPERAND (*t, 0)) == ADDR_EXPR
&& !DECL_P (TREE_OPERAND (TREE_OPERAND (*t, 0), 0))
&& !CONSTANT_CLASS_P (TREE_OPERAND (TREE_OPERAND (*t, 0), 0)))
&& !is_gimple_mem_ref_addr (TREE_OPERAND (*t, 0)))
{
bool volatile_p = TREE_THIS_VOLATILE (*t);
tree tem = fold_binary (MEM_REF, TREE_TYPE (*t),
TREE_OPERAND (*t, 0),
TREE_OPERAND (*t, 1));
if (tem)
{
TREE_THIS_VOLATILE (tem) = volatile_p;
*t = tem;
tem = maybe_fold_reference (expr, is_lhs);
if (tem)