Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220713012255.GZ7074@brightrain.aerifal.cx>
Date: Tue, 12 Jul 2022 21:22:55 -0400
From: Rich Felker <dalias@...c.org>
To: "Mike Z.Vand" <anonlth@...oo.com>
Cc: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: Re: Reverting a GCC bug workaround commit from 8 years ago

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.