From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90881 invoked by alias); 28 Oct 2016 13:28:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 90871 invoked by uid 89); 28 Oct 2016 13:28:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 spammy=indicator, recommendation, hides, assured X-HELO: mx1.redhat.com Subject: Re: [PATCH] Fix -Os related -Werror failures. To: Andrew Pinski , Arnd Bergmann References: <6eac682f-26fa-6a47-9497-357206266ba1@redhat.com> <6be7dce5-bfa7-32c7-5bac-6c3b79776683@redhat.com> <9d58289e-07fb-4bae-d7d3-8055a6c96a3a@redhat.com> <20863164.XNWC5rYB1g@wuerfel> Cc: GNU C Library , Florian Weimer , "Carlos O'Donell" From: Jeff Law Message-ID: <4efcd5bb-b932-b9e0-ceed-7f02ba4f4447@redhat.com> Date: Fri, 28 Oct 2016 13:28:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-10/txt/msg00533.txt.bz2 On 10/28/2016 02:17 AM, Andrew Pinski wrote: > On Fri, Oct 28, 2016 at 1:12 AM, Arnd Bergmann wrote: >> On Friday, October 28, 2016 12:44:32 AM CEST Jeff Law wrote: >>> On 10/28/2016 12:32 AM, Florian Weimer wrote: >>>> On 10/28/2016 06:46 AM, Carlos O'Donell wrote: >>>>> +/* With GCC 5.3 when compiling with -Os the compiler emits a warning >>>>> + that buf[0] and buf[1] may be used uninitialized. This can only >>>>> + happen in the case where tmpbuf[3] is used, and in that case the >>>>> + write to the tmpbuf[1] and tmpbuf[2] was assured because >>>>> + ucs4_to_cns11643 would have filled in those entries. The difficulty >>>>> + is in getting the compiler to see this logic because tmpbuf[0] is >>>>> + involved in determining the code page and is the indicator that >>>>> + tmpbuf[2] is initialized. */ >>>>> +DIAG_PUSH_NEEDS_COMMENT; >>>>> +DIAG_IGNORE_NEEDS_COMMENT (5.3, "-Wmaybe-uninitialized"); >>>> >>>> This hides the warning for -O2 builds as well, so I don't think this is >>>> a good idea. >>>> >>>> Those who want to build with -Os or other special compiler flags should >>>> just configure with --disable-werror. We can't account for every >>>> optimization someone might want to disable in their build. >>> That'd be my recommendation. >>> >>> What often happens in these cases is the compiler in its default mode of >>> operation is able to statically eliminate a conditional branch on a >>> particular path. However, to do so the compiler has to duplicate code. >>> >>> Not surprisingly, there's a cost/benefit tradeoff here and the >>> heuristics are largely driven by the real or estimated profile data as >>> well as the coarser "optimize for code space". So changing flags >>> changes the output of those heuristics and ultimately can result in >>> leaving paths in the CFG that can not be executed -- and that often >>> leads to false positive may-be-uninitialized warnings and such. >>> >>> Long term I would like to find a good way to mark paths that are not >>> executable, but are not profitable to eliminate, then utilize that >>> information to prune various "may" warnings. That would make those kind >>> of warnings more stable across different optimization levels as well as >>> more stable release-to-release. But that's definitely in the "future >>> work" area. >> >> I've spent a lot of time trying to eliminate -Wmaybe-uninitialized >> warnings from the Linux kernel. Here are some data points that you >> may find useful too: >> >> - Building with -Os causes many false positives starting with gcc-4.9, >> and I have disabled the warning for this specific flag. I believe >> this is due to the lack of the "-fschedule-insns" optimization step > > No this is false. It is usually due to jump threading is not as > aggressive at -O2 than -Os due to -Os not wanting to increase code > size. Correct. The scheduler has nothing to do with this issue, it's primarily jump threading. At -Os we don't allow as much block copying which results in many jump threads not being optimized. The reduced jump threading leaves unexecutable paths in the CFG and results in false positive -Wuninitialized errors. PGO can have similar effects as profiling data may indicate that a particular path is not worth duplicating to eliminate a conditional Inlining goes both ways. By exposing more code to the optimizers, we can often do a better job at eliminating false positives. But it is also the case that inlining may remove the addressability property on an object which in turn exposes the object to these kinds of analysis. Similarly for SRA, function splitting, etc etc. Jeff