aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-08-23 07:23:19 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-08-23 07:23:19 +0000
commit1fd9f058f37ba4c17cd34e961fe4879e7dd7e3bc (patch)
tree78232f581677e4708f81fc0025d91b370e95ffea /gcc
parente83421c08ff730d683c4921c07cf7f327a6bab89 (diff)
downloadgcc-1fd9f058f37ba4c17cd34e961fe4879e7dd7e3bc.zip
gcc-1fd9f058f37ba4c17cd34e961fe4879e7dd7e3bc.tar.gz
gcc-1fd9f058f37ba4c17cd34e961fe4879e7dd7e3bc.tar.bz2
re PR middle-end/27336 (delete null checks in callers to nonnull functions)
2016-08-23 Richard Biener <rguenther@suse.de> PR tree-optimization/27336 * tree-vrp.c (infer_value_range): Handle stmts that can throw by looking for a non-EH edge. (process_assert_insertions_for): Likewise. * c-c++-common/pr27336.c: New testcase. From-SVN: r239684
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/pr27336.c12
-rw-r--r--gcc/tree-vrp.c11
4 files changed, 27 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 42fe573..13b4ad5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2016-08-23 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/27336
+ * tree-vrp.c (infer_value_range): Handle stmts that can throw
+ by looking for a non-EH edge.
+ (process_assert_insertions_for): Likewise.
+
+2016-08-23 Richard Biener <rguenther@suse.de>
+
PR middle-end/77305
* statistics.c (statistics_counter_event): Robustify against
NULL current_pass.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f25acf4..812c0c5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-23 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/27336
+ * c-c++-common/pr27336.c: New testcase.
+
2016-08-22 Marek Polacek <polacek@redhat.com>
PR c++/77321
diff --git a/gcc/testsuite/c-c++-common/pr27336.c b/gcc/testsuite/c-c++-common/pr27336.c
new file mode 100644
index 0000000..2978c6d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr27336.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+
+struct B { int x; };
+extern void g3(struct B *that) __attribute__((nonnull));
+int f3(struct B *a)
+{
+ g3(a);
+ return a != (void *)0;
+}
+
+/* { dg-final { scan-tree-dump "return 1;" "vrp1" } } */
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 86f2a8f..45882c4 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4782,11 +4782,6 @@ infer_value_range (gimple *stmt, tree op, tree_code *comp_code_p, tree *val_p)
if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op))
return false;
- /* Similarly, don't infer anything from statements that may throw
- exceptions. ??? Relax this requirement? */
- if (stmt_could_throw_p (stmt))
- return false;
-
/* If STMT is the last statement of a basic block with no normal
successors, there is no point inferring anything about any of its
operands. We would not be able to find a proper insertion point
@@ -4797,7 +4792,7 @@ infer_value_range (gimple *stmt, tree op, tree_code *comp_code_p, tree *val_p)
edge e;
FOR_EACH_EDGE (e, ei, gimple_bb (stmt)->succs)
- if (!(e->flags & EDGE_ABNORMAL))
+ if (!(e->flags & (EDGE_ABNORMAL|EDGE_EH)))
break;
if (e == NULL)
return false;
@@ -6370,10 +6365,10 @@ process_assert_insertions_for (tree name, assert_locus *loc)
/* If STMT must be the last statement in BB, we can only insert new
assertions on the non-abnormal edge out of BB. Note that since
- STMT is not control flow, there may only be one non-abnormal edge
+ STMT is not control flow, there may only be one non-abnormal/eh edge
out of BB. */
FOR_EACH_EDGE (e, ei, loc->bb->succs)
- if (!(e->flags & EDGE_ABNORMAL))
+ if (!(e->flags & (EDGE_ABNORMAL|EDGE_EH)))
{
gsi_insert_on_edge (e, assert_stmt);
return true;