diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-03-18 18:58:06 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-03-18 19:02:19 +0100 |
commit | 32ca611c42658948f1b8883994796f35e8b4e74d (patch) | |
tree | 20ce7c597f2ef4552d030bc33b37a2255d60fcef /gcc/params.opt | |
parent | 0a0c2c3f06227d46b5e9542dfdd4e0fd2d67d894 (diff) | |
download | gcc-32ca611c42658948f1b8883994796f35e8b4e74d.zip gcc-32ca611c42658948f1b8883994796f35e8b4e74d.tar.gz gcc-32ca611c42658948f1b8883994796f35e8b4e74d.tar.bz2 |
Allow (void *) 0xdeadbeef accesses without warnings [PR99578]
Starting with GCC11 we keep emitting false positive -Warray-bounds or
-Wstringop-overflow etc. warnings on widely used *(type *)0x12345000
style accesses (or memory/string routines to such pointers).
This is a standard programming style supported by all C/C++ compilers
I've ever tried, used mostly in kernel or DSP programming, but sometimes
also together with mmap MAP_FIXED when certain things, often I/O registers
but could be anything else too are known to be present at fixed
addresses.
Such INTEGER_CST addresses can appear in code either because a user
used it like that (in which case it is fine) or because somebody used
pointer arithmetics (including &((struct whatever *)NULL)->field) on
a NULL pointer. The middle-end warning code wrongly assumes that the
latter case is what is very likely, while the former is unlikely and
users should change their code.
The following patch adds a min-pagesize param defaulting to 4KB,
and treats INTEGER_CST addresses smaller than that as assumed results
of pointer arithmetics from NULL while addresses equal or larger than
that as expected user constant addresses. For GCC 13 we can
represent results from pointer arithmetics on NULL using
&MEM[(void*)0 + offset] instead of (void*)offset INTEGER_CSTs.
2022-03-18 Jakub Jelinek <jakub@redhat.com>
PR middle-end/99578
PR middle-end/100680
PR tree-optimization/100834
* params.opt (--param=min-pagesize=): New parameter.
* pointer-query.cc
(compute_objsize_r) <case ARRAY_REF>: Formatting fix.
(compute_objsize_r) <case INTEGER_CST>: Use maximum object size instead
of zero for pointer constants equal or larger than min-pagesize.
* gcc.dg/tree-ssa/pr99578-1.c: New test.
* gcc.dg/pr99578-1.c: New test.
* gcc.dg/pr99578-2.c: New test.
* gcc.dg/pr99578-3.c: New test.
* gcc.dg/pr100680.c: New test.
* gcc.dg/pr100834.c: New test.
Diffstat (limited to 'gcc/params.opt')
-rw-r--r-- | gcc/params.opt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/params.opt b/gcc/params.opt index 507d24c..b88e137 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -613,6 +613,10 @@ The maximum number of insns in loop header duplicated by the copy loop headers p Common Joined UInteger Var(param_max_modulo_backtrack_attempts) Init(40) Param Optimization The maximum number of backtrack attempts the scheduler should make when modulo scheduling a loop. +-param=min-pagesize= +Common Joined UInteger Var(param_min_pagesize) Init(4096) Param Optimization +Minimum page size for warning purposes. + -param=max-partial-antic-length= Common Joined UInteger Var(param_max_partial_antic_length) Init(100) Param Optimization Maximum length of partial antic set when performing tree pre optimization. |