]> gcc.gnu.org Git - gcc.git/commit
Improve uninitialized warning with value range info
authorBin Cheng <bin.cheng@linux.alibaba.com>
Fri, 6 Nov 2020 21:19:40 +0000 (16:19 -0500)
committerJeff Law <law@torsion.usersys.redhat.com>
Fri, 6 Nov 2020 21:21:11 +0000 (16:21 -0500)
commit7987a8d29a78eb373b5e054d539e332d75e92e92
treeb4197947306fbb473293ef3b951a8b0c5b31cad6
parent887515acd27e49c176395ab76d5826959d89cb9b
Improve uninitialized warning with value range info

Function use_pred_not_overlap_with_undef_path_pred of
pass_late_warn_uninitialized
checks if predicate of variable use overlaps with predicate of undefined
control flow path.
For now, it only checks ssa_var comparing against constant, this can be
improved where
ssa_var compares against another ssa_var with value range info, as described in
comment:

+         /* Check value range info of rhs, do following transforms:
+              flag_var < [min, max]  ->  flag_var < max
+              flag_var > [min, max]  ->  flag_var > min
+
+            We can also transform LE_EXPR/GE_EXPR to LT_EXPR/GT_EXPR:
+              flag_var <= [min, max] ->  flag_var < [min, max+1]
+              flag_var >= [min, max] ->  flag_var > [min-1, max]
+            if no overflow/wrap.  */

gcc/

* tree-ssa-uninit.c (find_var_cmp_const): New function.
(use_pred_not_overlap_with_undef_path_pred): Call above.
gcc/tree-ssa-uninit.c
This page took 0.161236 seconds and 6 git commands to generate.