ARM Optimizing C/C++ Compiler V18.1.0.LTS
Total Page:16
File Type:pdf, Size:1020Kb
ARM Optimizing C/C++ Compiler v18.1.0.LTS User's Guide Literature Number: SPNU151R January 2018 Contents Preface ........................................................................................................................................ 9 1 Introduction to the Software Development Tools.................................................................... 12 1.1 Software Development Tools Overview ................................................................................. 13 1.2 Compiler Interface.......................................................................................................... 15 1.3 ANSI/ISO Standard ........................................................................................................ 15 1.4 Output Files ................................................................................................................. 15 1.5 Utilities ....................................................................................................................... 16 2 Using the C/C++ Compiler ................................................................................................... 17 2.1 About the Compiler......................................................................................................... 18 2.2 Invoking the C/C++ Compiler ............................................................................................. 18 2.3 Changing the Compiler's Behavior with Options ....................................................................... 19 2.3.1 Linker Options ..................................................................................................... 25 2.3.2 Frequently Used Options......................................................................................... 27 2.3.3 Miscellaneous Useful Options ................................................................................... 28 2.3.4 Run-Time Model Options......................................................................................... 30 2.3.5 Symbolic Debugging and Profiling Options .................................................................... 32 2.3.6 Specifying Filenames ............................................................................................. 33 2.3.7 Changing How the Compiler Interprets Filenames ........................................................... 33 2.3.8 Changing How the Compiler Processes C Files .............................................................. 33 2.3.9 Changing How the Compiler Interprets and Names Extensions ............................................ 34 2.3.10 Specifying Directories............................................................................................ 34 2.3.11 Assembler Options............................................................................................... 35 2.3.12 Deprecated Options.............................................................................................. 35 2.4 Controlling the Compiler Through Environment Variables............................................................ 35 2.4.1 Setting Default Compiler Options (TI_ARM_C_OPTION).................................................... 36 2.4.2 Naming One or More Alternate Directories (TI_ARM_C_DIR) .............................................. 37 2.5 Controlling the Preprocessor ............................................................................................. 38 2.5.1 Predefined Macro Names ........................................................................................ 38 2.5.2 The Search Path for #include Files ............................................................................. 41 2.5.3 Support for the #warning and #warn Directives ............................................................... 42 2.5.4 Generating a Preprocessed Listing File (--preproc_only Option) ........................................... 42 2.5.5 Continuing Compilation After Preprocessing (--preproc_with_compile Option) ........................... 43 2.5.6 Generating a Preprocessed Listing File with Comments (--preproc_with_comment Option) ........... 43 2.5.7 Generating Preprocessed Listing with Line-Control Details (--preproc_with_line Option) ............... 43 2.5.8 Generating Preprocessed Output for a Make Utility (--preproc_dependency Option) ................... 43 2.5.9 Generating a List of Files Included with #include (--preproc_includes Option) ........................... 43 2.5.10 Generating a List of Macros in a File (--preproc_macros Option) ......................................... 43 2.6 Passing Arguments to main()............................................................................................. 44 2.7 Understanding Diagnostic Messages.................................................................................... 44 2.7.1 Controlling Diagnostic Messages ............................................................................... 46 2.7.2 How You Can Use Diagnostic Suppression Options ......................................................... 47 2.8 Other Messages ............................................................................................................ 47 2.9 Generating Cross-Reference Listing Information (--gen_cross_reference Option)................................ 47 2.10 Generating a Raw Listing File (--gen_preprocessor_listing Option)................................................. 48 2.11 Using Inline Function Expansion ......................................................................................... 49 2 Contents SPNU151R–January 2018 Submit Documentation Feedback Copyright © 2018, Texas Instruments Incorporated www.ti.com 2.11.1 Inlining Intrinsic Operators ...................................................................................... 50 2.11.2 Automatic Inlining ................................................................................................ 50 2.11.3 Inlining Restrictions .............................................................................................. 51 2.12 Using Interlist ............................................................................................................... 52 2.13 Controlling Application Binary Interface ................................................................................. 52 2.14 VFP Support ................................................................................................................ 53 2.15 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 Creating an Optimization Information File (--gen_opt_info Option)......................................... 57 3.3 Program-Level Optimization (--program_level_compile and --opt_level=3 options)............................... 57 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 Link-Time Optimization (--opt_level=4 Option) ......................................................................... 60 3.4.1 Option Handling ................................................................................................... 60 3.4.2 Incompatible Types ............................................................................................... 60 3.5 Using Feedback Directed Optimization.................................................................................. 60 3.5.1 Feedback Directed Optimization ................................................................................ 61 3.5.2 Profile Data Decoder.............................................................................................. 63 3.5.3 Feedback Directed Optimization API ........................................................................... 64 3.5.4 Feedback Directed Optimization Summary .................................................................... 64 3.6 Using Profile Information to Analyze Code Coverage ................................................................. 65 3.6.1 Code Coverage.................................................................................................... 65 3.6.2 Related Features and Capabilities .............................................................................. 66 3.7 Accessing Aliased Variables in Optimized Code....................................................................... 67 3.8 Use Caution With asm Statements in Optimized Code ............................................................... 67 3.9 Automatic Inline Expansion (--auto_inline Option) ..................................................................... 67 3.10 Using the Interlist Feature With Optimization........................................................................... 68 3.11 Debugging and Profiling Optimized Code............................................................................... 70 3.11.1 Profiling Optimized Code........................................................................................ 70 3.12 Controlling Code