Commit edcdea5b by Nathan Froyd Committed by Nathan Froyd

gimple.h (gimple_asm_clobbers_memory_p): Declare.

	* gimple.h (gimple_asm_clobbers_memory_p): Declare.
	* gimple.c (gimple_asm_clobbers_memory_p): Define.
	* ipa-pure-const.c (check_stmt): Call it.
	* tree-ssa-operands.c (get_asm_expr_operands): Likewise.

From-SVN: r172496
parent 0f141046
2011-04-15 Nathan Froyd <froydnj@codesourcery.com>
* gimple.h (gimple_asm_clobbers_memory_p): Declare.
* gimple.c (gimple_asm_clobbers_memory_p): Define.
* ipa-pure-const.c (check_stmt): Call it.
* tree-ssa-operands.c (get_asm_expr_operands): Likewise.
2011-04-15 Richard Guenther <rguenther@suse.de> 2011-04-15 Richard Guenther <rguenther@suse.de>
PR tree-optimization/48290 PR tree-optimization/48290
......
...@@ -5142,4 +5142,21 @@ gimple_call_builtin_p (gimple stmt, enum built_in_function code) ...@@ -5142,4 +5142,21 @@ gimple_call_builtin_p (gimple stmt, enum built_in_function code)
&& DECL_FUNCTION_CODE (fndecl) == code); && DECL_FUNCTION_CODE (fndecl) == code);
} }
/* Return true if STMT clobbers memory. STMT is required to be a
GIMPLE_ASM. */
bool
gimple_asm_clobbers_memory_p (const_gimple stmt)
{
unsigned i;
for (i = 0; i < gimple_asm_nclobbers (stmt); i++)
{
tree op = gimple_asm_clobber_op (stmt, i);
if (strcmp (TREE_STRING_POINTER (TREE_VALUE (op)), "memory") == 0)
return true;
}
return false;
}
#include "gt-gimple.h" #include "gt-gimple.h"
...@@ -973,6 +973,7 @@ extern bool walk_stmt_load_store_ops (gimple, void *, ...@@ -973,6 +973,7 @@ extern bool walk_stmt_load_store_ops (gimple, void *,
bool (*)(gimple, tree, void *)); bool (*)(gimple, tree, void *));
extern bool gimple_ior_addresses_taken (bitmap, gimple); extern bool gimple_ior_addresses_taken (bitmap, gimple);
extern bool gimple_call_builtin_p (gimple, enum built_in_function); extern bool gimple_call_builtin_p (gimple, enum built_in_function);
extern bool gimple_asm_clobbers_memory_p (const_gimple);
/* In gimplify.c */ /* In gimplify.c */
extern tree create_tmp_var_raw (tree, const char *); extern tree create_tmp_var_raw (tree, const char *);
......
...@@ -639,7 +639,6 @@ static void ...@@ -639,7 +639,6 @@ static void
check_stmt (gimple_stmt_iterator *gsip, funct_state local, bool ipa) check_stmt (gimple_stmt_iterator *gsip, funct_state local, bool ipa)
{ {
gimple stmt = gsi_stmt (*gsip); gimple stmt = gsi_stmt (*gsip);
unsigned int i = 0;
if (is_gimple_debug (stmt)) if (is_gimple_debug (stmt))
return; return;
...@@ -693,16 +692,12 @@ check_stmt (gimple_stmt_iterator *gsip, funct_state local, bool ipa) ...@@ -693,16 +692,12 @@ check_stmt (gimple_stmt_iterator *gsip, funct_state local, bool ipa)
} }
break; break;
case GIMPLE_ASM: case GIMPLE_ASM:
for (i = 0; i < gimple_asm_nclobbers (stmt); i++) if (gimple_asm_clobbers_memory_p (stmt))
{ {
tree op = gimple_asm_clobber_op (stmt, i); if (dump_file)
if (strcmp (TREE_STRING_POINTER (TREE_VALUE (op)), "memory") == 0) fprintf (dump_file, " memory asm clobber is not const/pure");
{ /* Abandon all hope, ye who enter here. */
if (dump_file) local->pure_const_state = IPA_NEITHER;
fprintf (dump_file, " memory asm clobber is not const/pure");
/* Abandon all hope, ye who enter here. */
local->pure_const_state = IPA_NEITHER;
}
} }
if (gimple_asm_volatile_p (stmt)) if (gimple_asm_volatile_p (stmt))
{ {
......
...@@ -832,15 +832,8 @@ get_asm_expr_operands (gimple stmt) ...@@ -832,15 +832,8 @@ get_asm_expr_operands (gimple stmt)
} }
/* Clobber all memory and addressable symbols for asm ("" : : : "memory"); */ /* Clobber all memory and addressable symbols for asm ("" : : : "memory"); */
for (i = 0; i < gimple_asm_nclobbers (stmt); i++) if (gimple_asm_clobbers_memory_p (stmt))
{ add_virtual_operand (stmt, opf_def);
tree link = gimple_asm_clobber_op (stmt, i);
if (strcmp (TREE_STRING_POINTER (TREE_VALUE (link)), "memory") == 0)
{
add_virtual_operand (stmt, opf_def);
break;
}
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment