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/TMS320F28388S: unable to disable the optimization level for some function

Part Number: TMS320F28388S

Tool/software: TI C/C++ Compiler

Hi Expert,

My customer want to set optimization level to 1, but for some function they want to set optimization level off, they use the command as below,

but find that actually there is no effect and optimization level 1 also work for this function, any suggestion for this?

  • Strong,

    I'm able to replicate the issue on my end and am looking into it. A workaround is to move the functions into a separate file and set the optimization level to off for that file.

    Not directly related to your question, but I'm curious as to why they want to disable optimizations for some functions - is it because these functions have some strict timing requirements and they want the function to take a fixed number of cycles?

    Ajay

  • Hi Ajay,

    Not directly related to your question, but I'm curious as to why they want to disable optimizations for some functions - is it because these functions have some strict timing requirements and they want the function to take a fixed number of cycles?

    --> The reason that want to  disable optimizations for some function is that when optimizations on, there will have issue for I2C function as posted on the below e2e, and there should have impact the executing cycles and reduce the delay between some function when optimizations on. for this issue, adding delay function to increase a little delay can fix this issue,  but in other way, disable optimizations for the function should have also fix this issue, but actually it did not.

    e2e.ti.com/.../3362401

  • Strong,

    When any level of optimization greater than --opt_level=off is enabled on the command line, optimizations cannot be turned off (--opt_level=off) on a per-function basis using the FUNCTION_OPTIONS pragma. Only --opt_level=0 or higher is available using the FUNCTION_OPTIONS pragma. The TMS320C28x Optimizing C/C++ Compiler User's Guide, section "The FUNCTION_OPTUIONS pragma" will be updated to document this limitation.

    The compiler generates similar code for this function with --opt_level=0 and --opt_level=1 - that is why you are not seeing a difference in the generated assembly. The best approach is to move the functions into a separate file and compile with --opt_level=off.

    Also, from the other thread, if a delay is required, it is better to make that explicit in the code using a loop vs. using --opt_level=off in the compiler. This will ensure the delay is present only where necessary and avoid degrading performance for the rest of the code that is compiled with --opt_level=off.

    Ajay