From patchwork Wed Nov 16 16:49:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 82563 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp297645obn; Wed, 16 Nov 2016 08:49:23 -0800 (PST) X-Received: by 10.98.206.207 with SMTP id y198mr5861252pfg.70.1479314963417; Wed, 16 Nov 2016 08:49:23 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n62si32549199pfk.105.2016.11.16.08.49.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 08:49:23 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441675-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-441675-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441675-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:from:cc:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=H8P2fZFpV0aOKwQrY 6QQHV9hSyApkKt63CirnWnAORZwVKwvBFZkHggfXo2EyC3UecDsR9DZqYkx/r7ah rZJ9+gH+OU61TtDK7gQb09sdl04eJCWt6p1xJe9ztA7eNF3eQ3ofeBw8dY0ZusYA rbt6dy35z2S1F6c5Ojj+/w9mj0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:from:cc:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=yuqhk3FMw/m4Kf+AsCiAEWG BxxA=; b=oBM1SQXZKdJ9XZYI9LtLUss3Q2dwCh65R9SldaveN7fXhCssnS1pMn9 g8v2jiOMN51QFRNrkgUd35tIh+wqNrILWTxgC47fkFeMH//xY1FWqljxxV7U7AGP +0UrSvqKluhWsQjLtrO3SOaKdfPPlviYTmvFEvXlvjKUtELgIj+U= Received: (qmail 56277 invoked by alias); 16 Nov 2016 16:49:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 56265 invoked by uid 89); 16 Nov 2016 16:49:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=H*Ad:U*sandra X-HELO: mail-qt0-f177.google.com Received: from mail-qt0-f177.google.com (HELO mail-qt0-f177.google.com) (209.85.216.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Nov 2016 16:49:05 +0000 Received: by mail-qt0-f177.google.com with SMTP id w33so108938588qtc.3 for ; Wed, 16 Nov 2016 08:49:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:cc:message-id:date :user-agent:mime-version:in-reply-to; bh=vGKHvl6eRNE+sxACPAF9mbe8yoNjRKpd8ZDOCllt/m8=; b=J8/s854HrN6hH9jqp36p16uZXqfIMFXltxXSKwKO2jGDy9gyitWxZYtAcDBbdbyaFk HHg8rXlssnTUbX0du2MMgKdpvvznM+Ins6R6FZC6CayHA09C9LoZSX5vC6ABkT/AqtuQ x5kwxj/Bizo/K2v/cuHzD1VBYSYYEqMsgcZt0SvQVDS2K0uxNgzLgLE6n1G5LgSxqgKG n8GS4Eu6KbAMsleEEPF0xgyslt3xo4h3TVLErefM80oP9jmlnZzyP4lB85MaNfSnEDmz ijlsjBUKJdqiUSFy3OdS5WugFcAiiUbWKkziJyMbz7JQERe8xT/aLzkJ7mcHHez+Vj/5 Y4Tw== X-Gm-Message-State: AKaTC03yfxcuVItMaYDwV6uedwlBpu45JWE9GRdUyfEiWs8ZquhIrCAOg8cCz/bYEU+ong== X-Received: by 10.200.45.57 with SMTP id n54mr2757285qta.52.1479314944014; Wed, 16 Nov 2016 08:49:04 -0800 (PST) Received: from [192.168.0.26] (75-166-206-79.hlrn.qwest.net. [75.166.206.79]) by smtp.gmail.com with ESMTPSA id w34sm18167037qtw.10.2016.11.16.08.49.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 08:49:03 -0800 (PST) Subject: PING [PATCH] enable -fprintf-return-value by default To: Gcc Patch List References: <1e7776ca-c7f6-4d93-6b33-2c51dc5a8689@gmail.com> From: Martin Sebor Cc: Sandra Loosemore Message-ID: Date: Wed, 16 Nov 2016 09:49:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1e7776ca-c7f6-4d93-6b33-2c51dc5a8689@gmail.com> X-IsSubscribed: yes I'm looking for an approval of the attached patch. I've adjusted the documentation based on Sandra's input (i.e., documented the negative of the option rather than the positive; thank you for the review, btw.) On 11/08/2016 08:13 PM, Martin Sebor wrote: > The -fprintf-return-value optimization has been disabled since > the last time it caused a bootstrap failure on powerpc64le. With > the underlying problems fixed GCC has bootstrapped fine on all of > powerpc64, powerpc64le and x86_64 and tested with no regressions. > I'd like to re-enable the option. The attached patch does that. > > Thanks > Martin > gcc/c-family/ChangeLog: * c.opt (-fprintf-return-value): Enable by default. gcc/ChangeLog: * doc/invoke.texi (-fprintf-return-value): Document that option is enabled by default. Index: gcc/c-family/c.opt =================================================================== --- gcc/c-family/c.opt (revision 242500) +++ gcc/c-family/c.opt (working copy) @@ -1550,7 +1550,7 @@ C++ ObjC++ Var(flag_pretty_templates) Init(1) -fno-pretty-templates Do not pretty-print template specializations as the template signature followed by the arguments. fprintf-return-value -C ObjC C++ ObjC++ LTO Optimization Var(flag_printf_return_value) Init(0) +C ObjC C++ ObjC++ LTO Optimization Var(flag_printf_return_value) Init(1) Treat known sprintf return values as constants. freplace-objc-classes Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 242500) +++ gcc/doc/invoke.texi (working copy) @@ -384,7 +384,7 @@ Objective-C and Objective-C++ Dialects}. -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol -fomit-frame-pointer -foptimize-sibling-calls @gol -fpartial-inlining -fpeel-loops -fpredictive-commoning @gol --fprefetch-loop-arrays -fprintf-return-value @gol +-fprefetch-loop-arrays -fno-printf-return-value @gol -fprofile-correction @gol -fprofile-use -fprofile-use=@var{path} -fprofile-values @gol -fprofile-reorder-functions @gol @@ -8286,18 +8286,19 @@ dependent on the structure of loops within the sou Disabled at level @option{-Os}. -@item -fprintf-return-value -@opindex fprintf-return-value -Substitute constants for known return value of formatted output functions -such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and @code{vsnprintf} -(but not @code{printf} of @code{fprintf}). This transformation allows GCC -to optimize or even eliminate branches based on the known return value of -these functions called with arguments that are either constant, or whose -values are known to be in a range that makes determining the exact return -value possible. For example, both the branch and the body of the @code{if} -statement (but not the call to @code{snprint}) can be optimized away when -@code{i} is a 32-bit or smaller integer because the return value is guaranteed -to be at most 8. +@item -fno-printf-return-value +@opindex fno-printf-return-value +Do not substitute constants for known return value of formatted output +functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and +@code{vsnprintf} (but not @code{printf} or @code{fprintf}). This +transformation allows GCC to optimize or even eliminate branches based +on the known return value of these functions called with arguments that +are either constant, or whose values are known to be in a range that +makes determining the exact return value possible. For example, when +@option{-fprintf-return-value} is in effect, both the branch and the +body of the @code{if} statement (but not the call to @code{snprintf}) +can be optimized away when @code{i} is a 32-bit or smaller integer +because the return value is guaranteed to be at most 8. @smallexample char buf[9]; @@ -8308,7 +8309,7 @@ if (snprintf (buf, "%08x", i) >= sizeof buf) The @option{-fprintf-return-value} option relies on other optimizations and yields best results with @option{-O2}. It works in tandem with the @option{-Wformat-length} option. The @option{-fprintf-return-value} -option is disabled by default. +option is enabled by default. @item -fno-peephole @itemx -fno-peephole2