11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Efficient coding for embedded applicationsFunction inliningFunction inlining means that a simple function, whose definition is known at compiletime, is integrated into the body of its caller to eliminate the overhead of the call. Thisoptimization, which is performed at optimization level High, normally reducesexecution time, but increases code size. The resulting code might also be difficult todebug.The compiler decides which functions to inline. Different heuristics are used whenoptimizing for speed, size, or when balancing between size and speed.Note: This option has no effect at optimization levels None, Low, and Medium.To read more about the command line option, see --no_inline, page 157.Code motionEvaluation of loop-invariant expressions and common subexpressions are moved toavoid redundant re-evaluation. This optimization, which is performed at optimizationlevel High, normally reduces code size and execution time. The resulting code mighthowever be difficult to debug.Note: This option has no effect at optimization levels None, and Low.Type-based alias analysisWhen two or more pointers <strong>reference</strong> the same memory location, these pointers are saidto be aliases for each other. The existence of aliases makes optimization more difficultbecause it is not necessarily known at compile time whether a particular value is beingchanged.Type-based alias analysis optimization assumes that all accesses to an object will takeplace using its declared type or as a char type. This assumption lets the compiler detectwhether pointers may <strong>reference</strong> the same memory location or not.Type-based alias analysis is performed at optimization level High. For ISO/ANSIstandard-conforming C or <strong>C++</strong> application code, this optimization can reduce code sizeand execution time. However, non-standard-conforming C or <strong>C++</strong> code might result inthe compiler producing code that leads to unexpected behavior. Therefore, it is possibleto turn this optimization off.Note: This option has no effect at optimization levels None, Low, and Medium.To read more about the command line option, see --no_tbaa, page 158.Exampleshort f(short * p1, long * p2){Part 1. Using the compiler123

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!