[PATCH] move more code to access warning pass

Martin Sebor msebor@gmail.com
Thu Aug 5 22:00:23 GMT 2021


As I mentioned in the description of the access warning pass when
I submitted it in July(*), I planned to change the -Wstringop-xxx
code in the pass to run on the GIMPLE IL instead of on trees in
builtins.c (and elsewhere).  The attached patch implements this
change along with moving more warning code from builtins.c and
calls.c into the pass source.

The changes are mostly mechanical but I should explain one aspect
that might draw attention: since some of the warning functions are
still called from outside the pass with tree arguments, I made them
templates parameterized on the type of the argument: either gimple*
or tree, and provided overloads for each(**).  I expect this to be
a transient solution until remaining callers that pass in trees are
moved into the new pass.  This might take a bit of effort and time
and involve more churn than feels appropriate for a single patch.

Tested on x86_64-linux and by building Glibc and GDB+Binutils with
no new warnings.

As the next steps I plan to:

* integrate the new pass with ranger and enable the pointer query
   caching to avoid repeatedly computing object sizes for statements
   involving related pointers
* move remaining warning code from builtins.c and calls.c (and
   possibly also gimple-fold.c) into the new pass (as much of it
   as possible
* investigate running a subset of the new pass early on during
   optimization in addition to late as it does now, to detect
   problems that are impossible to detect otherwise (i.e., split
   the pass into two stages similar to -Wuninitialized and
   -Wmaybe-uninitialized)
* investigate integrating the uninitialized predicate analyzer
   into the pass to help reduce false positives and perhaps also
   false negatives by enabling maybe-kinds of diagnostics for
   conditional code
* integrate -Warray-bounds into the pass (and remove it from vrp)

Martin

[*] https://gcc.gnu.org/pipermail/gcc-patches/2021-July/575377.html
[**] This was made easy by introducing overloads of functions like
get_location(gimple*) and get_location(tree) to return the location
of a GIMPLE statement or a tree decl or expression.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-warn-access-2.diff
Type: text/x-patch
Size: 108341 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210805/a93c9a05/attachment-0001.bin>


More information about the Gcc-patches mailing list