ARM Technical Support Knowledge Articles

PREVENTING COMMON BLOCK OPTIMIZATION

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

We have written a custom implementation of the setjmp function to solve some problems in our application. We are also using the highest optimization level with Linker Code Packing and we have a problem. The compiler and linker optimize the setjmp function calls and this causes problems for our application.

Is there a way to exclude a part of our code from optimization?

ANSWER

Yes. You may specify a different optimization level for the routine that contains the setjmp call. For example:

#pragma SAVE           // save current optimization level
#pragma OPTIMIZE(7)    // disable function block optimization
void func (void)  {

}
#pragma RESTORE        // restore original optimization level

The SAVE and OPTIMIZE pragmas save the current configuration and change the optimizer level to 7. The RESTORE pragma restores the previous optimizer level. Use these around your functions that use setjmp and common block subroutine optmization will be disabled (for these functions).

Note: It is not enough to reduce the optimization level to 8, since the compiler (or linker) would still combine code sections with other functions that are translated with optimize level 9 or higher.

MORE INFORMATION

SEE ALSO

Article last edited on: 2005-07-18 18:16:13

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential