This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFA] Improvements to infer_nonnull_range


On 10/28/13 23:02, Jeff Law wrote:

Based on a suggestion from Marc, I want to use infer_nonnull_range in
the erroneous path isolation optimization.

In the process of doing that, I found  a few deficiencies in
infer_nonnull_range that need to be addressed.


First, infer_nonnull_range_p doesn't infer ranges from a GIMPLE_RETURN
if the current function is marked as returns_nonnull.  That's fixed in
the relatively obvious way.

Second, infer_nonnull_range_p, when presented with an arglist where the
non-null attribute applies to all pointer arguments, it won't bother to
determine if OP is actually one of the arguments :(  It just assumes
that OP is in the argument list.  Opps.

Third, I want to be able to call infer_nonnull_range with OP being 0B.
That lets me use infer_nonnull_range to look for explicit null pointer
dereferences, explicit uses of null in a return statement in functions
that can't return non-null and explicit uses of null arguments when
those arguments can't be null.   Sadly, to make that work we need to use
operand_equal_p rather than simple pointer comparisons to see if OP
shows up in STMT.

Finally, for detecting explicit null pointers, infer_nonnull_range calls
count_ptr_derefs.  count_ptr_derefs counts things in two ways.  One with
a FOR_EACH_SSA_TREE_OPERAND, then again with simple walks of the tree
structures.   Not surprisingly if we're looking for an explicit 0B, then
the loop over the operands finds nothing, but walking the tree
structures does. And the checking assert triggers.  This change removes
the assert and instead sets *num_uses_p to a sane value.

I don't have testcases for this stuff that are independent of the
erroneous path isolation optimization.  However, each is triggered by
tests I'll include in the the erroneous path isolation patch.

Bootstrapped and regression tested on x86_64-unknown-linux-gnu.  OK for
the trunk?
I'm withdrawing this patch. While everything works exactly how I wanted, I think it's best to rework things a bit and totally eliminate count_ptr_derefs entirely.

That change makes it significantly easier to move infer_nonnull_range out of tree-vrp.c and into gimple.c (or wherever Andrew wants it) without a significant modularity break.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]