This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Change default optimization level to -Og
- From: Eric Gallager <egall at gwmail dot gwu dot edu>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Mon, 30 Oct 2017 15:20:13 -0400
- Subject: Re: [PATCH] Change default optimization level to -Og
- Authentication-results: sourceware.org; auth=none
- References: <DB6PR0801MB2053E6F13ED5CA0FA6D0D9F483450@DB6PR0801MB2053.eurprd08.prod.outlook.com> <CAMfHzOtNqGGdkr0Uv7bEbR6U-JQ1ay4i=-aSrrmsffY_8ysieA@mail.gmail.com>
On Thu, Oct 26, 2017 at 2:16 PM, Eric Gallager <egall@gwmail.gwu.edu> wrote:
> On 10/26/17, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>> GCC's default optimization level is -O0. Unfortunately unlike other
>> compilers,
>> GCC generates extremely inefficient code with -O0. It is almost unusable
>> for
>> low-level debugging or manual inspection of generated code. So a -O option
>> is
>> always required for compilation. -Og not only allows for fast compilation,
>> but
>> also produces code that is efficient, readable as well as debuggable.
>> Therefore -Og makes for a much better default setting.
>>
>> Any comments?
>
> There are a number of bugs with -Og that I'd want to see fixed before
> making it the default; I'll follow this message up once I find them
> all.
update: I've filed bug 82738 to track them all:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82738
https://gcc.gnu.org/ml/gcc-bugs/2017-10/msg03058.html
>
>>
>> 2017-10-26 Wilco Dijkstra <wdijkstr@arm.com>
>>
>> * opts.c (default_options_optimization): Set default to -Og.
>>
>> doc/
>> * invoke.texi (-O0) Remove default mention.
>> (-Og): Add mention of default setting.
>>
>> --
>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index
>> 3328a3b5fafa6a98007eff52d2a26af520de9128..74c33ea35b9f320b419a3417e6007d2391536f1b
>> 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -7343,7 +7343,7 @@ by @option{-O2} and also turns on the following
>> optimization flags:
>> @item -O0
>> @opindex O0
>> Reduce compilation time and make debugging produce the expected
>> -results. This is the default.
>> +results.
>>
>> @item -Os
>> @opindex Os
>> @@ -7371,7 +7371,7 @@ Optimize debugging experience. @option{-Og} enables
>> optimizations
>> that do not interfere with debugging. It should be the optimization
>> level of choice for the standard edit-compile-debug cycle, offering
>> a reasonable level of optimization while maintaining fast compilation
>> -and a good debugging experience.
>> +and a good debugging experience. This is the default.
>> @end table
>>
>> If you use multiple @option{-O} options, with or without level numbers,
>> diff --git a/gcc/opts.c b/gcc/opts.c
>> index
>> dfad955e220870a3250198640f3790c804b191e0..74511215309f11445685db4894be2ab6881695d3
>> 100644
>> --- a/gcc/opts.c
>> +++ b/gcc/opts.c
>> @@ -565,6 +565,12 @@ default_options_optimization (struct gcc_options
>> *opts,
>> int opt2;
>> bool openacc_mode = false;
>>
>> + /* Set the default optimization to -Og. */
>> + opts->x_optimize_size = 0;
>> + opts->x_optimize = 1;
>> + opts->x_optimize_fast = 0;
>> + opts->x_optimize_debug = 1;
>> +
>> /* Scan to see what optimization level has been specified. That will
>> determine the default value of many flags. */
>> for (i = 1; i < decoded_options_count; i++)
>>
>>