aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-range-cache.cc35
-rw-r--r--gcc/gimple-range-cache.h2
-rw-r--r--gcc/gimple-range.cc8
3 files changed, 30 insertions, 15 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 98ecdbb..23597ad 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -81,6 +81,29 @@ non_null_ref::non_null_deref_p (tree name, basic_block bb, bool search_dom)
return false;
}
+// If NAME has a non-null dereference in block BB, adjust R with the
+// non-zero information from non_null_deref_p, and return TRUE. If
+// SEARCH_DOM is true, non_null_deref_p should search the dominator tree.
+
+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))
+ {
+ int_range<2> nz;
+ nz.set_nonzero (TREE_TYPE (name));
+ r.intersect (nz);
+ return true;
+ }
+ return false;
+}
+
// Allocate an populate the bitmap for NAME. An ON bit for a block
// index indicates there is a non-null reference in that block. In
// order to populate the bitmap, a quick run of all the immediate uses
@@ -857,9 +880,8 @@ ranger_cache::range_of_def (irange &r, tree name, basic_block bb)
r = gimple_range_global (name);
}
- if (bb && r.varying_p () && m_non_null.non_null_deref_p (name, bb, false) &&
- !cfun->can_throw_non_call_exceptions)
- r = range_nonzero (TREE_TYPE (name));
+ if (bb)
+ m_non_null.adjust_range (r, name, bb, false);
}
// Get the range of NAME as it occurs on entry to block BB.
@@ -878,12 +900,7 @@ ranger_cache::entry_range (irange &r, tree name, basic_block bb)
if (!m_on_entry.get_bb_range (r, name, bb))
range_of_def (r, name);
- // 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 (r.varying_p () && m_non_null.non_null_deref_p (name, bb, false) &&
- !cfun->can_throw_non_call_exceptions)
- r = range_nonzero (TREE_TYPE (name));
+ m_non_null.adjust_range (r, name, bb, false);
}
// Get the range of NAME as it occurs on exit from block BB.
diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h
index ecf63dc..f842e9c 100644
--- a/gcc/gimple-range-cache.h
+++ b/gcc/gimple-range-cache.h
@@ -34,6 +34,8 @@ public:
non_null_ref ();
~non_null_ref ();
bool non_null_deref_p (tree name, basic_block bb, bool search_dom = true);
+ bool adjust_range (irange &r, tree name, basic_block bb,
+ bool search_dom = true);
private:
vec <bitmap> m_nn;
void process_name (tree name);
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 1851339..b210787 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -69,9 +69,7 @@ gimple_ranger::range_of_expr (irange &r, tree expr, gimple *stmt)
if (def_stmt && gimple_bb (def_stmt) == bb)
{
range_of_stmt (r, def_stmt, expr);
- if (!cfun->can_throw_non_call_exceptions && r.varying_p () &&
- m_cache.m_non_null.non_null_deref_p (expr, bb))
- r = range_nonzero (TREE_TYPE (expr));
+ m_cache.m_non_null.adjust_range (r, expr, bb, true);
}
else
// Otherwise OP comes from outside this block, use range on entry.
@@ -95,9 +93,7 @@ gimple_ranger::range_on_entry (irange &r, basic_block bb, tree name)
if (m_cache.block_range (entry_range, bb, name))
r.intersect (entry_range);
- if (!cfun->can_throw_non_call_exceptions && r.varying_p () &&
- m_cache.m_non_null.non_null_deref_p (name, bb))
- r = range_nonzero (TREE_TYPE (name));
+ m_cache.m_non_null.adjust_range (r, name, bb, true);
}
// Calculate the range for NAME at the end of block BB and return it in R.