This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TM4C123BE6PZ: Optimization level greater than 'off'

Part Number: TM4C123BE6PZ

Tool/software: TI C/C++ Compiler

Recently one of our applications blew out its memory.  We took two paths to solve the issue:

1)Analyze the map file and remove any functions that have been included by un-executable code.  This actually solved the problem.

2)Another path was to increase the optimization level.  Moving from off to 0-Register Optimizations reduced code size by 25%, level one got us another 6%, each additional level help between -1 and 4%.

We had a discussion on optimization levels.  We agreed that we should stay away from higher optimization levels because:

1)Stepping through the code gets harder and at times next to impossible

2)We distrust the upper levels. 

The compiler writers need to get pretty tricky at some point and some of those tricks may not be abundantly tested.

Experience has shown that when updating to a new version of compiler, it is the highly optimized code that breaks.

But that 25% savings for just the first level of optimization is pretty tempting if we get in a pinch.

So where are these optimization levels defined?  If no where, what are 'register optimizations'? 

I can guess function arguments and registers are more optimized, as are local variables vs stack vs register?  What else?

How would stepping through C code with CCS be changed?  Would the differences only be seen in stepping through the assembler window?

  • John Osen said:
    So where are these optimization levels defined? 

    Please see the chapter titled Optimizing Your Code in the ARM compiler manual.

    John Osen said:
    How would stepping through C code with CCS be changed?  Would the differences only be seen in stepping through the assembler window?

    Please see the article Debug versus Optimization Tradeoff.

    John Osen said:
    Recently one of our applications blew out its memory.  We took two paths to solve the issue:

    Another path to consider.  Use the Optimizer Assistant.  This is a feature of CCS which makes it easy to experiment with the compiler options for optimization and code size.

    Thanks and regards,

    -George