From: Martin Sebor Date: Mon, 21 Nov 2016 17:15:54 +0000 (+0000) Subject: Enable -fprintf-return-value by default. Tested on powerpc64le and x86. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=89990732da0502a298fd10f8bfb85e2973259ef6;p=gcc.git Enable -fprintf-return-value by default. Tested on powerpc64le and x86. 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. From-SVN: r242674 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6c509252a80..543d38b5e24 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-11-21 Martin Sebor + + * doc/invoke.texi (-fprintf-return-value): Document that option + is enabled by default. + 2016-11-21 Georg-Johann Lay * config/avr/avr-c.c (avr_register_target_pragmas): Use C++ diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 565ff823fc3..f2ea179761e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2016-11-21 Martin Sebor + + * c.opt (-fprintf-return-value): Enable by default. + 2016-11-21 Bernd Edlinger PR c++/71973 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 10a87936107..c61fab8d2bc 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1554,7 +1554,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 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 67ed240b8aa..e02665318b1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -381,11 +381,12 @@ Objective-C and Objective-C++ Dialects}. -fmove-loop-invariants -fno-branch-count-reg @gol -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol --fno-peephole2 -fno-sched-interblock -fno-sched-spec -fno-signed-zeros @gol +-fno-peephole2 -fno-printf-return-value -fno-sched-interblock @gol +-fno-sched-spec -fno-signed-zeros @gol -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 @gol -fprofile-correction @gol -fprofile-use -fprofile-use=@var{path} -fprofile-values @gol -fprofile-reorder-functions @gol @@ -8274,18 +8275,19 @@ dependent on the structure of loops within the source code. 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} 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, 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{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. @smallexample char buf[9]; @@ -8296,7 +8298,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