Commit 89990732 by Martin Sebor Committed by Martin Sebor

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
parent 9636feef
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> 2016-11-21 Georg-Johann Lay <avr@gjlay.de>
* config/avr/avr-c.c (avr_register_target_pragmas): Use C++ * config/avr/avr-c.c (avr_register_target_pragmas): Use C++
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> 2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR c++/71973 PR c++/71973
......
...@@ -1554,7 +1554,7 @@ C++ ObjC++ Var(flag_pretty_templates) Init(1) ...@@ -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. -fno-pretty-templates Do not pretty-print template specializations as the template signature followed by the arguments.
fprintf-return-value 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. Treat known sprintf return values as constants.
freplace-objc-classes freplace-objc-classes
......
...@@ -381,11 +381,12 @@ Objective-C and Objective-C++ Dialects}. ...@@ -381,11 +381,12 @@ Objective-C and Objective-C++ Dialects}.
-fmove-loop-invariants -fno-branch-count-reg @gol -fmove-loop-invariants -fno-branch-count-reg @gol
-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @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-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 -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
-fomit-frame-pointer -foptimize-sibling-calls @gol -fomit-frame-pointer -foptimize-sibling-calls @gol
-fpartial-inlining -fpeel-loops -fpredictive-commoning @gol -fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
-fprefetch-loop-arrays -fprintf-return-value @gol -fprefetch-loop-arrays @gol
-fprofile-correction @gol -fprofile-correction @gol
-fprofile-use -fprofile-use=@var{path} -fprofile-values @gol -fprofile-use -fprofile-use=@var{path} -fprofile-values @gol
-fprofile-reorder-functions @gol -fprofile-reorder-functions @gol
...@@ -8274,18 +8275,19 @@ dependent on the structure of loops within the source code. ...@@ -8274,18 +8275,19 @@ dependent on the structure of loops within the source code.
Disabled at level @option{-Os}. Disabled at level @option{-Os}.
@item -fprintf-return-value @item -fno-printf-return-value
@opindex fprintf-return-value @opindex fno-printf-return-value
Substitute constants for known return value of formatted output functions Do not substitute constants for known return value of formatted output
such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and @code{vsnprintf} functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
(but not @code{printf} of @code{fprintf}). This transformation allows GCC @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
to optimize or even eliminate branches based on the known return value of transformation allows GCC to optimize or even eliminate branches based
these functions called with arguments that are either constant, or whose on the known return value of these functions called with arguments that
values are known to be in a range that makes determining the exact return are either constant, or whose values are known to be in a range that
value possible. For example, both the branch and the body of the @code{if} makes determining the exact return value possible. For example, when
statement (but not the call to @code{snprint}) can be optimized away when @option{-fprintf-return-value} is in effect, both the branch and the
@code{i} is a 32-bit or smaller integer because the return value is guaranteed body of the @code{if} statement (but not the call to @code{snprint})
to be at most 8. 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 @smallexample
char buf[9]; char buf[9];
...@@ -8296,7 +8298,7 @@ if (snprintf (buf, "%08x", i) >= sizeof buf) ...@@ -8296,7 +8298,7 @@ if (snprintf (buf, "%08x", i) >= sizeof buf)
The @option{-fprintf-return-value} option relies on other optimizations The @option{-fprintf-return-value} option relies on other optimizations
and yields best results with @option{-O2}. It works in tandem with the and yields best results with @option{-O2}. It works in tandem with the
@option{-Wformat-length} option. The @option{-fprintf-return-value} @option{-Wformat-length} option. The @option{-fprintf-return-value}
option is disabled by default. option is enabled by default.
@item -fno-peephole @item -fno-peephole
@itemx -fno-peephole2 @itemx -fno-peephole2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment