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
This commit is contained in:
Martin Sebor 2016-11-21 17:15:54 +00:00 committed by Martin Sebor
parent 9636feef4d
commit 89990732da
4 changed files with 27 additions and 16 deletions

View File

@ -1,3 +1,8 @@
2016-11-21 Martin Sebor <msebor@redhat.com>
* doc/invoke.texi (-fprintf-return-value): Document that option
is enabled by default.
2016-11-21 Georg-Johann Lay <avr@gjlay.de>
* config/avr/avr-c.c (avr_register_target_pragmas): Use C++

View File

@ -1,3 +1,7 @@
2016-11-21 Martin Sebor <msebor@redhat.com>
* c.opt (-fprintf-return-value): Enable by default.
2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR c++/71973

View File

@ -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

View File

@ -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