mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Reverting a GCC bug workaround commit from 8 years ago
       [not found] <121822628.385482.1657670107094.ref@mail.yahoo.com>
@ 2022-07-12 23:55 ` Mike Z.Vand
  2022-07-13  1:22   ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Z.Vand @ 2022-07-12 23:55 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 802 bytes --]

Hi,
I was following down a rabbit hole, investigating a weird WebAssembly code generation from wasi-libc, when I saw these strange volatile attributes for some pointers in stdio source code. As it happens, it was a GCC bug workaround that was introduced around 8 years ago (commit a6adb2bcd8145353943377d6119c1d7a4242bae1 work around constant folding bug 61144 in gcc 4.9.0 and 4.9.1).
As comment explained this commit could be "reconsidered and possibly reverted at some point in the future when the broken gcc versions are no longer relevant".
I very much hope it is the time we can revert this and give the compiler more wiggle room to do its thing and have less volatile keywords here and there for healthier looking code overall.
Thank you so much for all the work that has been done on musl.Mike

[-- Attachment #2: Type: text/html, Size: 1872 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] Reverting a GCC bug workaround commit from 8 years ago
  2022-07-12 23:55 ` [musl] Reverting a GCC bug workaround commit from 8 years ago Mike Z.Vand
@ 2022-07-13  1:22   ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2022-07-13  1:22 UTC (permalink / raw)
  To: Mike Z.Vand; +Cc: musl

On Tue, Jul 12, 2022 at 11:55:07PM +0000, Mike Z.Vand wrote:
> Hi,
> I was following down a rabbit hole, investigating a weird
> WebAssembly code generation from wasi-libc, when I saw these strange
> volatile attributes for some pointers in stdio source code. As it
> happens, it was a GCC bug workaround that was introduced around 8
> years ago (commit a6adb2bcd8145353943377d6119c1d7a4242bae1 work
> around constant folding bug 61144 in gcc 4.9.0 and 4.9.1).
> As comment explained this commit could be "reconsidered and possibly
> reverted at some point in the future when the broken gcc versions
> are no longer relevant".
> I very much hope it is the time we can revert this and give the
> compiler more wiggle room to do its thing and have less volatile
> keywords here and there for healthier looking code overall.

I don't think there's any valuable "wiggle room" to be had here. The
loads of these would-be constant objects are not in hot paths, and
there should be exactly one load regardless of whether it's volatile
or not. So this is more a matter of "cleanup" than any practical
benefit to be had.

Whether this can be changed probably depends on whether there were any
GCC version series whose lifetimes ended with the bug still present as
well as analysis of whether there were (or still are) any future
related bugs in this area. I don't recall the details but I seem to
remember this being an ongoing area of wrong optimization. I know at
least that there have been related issues with wrongly using derived
knowledge that a weak definition of a function was pure to conclude
that the function (possibly with a different definition) is pure. So
my leaning would be not to do away with any harmless barriers we have
in place against wrong optimization of weak definitions.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-13  1:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <121822628.385482.1657670107094.ref@mail.yahoo.com>
2022-07-12 23:55 ` [musl] Reverting a GCC bug workaround commit from 8 years ago Mike Z.Vand
2022-07-13  1:22   ` Rich Felker

Code repositories for project(s) associated with this inbox:

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).