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
This commit is contained in:
Prathamesh Kulkarni 2018-05-18 12:31:04 +00:00 committed by Prathamesh Kulkarni
parent b55fbca39e
commit bec3ee81e3
4 changed files with 48 additions and 32 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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)
} }
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;
if (TREE_CODE (arg) != SSA_NAME) all_args_zero = false;
DUMP_AND_RETURN ("phi arg is not SSA_NAME."); if (TREE_CODE (arg) != SSA_NAME)
if (!check_retval_uses (arg, phi)) DUMP_AND_RETURN ("phi arg is not SSA_NAME.");
DUMP_AND_RETURN ("phi arg has uses outside phi" if (!check_retval_uses (arg, phi))
" and comparisons against 0.") DUMP_AND_RETURN ("phi arg has uses outside phi"
" and comparisons against 0.")
gimple *arg_def = SSA_NAME_DEF_STMT (arg); gimple *arg_def = SSA_NAME_DEF_STMT (arg);
gcall *call_stmt = dyn_cast<gcall *> (arg_def); gcall *call_stmt = dyn_cast<gcall *> (arg_def);
if (!call_stmt) if (!call_stmt)
return false; return false;
tree callee_decl = gimple_call_fndecl (call_stmt); tree callee_decl = gimple_call_fndecl (call_stmt);
if (!callee_decl) if (!callee_decl)
return false; return false;
if (!ipa && !DECL_IS_MALLOC (callee_decl)) if (!ipa && !DECL_IS_MALLOC (callee_decl))
DUMP_AND_RETURN("callee_decl does not have malloc attribute for" DUMP_AND_RETURN("callee_decl does not have malloc attribute"
" non-ipa mode.") " for non-ipa mode.")
cgraph_edge *cs = node->get_edge (call_stmt); cgraph_edge *cs = node->get_edge (call_stmt);
if (cs) if (cs)
{ {
ipa_call_summary *es = ipa_call_summaries->get (cs); ipa_call_summary *es = ipa_call_summaries->get (cs);
gcc_assert (es); gcc_assert (es);
es->is_return_callee_uncaptured = true; es->is_return_callee_uncaptured = true;
} }
} }
if (all_args_zero)
DUMP_AND_RETURN ("Return value is a phi with all args equal to 0.");
}
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.")

View File

@ -1,3 +1,9 @@
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.

View File

@ -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" } } */