Re: Re: Re: gcc optimization options and lto (detailed info)

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

 



On Thu, 19 May 2022 at 10:12, Roman Kellner wrote:
> What I try to understand is how to write "correct" code, if I need to prevent some dedicated code parts or data structures (typically in flash) from being optimized away or moved around, because the program relies on them.
> Since __attribute__((used)), compare https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_chr1359124978363.htm , volatile etc. are compiler and language features, all I try to further understand is, which influence such declarations and attributes do have on the different optimization features / strategies.
>
> It is not that the optimizers do things wrong, but they do not understand the programmers notion.
> I am looking for ways to tell the optimizers what I need ("This data structure/code part needs to stay where it is / how it is. Do not touch").
> And if others have gathered experience with it, providing some hints (do's and dont's).

Thank you, that makes it clearer. I agree you should be fixing the
code to correctly express the intent, and not adding hundreds of
command-line options to try and micro-manage the optimizers, which is
what you seemed to be asking about (which optimizations are active at
which stages, what they're documented to do, how to avoid very long
command lines etc).

It seems what you're really asking about is how to write correct
embedded code, so that it works correctly with different compilers,
even when optimized. Asking about GCC's LTO optimizations is the wrong
goal, I think.




[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