Commit 4882e5ba by Richard Biener Committed by Prathamesh Kulkarni

re PR ipa/88788 (Infinite loop in malloc_candidate_p_1 since r264838)

2019-01-15  Richard Biener  <rguenther@suse.de>
	    Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	PR ipa/88788
	* ipa-pure-const.c (malloc_candidate_p_1): Add parameter visited and
	return true if SSA_NAME is already marked in visited bitmap.
	(malloc_candidate_p): Pass visited to malloc_candidate_p_1.

Co-Authored-By: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>

From-SVN: r267933
parent 079a6680
2019-01-15 Richard Biener <rguenther@suse.de>
Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR ipa/88788
* ipa-pure-const.c (malloc_candidate_p_1): Add parameter visited and
return true if SSA_NAME is already marked in visited bitmap.
(malloc_candidate_p): Pass visited to malloc_candidate_p_1.
2019-01-15 Jakub Jelinek <jakub@redhat.com> 2019-01-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/88775 PR tree-optimization/88775
......
...@@ -878,9 +878,12 @@ check_retval_uses (tree retval, gimple *stmt) ...@@ -878,9 +878,12 @@ check_retval_uses (tree retval, gimple *stmt)
} }
static bool static bool
malloc_candidate_p_1 (function *fun, tree retval, gimple *ret_stmt, bool ipa) malloc_candidate_p_1 (function *fun, tree retval, gimple *ret_stmt, bool ipa,
bitmap visited)
{ {
cgraph_node *node = cgraph_node::get_create (fun->decl); cgraph_node *node = cgraph_node::get_create (fun->decl);
if (!bitmap_set_bit (visited, SSA_NAME_VERSION (retval)))
return true;
if (!check_retval_uses (retval, ret_stmt)) if (!check_retval_uses (retval, ret_stmt))
DUMP_AND_RETURN("Return value has uses outside return stmt" DUMP_AND_RETURN("Return value has uses outside return stmt"
...@@ -925,7 +928,7 @@ malloc_candidate_p_1 (function *fun, tree retval, gimple *ret_stmt, bool ipa) ...@@ -925,7 +928,7 @@ malloc_candidate_p_1 (function *fun, tree retval, gimple *ret_stmt, bool ipa)
gimple *arg_def = SSA_NAME_DEF_STMT (arg); gimple *arg_def = SSA_NAME_DEF_STMT (arg);
if (is_a<gphi *> (arg_def)) if (is_a<gphi *> (arg_def))
{ {
if (!malloc_candidate_p_1 (fun, arg, phi, ipa)) if (!malloc_candidate_p_1 (fun, arg, phi, ipa, visited))
DUMP_AND_RETURN ("nested phi fail") DUMP_AND_RETURN ("nested phi fail")
continue; continue;
} }
...@@ -971,6 +974,7 @@ malloc_candidate_p (function *fun, bool ipa) ...@@ -971,6 +974,7 @@ malloc_candidate_p (function *fun, bool ipa)
|| !flag_delete_null_pointer_checks) || !flag_delete_null_pointer_checks)
return false; return false;
auto_bitmap visited;
FOR_EACH_EDGE (e, ei, exit_block->preds) FOR_EACH_EDGE (e, ei, exit_block->preds)
{ {
gimple_stmt_iterator gsi = gsi_last_bb (e->src); gimple_stmt_iterator gsi = gsi_last_bb (e->src);
...@@ -987,7 +991,7 @@ malloc_candidate_p (function *fun, bool ipa) ...@@ -987,7 +991,7 @@ malloc_candidate_p (function *fun, bool ipa)
|| TREE_CODE (TREE_TYPE (retval)) != POINTER_TYPE) || TREE_CODE (TREE_TYPE (retval)) != POINTER_TYPE)
DUMP_AND_RETURN("Return value is not SSA_NAME or not a pointer type.") DUMP_AND_RETURN("Return value is not SSA_NAME or not a pointer type.")
if (!malloc_candidate_p_1 (fun, retval, ret_stmt, ipa)) if (!malloc_candidate_p_1 (fun, retval, ret_stmt, ipa, visited))
return false; return false;
} }
......
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