Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1503667
| From | Richard Biener <rguenther@suse.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts |
| Date | 2016-10-19 16:30 +0200 |
| Message-ID | <su02u-2rf-65@gated-at.bofh.it> (permalink) |
| References | (6 earlier) <steAx-2Ua-9@gated-at.bofh.it> <stxDc-7sX-15@gated-at.bofh.it> <stJXI-7yE-15@gated-at.bofh.it> <su02u-2rf-67@gated-at.bofh.it> <su02u-2rf-69@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, 19 Oct 2016, Peter Zijlstra wrote:
> On Wed, Oct 19, 2016 at 10:18:43AM +0200, Richard Biener wrote:
>
> > The commit implements a long-standing failure to optimize trivial pointer
> > comparisons that arise for example from libstdc++. PR65686 contains
> > a simple C example:
> >
> > mytype f(struct S *e)
> > {
> > mytype x;
> > if(&x != e->pu)
> > __builtin_memcpy(&x, e->pu, sizeof(unsigned));
> > return x;
> > }
> >
> > where GCC before the commit could not optimize the &x != e->pu test
> > as trivial false.
>
> Which is fine; x is stack based and could not possibly have been handed
> as the argument to this same function.
Sure, it was just one example.
> This is also an entirely different class of optimizations than the whole
> pointer arithmetic is only valid inside an object thing.
Yes, it is not related to that. I've opened
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78035 to track an
inconsistency in that new optimization.
> The kernel very much relies on unbounded pointer arithmetic, including
> overflow. Sure, C language says its UB, but we know our memory layout,
> and it would be very helpful if we could define it.
It's well-defined and correctly handled if you do the arithmetic
in uintptr_t. No need for knobs.
> Can't we get a knob extending -fno-strict-aliasing to define pointer
> arithmetic outside of objects and overflow? I mean, we already use that,
> we also use -fno-strict-overflow and a whole bunch of others.
>
> At the very least, it would be nice to get a -W flag for when this alias
> analysis stuff kills something so we can at least know when GCC goes and
> defeats us.
What kind of warning do you envision?
"warning: optimized address comparison to always true/false"
? That would trigger all over the place.
Richard.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/12] external array access helpers Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-16 17:30 +0200
[PATCH 07/12] tracing: declare __{start,stop}_ftrace_enum_maps as external array Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-16 17:30 +0200
[PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-16 17:30 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-17 09:10 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Peter Zijlstra <peterz@infradead.org> - 2016-10-17 10:40 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Jiri Slaby <jslaby@suse.cz> - 2016-10-17 11:10 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Peter Zijlstra <peterz@infradead.org> - 2016-10-17 11:10 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-17 13:30 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Peter Zijlstra <peterz@infradead.org> - 2016-10-17 13:50 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-18 10:10 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-10-18 23:20 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Richard Biener <rguenther@suse.de> - 2016-10-19 16:30 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Peter Zijlstra <peterz@infradead.org> - 2016-10-19 16:40 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Richard Biener <rguenther@suse.de> - 2016-10-19 18:00 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Peter Zijlstra <peterz@infradead.org> - 2016-10-19 18:10 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Richard Biener <rguenther@suse.de> - 2016-10-19 17:10 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Peter Zijlstra <peterz@infradead.org> - 2016-10-19 18:20 +0200
Re: [PATCH 01/12] extarray: define helpers for arrays defined in linker scripts Jiri Slaby <jslaby@suse.cz> - 2016-10-19 16:50 +0200
[PATCH 12/12] dynamic debug: declare table as external array Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-16 17:30 +0200
[PATCH 10/12] serial_core: declare __earlycon_table{,_end} as external array Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-16 18:00 +0200
[PATCH 08/12] tracing: declare __trace_bprintk_fmt/__tracepoint_str as external arrays Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-16 18:00 +0200
[PATCH 09/12] tracing: declare __{start,stop}_syscalls_metadata as external array Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-16 18:20 +0200
Re: [PATCH 00/12] external array access helpers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-16 18:20 +0200
Re: [PATCH 00/12] external array access helpers Vegard Nossum <vegard.nossum@oracle.com> - 2016-10-16 19:30 +0200
Re: [PATCH 00/12] external array access helpers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-17 09:10 +0200
Re: [PATCH 00/12] external array access helpers Jiri Slaby <jslaby@suse.cz> - 2016-10-17 08:30 +0200
csiph-web