Commit bec3ee81 by Prathamesh Kulkarni Committed by Prathamesh Kulkarni

re PR middle-end/85817 (ICE in expand_call at gcc/calls.c:4291)

2018-05-18  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	PR middle-end/85817
	* ipa-pure-const.c (malloc_candidate_p): Remove the check integer_zerop
	for retval and return false if all args to phi are zero.	

testsuite/
	* gcc.dg/tree-ssa/pr83648.c: Change scan-tree-dump to
	scan-tree-dump-not for h.

From-SVN: r260358
parent b55fbca3
2018-05-18 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR middle-end/85817
* ipa-pure-const.c (malloc_candidate_p): Remove the check integer_zerop
for retval and return false if all args to phi are zero.
2018-05-18 Richard Biener <rguenther@suse.de> 2018-05-18 Richard Biener <rguenther@suse.de>
* gimple-ssa-evrp.c (class evrp_folder): Add simplify_stmt_using_ranges * gimple-ssa-evrp.c (class evrp_folder): Add simplify_stmt_using_ranges
......
...@@ -940,9 +940,6 @@ malloc_candidate_p (function *fun, bool ipa) ...@@ -940,9 +940,6 @@ malloc_candidate_p (function *fun, bool ipa)
if (!retval) if (!retval)
DUMP_AND_RETURN("No return value.") DUMP_AND_RETURN("No return value.")
if (integer_zerop (retval))
continue;
if (TREE_CODE (retval) != SSA_NAME if (TREE_CODE (retval) != SSA_NAME
|| 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.")
...@@ -972,37 +969,44 @@ malloc_candidate_p (function *fun, bool ipa) ...@@ -972,37 +969,44 @@ malloc_candidate_p (function *fun, bool ipa)
} }
else if (gphi *phi = dyn_cast<gphi *> (def)) else if (gphi *phi = dyn_cast<gphi *> (def))
for (unsigned i = 0; i < gimple_phi_num_args (phi); ++i) {
{ bool all_args_zero = true;
tree arg = gimple_phi_arg_def (phi, i); for (unsigned i = 0; i < gimple_phi_num_args (phi); ++i)
if (integer_zerop (arg)) {
continue; tree arg = gimple_phi_arg_def (phi, i);
if (integer_zerop (arg))
continue;
all_args_zero = false;
if (TREE_CODE (arg) != SSA_NAME)
DUMP_AND_RETURN ("phi arg is not SSA_NAME.");
if (!check_retval_uses (arg, phi))
DUMP_AND_RETURN ("phi arg has uses outside phi"
" and comparisons against 0.")
gimple *arg_def = SSA_NAME_DEF_STMT (arg);
gcall *call_stmt = dyn_cast<gcall *> (arg_def);
if (!call_stmt)
return false;
tree callee_decl = gimple_call_fndecl (call_stmt);
if (!callee_decl)
return false;
if (!ipa && !DECL_IS_MALLOC (callee_decl))
DUMP_AND_RETURN("callee_decl does not have malloc attribute"
" for non-ipa mode.")
cgraph_edge *cs = node->get_edge (call_stmt);
if (cs)
{
ipa_call_summary *es = ipa_call_summaries->get (cs);
gcc_assert (es);
es->is_return_callee_uncaptured = true;
}
}
if (TREE_CODE (arg) != SSA_NAME) if (all_args_zero)
DUMP_AND_RETURN ("phi arg is not SSA_NAME."); DUMP_AND_RETURN ("Return value is a phi with all args equal to 0.");
if (!check_retval_uses (arg, phi)) }
DUMP_AND_RETURN ("phi arg has uses outside phi"
" and comparisons against 0.")
gimple *arg_def = SSA_NAME_DEF_STMT (arg);
gcall *call_stmt = dyn_cast<gcall *> (arg_def);
if (!call_stmt)
return false;
tree callee_decl = gimple_call_fndecl (call_stmt);
if (!callee_decl)
return false;
if (!ipa && !DECL_IS_MALLOC (callee_decl))
DUMP_AND_RETURN("callee_decl does not have malloc attribute for"
" non-ipa mode.")
cgraph_edge *cs = node->get_edge (call_stmt);
if (cs)
{
ipa_call_summary *es = ipa_call_summaries->get (cs);
gcc_assert (es);
es->is_return_callee_uncaptured = true;
}
}
else else
DUMP_AND_RETURN("def_stmt of return value is not a call or phi-stmt.") DUMP_AND_RETURN("def_stmt of return value is not a call or phi-stmt.")
......
2018-05-18 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR middle-end/85817
* gcc.dg/tree-ssa/pr83648.c: Change scan-tree-dump to
scan-tree-dump-not for h.
2018-05-18 Richard Biener <rguenther@suse.de> 2018-05-18 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/pr21559.c: Adjust. * gcc.dg/tree-ssa/pr21559.c: Adjust.
......
...@@ -12,4 +12,4 @@ void *h() ...@@ -12,4 +12,4 @@ void *h()
} }
/* { dg-final { scan-tree-dump "Function found to be malloc: g" "local-pure-const1" } } */ /* { dg-final { scan-tree-dump "Function found to be malloc: g" "local-pure-const1" } } */
/* { dg-final { scan-tree-dump "Function found to be malloc: h" "local-pure-const1" } } */ /* { dg-final { scan-tree-dump-not "Function found to be malloc: h" "local-pure-const1" } } */
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