+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>
PR tree-optimization/88775
}
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);
+ if (!bitmap_set_bit (visited, SSA_NAME_VERSION (retval)))
+ return true;
if (!check_retval_uses (retval, ret_stmt))
DUMP_AND_RETURN("Return value has uses outside return stmt"
gimple *arg_def = SSA_NAME_DEF_STMT (arg);
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")
continue;
}
|| !flag_delete_null_pointer_checks)
return false;
+ auto_bitmap visited;
FOR_EACH_EDGE (e, ei, exit_block->preds)
{
gimple_stmt_iterator gsi = gsi_last_bb (e->src);
|| TREE_CODE (TREE_TYPE (retval)) != 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;
}