Re: question about knowing when optimization options are used

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 18, 2020 at 10:44:09AM -0700, mark_at_yahoo via Gcc-help wrote:
> On 3/16/20 4:34 PM, Segher Boessenkool wrote:
> >You can enable the *flags*, sure, but with -O0 those flags do not do
> >anything.  Exactly as the text above says?  The "even if" part.

> Sorry to question this, but my experience has been otherwise.

>From the manual again:
  Most optimizations are completely disabled at '-O0' or if an '-O' level
  is not set on the command line, even if individual optimization flags
  are specified.  Similarly, '-Og' suppresses many optimization passes.

> I haven't 
> tried it in a while (probably last did on an older release) but at least 
> with gcc-arm, doing:
> 
>     -O0 \
>     -fbranch-count-reg \
>     -fcombine-stack-adjustments \
>     -fcompare-elim \
>     -fcprop-registers \
>     <long list of other flags deleted>
> 
> *did* do something different than just "-O0".

It might be interesting to see which compiler flag(s) you see any
differences with.

> 2) My code includes header files with literally thousands (no 
> exaggeration) of "static const int ..."s
> 3) The code (intentionally) uses only a handful of the consts
> 4) If compiled "-O1", no memory is allocated for the thousands of consts 
> (not even the few that are used)
> 5) If compiled "-O0" memory is allocated for each const -- far more 
> memory than is available
> 6) "-O0" executables are much easier to debug at the machine instruction 
> level (sometimes necessary on microcontrollers)
> 
> Can anyone suggest a minimal set of "-f<options>"s to add  to -O0 which 
> will do what I want, i.e. no code optimizations, but also no memory 
> allocated for the consts?

Try -Og instead?  It is mostly like -O1, but almost all debugging should
work fine with it (as the option name itself suggests :-) )


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux