REGARDING -Og OPTIMIZATION

Jeff Law jeffreyalaw@gmail.com
Mon May 17 15:11:45 GMT 2021


On 5/17/2021 1:44 AM, Jonathan Wakely via Gcc-help wrote:
> On Mon, 17 May 2021, 08:31 Ezhil P via Gcc-help, <gcc-help@gcc.gnu.org>
> wrote:
>
>> Hi,
>> can you kindly clarify the unique feature of -Og flag?. It is described as
>> "optimize the debugging experience". How does it do?
>
>
> It performs some simple optimizations that improve performance similarly to
> -O1. But it avoids transformations that make debugging harder, such as
> drastically rearranging the code, or GDB telling you a variable had been
> "optimized out".
>
> It's not magic, it's just a selection of optimizations that don't hurt the
> debugging experience. The usual -O1, -O2, -O3 options aim for better
> performance, not debugging experience, and -Os aims for smaller code size,
> not debugging experience. So it's just a different set of trade offs.

-Og is also a good option in circumstances where you're compiling 
insanely large code on a resource constrained system.   The case we ran 
into was auto-generated code that had tons of obvious redundancies.  -Og 
cleaned things up enough that we didn't explode the memory usage during 
the out-of-ssa phase and ultimately allowed compilation to succeed (Jon, 
if you're interested, contact me privately and I can give you hints on 
finding the right Red Hat BZ).


Jef



More information about the Gcc-help mailing list