From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31833 invoked from network); 13 Jul 2022 01:23:12 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 13 Jul 2022 01:23:12 -0000 Received: (qmail 20152 invoked by uid 550); 13 Jul 2022 01:23:09 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 20120 invoked from network); 13 Jul 2022 01:23:09 -0000 Date: Tue, 12 Jul 2022 21:22:55 -0400 From: Rich Felker To: "Mike Z.Vand" Cc: "musl@lists.openwall.com" Message-ID: <20220713012255.GZ7074@brightrain.aerifal.cx> References: <121822628.385482.1657670107094.ref@mail.yahoo.com> <121822628.385482.1657670107094@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <121822628.385482.1657670107094@mail.yahoo.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] 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