[Bug middle-end/27336] delete null checks in callers to nonnull functions
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Aug 22 09:41:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27336
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
This is because of
static bool
infer_value_range (gimple *stmt, tree op, tree_code *comp_code_p, tree *val_p)
{
*val_p = NULL_TREE;
*comp_code_p = ERROR_MARK;
/* Do not attempt to infer anything in names that flow through
abnormal edges. */
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;
thus it works with -fno-exceptions. I think we can insert an assertion
anyway (on the non-EH edge). Or at least relax the above to
stmt_could_throw_internal_p (stmt). The following works for me.
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c (revision 239653)
+++ gcc/tree-vrp.c (working copy)
@@ -4782,11 +4760,6 @@ infer_value_range (gimple *stmt, tree op
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 +4770,7 @@ infer_value_range (gimple *stmt, tree op
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 +6343,10 @@ process_assert_insertions_for (tree name
/* 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;
More information about the Gcc-bugs
mailing list