diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2021-07-22 16:03:53 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-07-22 17:29:07 +0200 |
commit | 4048d8a08621820dd6cc6035e13de3c3c82af4a5 (patch) | |
tree | b8fcf105a222bef8503c43e2be5e69f4313767ef | |
parent | 3f7a2374d312112ea9a858dbbb883edf50730e96 (diff) | |
download | gcc-4048d8a08621820dd6cc6035e13de3c3c82af4a5.zip gcc-4048d8a08621820dd6cc6035e13de3c3c82af4a5.tar.gz gcc-4048d8a08621820dd6cc6035e13de3c3c82af4a5.tar.bz2 |
Allow non-null adjustments for pointers even when there is a known range.
Fix non_null_ref::adjust_range so it always adjust ranges, not just
varying ranges. This will allow pointers that have a range, but are not
necessarily non-null, to be adjusted.
gcc/ChangeLog:
* gimple-range-cache.cc (non_null_ref::adjust_range): Replace
varying_p check for null/non-null check.
-rw-r--r-- | gcc/gimple-range-cache.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 23597ad..265a64b 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -89,12 +89,17 @@ bool non_null_ref::adjust_range (irange &r, tree name, basic_block bb, bool search_dom) { - // Check if pointers have any non-null dereferences. Non-call - // exceptions mean we could throw in the middle of the block, so just - // punt for now on those. - if (!cfun->can_throw_non_call_exceptions - && r.varying_p () - && non_null_deref_p (name, bb, search_dom)) + // Non-call exceptions mean we could throw in the middle of the + // block, so just punt on those for now. + if (cfun->can_throw_non_call_exceptions) + return false; + + // We only care about the null / non-null property of pointers. + if (!POINTER_TYPE_P (TREE_TYPE (name)) || r.zero_p () || r.nonzero_p ()) + return false; + + // Check if pointers have any non-null dereferences. + if (non_null_deref_p (name, bb, search_dom)) { int_range<2> nz; nz.set_nonzero (TREE_TYPE (name)); |