www.ti.com
2.10.1 Inlining Intrinsic Operators ..................................................................................... 49
2.10.2 Unguarded Definition-Controlled Inlining ..................................................................... 49
2.10.3 Guarded Inlining and the _INLINE Preprocessor Symbol .................................................. 50
2.10.4 Inlining Restrictions ............................................................................................. 52
2.11 Using Interlist ............................................................................................................... 53
2.12 Enabling Entry Hook and Exit Hook Functions ........................................................................ 54
3 Optimizing Your Code ........................................................................................................ 55
3.1 Invoking Optimization ..................................................................................................... 56
3.2 Performing File-Level Optimization (--opt_level=3 option) ........................................................... 57
3.2.1 Controlling File-Level Optimization (--std_lib_func_def Options) ........................................... 57
3.2.2 Creating an Optimization Information File (--gen_opt_info Option) ........................................ 57
3.3 Performing Program-Level Optimization (--program_level_compile and --opt_level=3 options) ................ 58
3.3.1 Controlling Program-Level Optimization (--call_assumptions Option) ..................................... 58
3.3.2 Optimization Considerations When Mixing C/C++ and Assembly ......................................... 59
3.4 Indicating Whether Certain Aliasing Techniques Are Used .......................................................... 60
3.4.1 Use the --aliased_variables Option When Certain Aliases are Used ...................................... 60
3.4.2 Use the --no_bad_aliases Option to Indicate That These Techniques Are Not Used ................... 61
3.5 Use Caution With asm Statements in Optimized Code .............................................................. 62
3.6 Automatic Inline Expansion (--auto_inline Option) .................................................................... 62
3.7 Using the Interlist Feature With Optimization .......................................................................... 63
3.8 Debugging and Profiling Optimized Code .............................................................................. 64
3.8.1 Debugging Optimized Code (--symdebug:dwarf, --symdebug:coff, and --opt_level Options) .......... 64
3.8.2 Profiling Optimized Code ........................................................................................ 64
3.9 Controlling Code Size Versus Speed ................................................................................... 65
3.10 What Kind of Optimization Is Being Performed? ...................................................................... 66
3.10.1 Cost-Based Register Allocation ............................................................................... 66
3.10.2 Alias Disambiguation ............................................................................................ 66
3.10.3 Branch Optimizations and Control-Flow Simplification ..................................................... 67
3.10.4 Data Flow Optimizations ........................................................................................ 67
3.10.5 Expression Simplification ....................................................................................... 67
3.10.6 Inline Expansion of Functions ................................................................................. 67
3.10.7 Function Symbol Aliasing ...................................................................................... 67
3.10.8 Induction Variables and Strength Reduction ................................................................. 68
3.10.9 Loop-Invariant Code Motion ................................................................................... 68
3.10.10 Loop Rotation ................................................................................................... 68
3.10.11 Instruction Scheduling ......................................................................................... 68
3.10.12 Tail Merging .................................................................................................... 68
3.10.13 Autoincrement Addressing .................................................................................... 68
3.10.14 Hardware Loop Instructions .................................................................................. 68
3.10.15 Circular Addressing ............................................................................................ 69
4 Linking C/C++ Code ........................................................................................................... 71
4.1 Invoking the Linker Through the Compiler (-z Option) ................................................................ 72
4.1.1 Invoking the Linker Separately ................................................................................. 72
4.1.2 Invoking the Linker as Part of the Compile Step ............................................................. 73
4.1.3 Disabling the Linker (--compile_only Compiler Option) ...................................................... 73
4.2 Linker Code Optimizations ............................................................................................... 74
4.2.1 Generate List of Dead Functions (--generate_dead_funcs_list Option) ................................... 74
4.2.2 Generating Function Subsections (--gen_func_subsections Compiler Option) .......................... 74
4.3 Controlling the Linking Process .......................................................................................... 75
4.3.1 Including the Run-Time-Support Library ....................................................................... 75
4.3.2 Run-Time Initialization ........................................................................................... 76
4.3.3 Initialization by the Interrupt Vector ............................................................................ 76
4.3.4 Global Object Constructors ..................................................................................... 77
4
Contents SPRU281G– December 2011
Submit Documentation Feedback
Copyright © 2011, Texas Instruments Incorporated