The Impact of Undefined Behavior on Compiler Optimization
Zefan Shen
Abstract
Zefan Shen
Abstract
With the development of society and the improvement of life quality, people's requirements for software experience are becoming more and more stringent. Performance optimization is becoming more and more important in software design. At present, most compilers support the default optimization options of o 1, o 2 and o 3, such as the GCC compiler. In order to meet the different degrees of optimization needs of users, it provides nearly a hundred optimization options for compiling time, target file length, and execution. At the same time, compiler optimization options will adjust the code execution order, and different optimization options will treat undefined behaviors differently. This work mainly tests the impact of undefined behavior (UB) on compiler optimization at different levels. The results show that UB has both positive and negative effects on the compiler. In addition, this paper reminds programmers to learn to improve their code specifications and correctly handle these undefined behaviors.
OpenAlex reports 3 citations for this work. Citation counts describe recorded attention and do not establish research quality.
A contribution statement is not available in the OpenAlex record.
Method details are not available in the OpenAlex metadata.
Findings are not separately available in the OpenAlex metadata.
Limitations are not available in the OpenAlex metadata.
Application details are not available in the OpenAlex metadata.
With the development of society and the improvement of life quality, people's requirements for software experience are becoming more and more stringent. Performance optimization is becoming more and more important in software design. At present, most compilers support the default optimization options of o 1, o 2 and o 3, such as the GCC compiler. In order to meet the different degrees of optimization needs of users, it provides nearly a hundred optimization options for compiling time, target file length, and execution. At the same time, compiler optimization options will adjust the code execution order, and different optimization options will treat undefined behaviors differently. This work mainly tests the impact of undefined behavior (UB) on compiler optimization at different levels. The results show that UB has both positive and negative effects on the compiler. In addition, this paper reminds programmers to learn to improve their code specifications and correctly handle these undefined behaviors.
Key concepts: Compiler, Computer science, Optimizing compiler, Program optimization, Interprocedural optimization, Loop optimization, Programming language, Code (set theory)