|
|||||||||||
Technical Support Support Resources
Product Information |
ARMCLANG: Code size comparison between ARMCC and ARMCLANGInformation in this knowledgebase article applies to:
SYMPTOMI compared the code size generated by Arm Compiler 5 with the one generated by Arm Compiler 6 with different optimization levels inside the same project. If the linker time optimization (LTO) is not enabled in Arm Compiler 6, the code size generated by Arm Compiler 6 might be bigger than the one generated by Arm Compiler 5 with different -Onum optimization changes. Code generated by Arm Compiler 6 from -O1 to -O2 increases in size. However, code generated by Arm Compiler 5, decreases in size, when the optimization level goes from -O1 to -O2. What are the differences in terms of optimization for Arm Compiler 5 and Arm Compiler 6? How can I achieve a smaller code size using the Arm Compiler 6 toolchain? CAUSEGenerally speaking, the optimization algorithms used in Arm Compiler 5 and Arm Compiler 6 are quite different, so a user cannot directly compare the code size of an image with the same -Onum compiler option between ARMCC and ARMCLANG. Even a transition between the same two -Onum levels cannot be directly compared. The optimization level goals are different, partially because Arm Compiler 5 and the Arm Compiler 6 are based on different technologies. When a compiler carries out optimizations, there is always a trade-off between code size, performance (time for code execution) and debug experience. Using Arm Compiler 6 the code size might increase from -O1 to -O2, because the code is generated in favour of performance rather than code size. In Arm Compiler 6, as -Onum's numeric level increases, performance increases, unlike ARMCC. Certain optimizations like loop unrolling might be carried out to speed up code execution, result in larger code size. Additionally optimizing across modules with link time optimization (LTO) will give the link-time optimizer (libLTO) better opportunities to reduce code size further. You can quickly enable this feature in µVision's Options for Target => Target tab. The equivalent ARMCLANG command-line option is "-flto" RESOLUTIONFor applications, like ones running on devices with minimal Flash/RAM resource, where the code size is the most crucial criterion, use -Oz together with LTO to minimize the code size of the image, in production. In order to get a list of all optimization methods done by ARMCLANG for a specific optimization level, you can add the additional compiler options -mllvm and -debug-pass=Arguments. See the following example: armclang --target=arm-arm-none-eabi -mcpu=cortex-m3 -mthumb -c test.c -O1 -v -mllvm -debug-pass=Arguments However, note that -mllvm -debug-pass=Arguments is a COMMUNITY feature. Minimum Compiler Optimization RecommendationsMost Arm Compiler 5 (ARMCC) examples used an optimization level 0. However, for Arm Compiler 6 (ARMCLANG) the minimum recommended setting is instead optimization level 1. See the Application Note 298: Migrate from ARM C/C++ Compiler 5 to ARM Compiler for more details and tips. Therefore for projects being converted to use ARMCLANG, it is strongly recommended not to use level 0 optimization. Choosing level 0 optimization with ARMCLANG requires several additional steps in order to get a program to link successfully, without much benefit. Such actions are listed in the Note section at the bottom of this manual page. STATUSARMCLANG is continuously being improved by the ARM compiler team to achieve better performance as well as smaller (better) code size in a great many test scenarios. If you discover a use-case, where ARMCLANG (or armlink) misses an optimization opportunity or does not perform correctly, feel free to contact an ARM support team. The vast majority of reported issues in compiler support work are not bugs at all, but such a conversation can help, in many other ways. For more information about reporting issues, and how to do it well, see our guide. MORE INFORMATION
SEE ALSO
Last Reviewed: Tuesday, November 3, 2020 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.