diff options
author | Kugan Vivekanandarajah <kuganv@linaro.org> | 2016-10-17 23:35:48 +0000 |
---|---|---|
committer | Kugan Vivekanandarajah <kugan@gcc.gnu.org> | 2016-10-17 23:35:48 +0000 |
commit | 735b8f9fc4b14384b246b39dfccbf529402b7791 (patch) | |
tree | 79b96808abe9a9f3a2571e69510e046068caad46 /gcc/tree-ssanames.c | |
parent | 86f980870a28bc9022cc57362b5031ede43ecff9 (diff) |
Set nonnull attribute to ptr_info_def based on VRP
Set nonnull attribute to ptr_info_def based on VRP
gcc/ChangeLog:
2016-10-18 Kugan Vivekanandarajah <kuganv@linaro.org>
* tree-ssa-alias.h (pt_solution_singleton_or_null_p): Renamed from
pt_solution_singleton_p.
* tree-ssa-ccp.c (fold_builtin_alloca_with_align): Use renamed
pt_solution_singleton_or_null_p from pt_solution_singleton_p.
* tree-ssa-structalias.c (find_what_p_points_to): Preserve
pointer nonnull computed by VRP.
Also Conservatively set pt.null to 1.
(pt_solution_reset): Conservatively set pt.null to 1.
(pt_solution_singleton_or_null_p): Renamed from
pt_solution_singleton_p.
* tree-ssanames.h (set_ptr_nonnull): Declare.
(get_ptr_nonnull): Likewise.
* tree-ssanames.c (set_ptr_nonnull): New.
(get_ptr_nonnull): Likewise.
* tree-vrp.c (vrp_finalize): Set ptr that are nonnull.
(evrp_dom_walker::before_dom_children): Likewise.
gcc/testsuite/ChangeLog:
2016-10-18 Kugan Vivekanandarajah <kuganv@linaro.org>
* gcc.dg/torture/pr39074-2.c: Adjust testcase.
* gcc.dg/torture/pr39074.c: Likewise.
From-SVN: r241287
Diffstat (limited to 'gcc/tree-ssanames.c')
-rw-r--r-- | gcc/tree-ssanames.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 64ab13a2048..913d142f046 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -374,6 +374,35 @@ get_range_info (const_tree name, wide_int *min, wide_int *max) return SSA_NAME_RANGE_TYPE (name); } +/* Set nonnull attribute to pointer NAME. */ + +void +set_ptr_nonnull (tree name) +{ + gcc_assert (POINTER_TYPE_P (TREE_TYPE (name))); + struct ptr_info_def *pi = get_ptr_info (name); + pi->pt.null = 0; +} + +/* Return nonnull attribute of pointer NAME. */ +bool +get_ptr_nonnull (const_tree name) +{ + gcc_assert (POINTER_TYPE_P (TREE_TYPE (name))); + struct ptr_info_def *pi = SSA_NAME_PTR_INFO (name); + if (pi == NULL) + return false; + /* TODO Now pt->null is conservatively set to true in PTA + analysis. vrp is the only pass (including ipa-vrp) + that clears pt.null via set_ptr_nonull when it knows + for sure. PTA will preserves the pt.null value set by VRP. + + When PTA analysis is improved, pt.anything, pt.nonlocal + and pt.escaped may also has to be considered before + deciding that pointer cannot point to NULL. */ + return !pi->pt.null; +} + /* Change non-zero bits bitmask of NAME. */ void |