aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>2018-05-18 12:31:04 +0000
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>2018-05-18 12:31:04 +0000
commitbec3ee81e3c60bc4e8001871ede2b0b07ff417f1 (patch)
tree3b5a9fcb699e42d0db04126b33ecc6cd67e594fd /gcc
parentb55fbca39ee2568d007ce835f7684f3d2ec2e986 (diff)
downloadgcc-bec3ee81e3c60bc4e8001871ede2b0b07ff417f1.zip
gcc-bec3ee81e3c60bc4e8001871ede2b0b07ff417f1.tar.gz
gcc-bec3ee81e3c60bc4e8001871ede2b0b07ff417f1.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-pure-const.c70
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr83648.c2
4 files changed, 50 insertions, 34 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4795777..479b032 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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>
* gimple-ssa-evrp.c (class evrp_folder): Add simplify_stmt_using_ranges
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 567b615..528ea66 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -940,9 +940,6 @@ malloc_candidate_p (function *fun, bool ipa)
if (!retval)
DUMP_AND_RETURN("No return value.")
- if (integer_zerop (retval))
- continue;
-
if (TREE_CODE (retval) != SSA_NAME
|| TREE_CODE (TREE_TYPE (retval)) != 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))
- for (unsigned i = 0; i < gimple_phi_num_args (phi); ++i)
- {
- tree arg = gimple_phi_arg_def (phi, i);
- if (integer_zerop (arg))
- continue;
+ {
+ bool all_args_zero = true;
+ for (unsigned i = 0; i < gimple_phi_num_args (phi); ++i)
+ {
+ 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)
- 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 (all_args_zero)
+ DUMP_AND_RETURN ("Return value is a phi with all args equal to 0.");
+ }
else
DUMP_AND_RETURN("def_stmt of return value is not a call or phi-stmt.")
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 185ce2f..cbd2266 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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>
* gcc.dg/tree-ssa/pr21559.c: Adjust.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr83648.c b/gcc/testsuite/gcc.dg/tree-ssa/pr83648.c
index febfd7d..884faf8 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr83648.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr83648.c
@@ -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: h" "local-pure-const1" } } */
+/* { dg-final { scan-tree-dump-not "Function found to be malloc: h" "local-pure-const1" } } */