On 01/24/14 03:52, Jakub Jelinek wrote:
I'd say this belongs into infer_value_range instead.
Here we go with that variant: OK for the trunk? jeff
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2998c72..3b1abbc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-01-23 Jeff Law <l...@redhat.com> + + PR tree-optimization/59919 + * tree-vrp.c (find_assert_locations_1): Do not register asserts + for non-returning calls. + 2014-01-23 Pat Haugen <pthau...@us.ibm.com> * config/rs6000/rs6000.c (rs6000_option_override_internal): Don't diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 564d425..0d05178 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-01-23 Jeff Law <l...@redhat.com> + + PR tree-optimization/59919 + * gcc.c-torture/compile/pr59919.c: New test. + 2014-01-23 Paolo Carlini <paolo.carl...@oracle.com> PR c++/58980 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr59919.c b/gcc/testsuite/gcc.c-torture/compile/pr59919.c new file mode 100644 index 0000000..6809caa --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr59919.c @@ -0,0 +1,18 @@ +typedef int jmp_buf[10]; +struct S +{ + int i; + jmp_buf buf; +}; + +void setjmp (jmp_buf); +void foo (int *); +__attribute__ ((__noreturn__, __nonnull__)) void bar (struct S *); + +void +baz (struct S *p) +{ + bar (p); + setjmp (p->buf); + foo (&p->i); +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index f6da192..7aa732d 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4534,12 +4534,21 @@ infer_value_range (gimple stmt, tree op, enum tree_code *comp_code_p, tree *val_ if (stmt_could_throw_p (stmt)) return false; - /* If STMT is the last statement of a basic block with no + /* 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 for the assertion, anyway. */ - if (stmt_ends_bb_p (stmt) && EDGE_COUNT (gimple_bb (stmt)->succs) == 0) - return false; + if (stmt_ends_bb_p (stmt)) + { + edge_iterator ei; + edge e; + + FOR_EACH_EDGE (e, ei, gimple_bb (stmt)->succs) + if (!(e->flags & EDGE_ABNORMAL)) + break; + if (e == NULL) + return false; + } if (infer_nonnull_range (stmt, op, true, true)) {