lsirikh
lsirikh

Reputation: 13

Is it possible to set the specific section which is non-optimazed code in C code when I compile ARM-series code in IAR Embedded workbench

I use IAR Embedded workbench to edit C code and compile. I am very curious if I set Optimizations level at High in IAR project options, why the sequence of programming in code was changed.

I have check the reason for change. it may be related with branch speculation.

I'd like to know if I want to use Optimizations level at High, Can I set the specific code section which is not sequential changed by using special tags or options.

thanks.

Upvotes: 1

Views: 5283

Answers (1)

user10008009
user10008009

Reputation:

Currently I don't use IAR. So I cannot test the specific preprocessor directive. But the following should work for functions with IAR, according to the official development guide.

#pragma optimize=none
void foo(void)
{
    /* Do something, but don't optimize this function */ 
}

Description
Use this pragma directive to decrease the optimization level, or to turn off some specific optimizations. This pragma directive only affects the function that follows immediately after the directive.

Quote from the development guide (Page 253).

Upvotes: 4

Related Questions