Compiler Optimization Test Case Automatic Generation Based on Branching Temporal Logic Specification

Abstract

编译器是软件产业中重要的工具,对它的质量保证非常重要。编译优化是编译器的重要功能,它的质量对于编译器质量有重大影响。可采用软件测试的方法进行编译器优化模块的质量保证。测试需要测试用例。编译优化的测试用例必须触发编译器的优化功能,是具有可被优化特征的源程序。对不同的编译优化,该特征各不相同。需要将不同优化所对应的特征加入到源程序中以构造编译优化测试用例程序。 TRANS语言结合了时序逻辑,描述了不同的编译优化,包括优化前后的代码特征、优化执行的条件及方法。优化前的代码特征和执行优化的条件可被用作构造编译优化测试用例程序所需的特征。一种基于时序逻辑的编译优化测试用例程序生成方法的框架已被提出。该方法从TRANS描述的某种变体生成编译优化测试用例程序。但是该框架并未完善,面临多方面的问题。本文参考该框架的思想,设计了编译优化测试用例程序生成方法,解决了算法框架的部分问题。该方法可以适应复杂描述的情况;公式的合法性及语义得以保持;具体化并完整化了原有框架。该方法是具有针对性的编译优化测试用例程序自动生成方法。本文对该方法作了原型系统实现,并从中得到测试用例程序。本文设计并进行针对GCC的优化模块测试实验,以覆盖率为评价指标检验了测试用例程序的质量。实验表明该方法生成的测试用例程序具有针对性。对编译优化模块的测试,该方法是一种行之有效的办法。并且该方法仍有更多的应用空间,加以改进后可用于优化组合测试、优化正确性检测等。Compilers are essential tools in the software industry. The quality assurance of compilers is vital to the software products. Compiler optimization is an important function in compiler, and its quality plays an important part in that of a compiler. The quality assurance of compiler optimization can be made with software testing, which needs test cases. Compiler optimization test cases should trigger the action of the optimizer. They are source codes containing parts to be optimized, which are different for various types of optimizations. It needs to add different parts to the source codes to build test case programs for various optimizations. TRANS language formally describes different types of optimizations with temporal logic. It describes the characteristics of source codes before and after optimizations, the action and condition of the optimizations. The characteristics before optimization and the condition should be regarded as characteristics that activate the optimizer. A compiler optimization test case programs generation framework based on temporal logic has been proposed. The framework generates test case programs from modified descriptions from TRANS. But the framework is not complete and contains problems. This paper designs and builds a new compiler optimization test case programs automatic generation method based on the framework and solves some problems. This method eliminates malformed formulae and preserves their semantics, can deal with complex descriptions, and completes the framework. A prototype system has been implemented and test case programs are produced by the system. This paper designs and executes experiments on testing GCC and uses test coverage as a criterion to evaluate the test case programs. Analysis shows that the generation method is an accurate one according to optimizations. It’s an effective method for compiler optimization module test. The method can be further enhanced to assist optimizations combination study and optimization correctness checking, etc

    Similar works