A compiler defect locating method based on fine-grained optimization option configuration difference
Patent Information
- Application Number
- CN202111593390.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-23
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2041-12-23
AI Technical Summary
[0003]本发明在于提供一种基于细粒度优化选项配置差分的编译器缺陷定位方法,解决编译器缺陷定位技术中多个失败覆盖信息的缺失且测试用例生成过程低效的瓶颈问题
[0017] This invention uses the construction of an optimized compiler configuration instead of the mutation generation of test programs to locate compiler defects, solving the problems of missing failure coverage information and excessive resource consumption in existing technologies. All steps of this invention are automated, resulting in significantly improved defect location compared to existing technologies, greatly reducing the defect location burden on compiler developers. The execution process of this invention is simple and efficient, effectively locating compiler defects for subsequent defect fixing.
Smart Images

Figure CN114780374B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software defect localization, particularly compiler defect localization, and is a compiler defect localization method based on fine-grained optimization option configuration differentials. Background Technology
[0002] The compiler is a core infrastructure in software development, primarily used to translate user-written source code into executable machine code. As a complex, large-scale software system, the compiler itself contains numerous defects. These hidden defects inevitably have a decisive impact on the correctness of the compiled software system. The compiler mainly consists of front-end components, back-end components, and optimization components, with the optimization component being the most prone to harboring defects. One of the most important tasks for compiler developers is locating and fixing defects in compiler optimization classes. Due to the complexity and large scale of compilers, accurately locating defective files within the compiler is extremely difficult; therefore, automating the location of compiler defects is of great significance. Furthermore, compilers support a large number of optimization configurations, making the automated location of optimization class defects in the compiler a significant challenge. To address this, recent researchers have proposed generating witness test programs through code mutation to automatically locate compiler optimization defects. However, current compiler defect location techniques still have certain limitations. First, since it cannot be guaranteed that the mutated test program will trigger the same defect as a given failed test program, multiple failed test cases cannot be obtained, resulting in insufficient spectrum-based defect location information. Second, existing methods require a large number of mutations to obtain passing test programs, incurring significant time overhead. The compiler defect localization method based on fine-grained optimization option configuration differentials can effectively solve existing problems and can locate compiler defects more accurately and efficiently. Summary of the Invention
[0003] This invention provides a compiler defect localization method based on fine-grained optimization option configuration differentials, addressing the bottlenecks of missing failure coverage information and inefficient test case generation in compiler defect localization techniques. This invention automates efficient and effective compiler defect localization, thereby ensuring the reliability and correctness of software systems built upon the compiler.
[0004] To effectively and efficiently locate defects in compiler optimization components, this invention discloses a compiler defect localization method based on fine-grained optimization option configuration differentials, specifically including the following steps:
[0005] Step 1: Identify the defect-related and defect-independent fine-grained optimization options enabled by the coarse-grained optimization level that triggers the defect;
[0006] Step 2, Initialize and optimize the configuration;
[0007] Step 3: Based on the fine-grained optimization options that are defect-related and defect-independent, use a combinatorial search method to find the failed optimization configurations that enable as few optimizations as possible, as well as the successful optimization configurations that are similar to the failed configurations.
[0008] Step 4: Use the coverage tool to generate compiler coverage reports for both failed and successful optimization configurations;
[0009] Step 5: Calculate suspicious values for compiler code lines using spectrum-based defect localization techniques;
[0010] Step 6: Aggregate line-level suspicious values into compiler files. Sort the files according to the suspicious values in the compiler files, and the compiler files ranked first are most likely to be defective files.
[0011] In step 1, the compiler enables hundreds of fine-grained optimization options at the coarse-grained optimization level. The fine-grained optimization options at the coarse-grained optimization level that triggers the defect are disabled one by one. If the compilation result changes from failure to success, then the current fine-grained optimization option is the defect-related optimization option; if the compilation result still fails, then it is the defect-independent optimization option.
[0012] In step 2, all defect-independent fine-grained optimization options are disabled, while all defect-related fine-grained optimization options are enabled, thereby configuring an initial compiler optimization sequence. This initial optimization sequence uses fewer optimizations and triggers defects with a higher probability.
[0013] In step 3, defect-related and defect-independent optimization options constitute the search space. Based on the initial compilation optimization configuration obtained in step 2, optimization options in the search space are disabled / enabled using a combinatorial search method to construct the least optimized failing configuration and similar successful configurations. Specifically, each optimization configuration will produce two types of compilation results: pass and fail. Accordingly, the search process can be summarized into three operations: 1) If a failing compilation result is obtained under the current optimization configuration, the enabled options are disabled using a combinatorial search method until enough successful configurations are found. When one or more failing configurations are found during this process, the new configuration replaces the previous failing configuration, and this step continues until the termination condition is met. 2) If the compilation result is successful under the current optimization configuration and a failing configuration has been found, the same operation as in 1) is performed. 3) If the compilation result is successful under the current optimization configuration and a failing configuration has not yet been found, the disabled options are enabled using a combinatorial search method, and the next configuration is searched until the first failing optimization configuration is found.
[0014] In step 4, the test program is compiled using the failed optimization configuration and the successful optimization configuration obtained in step 3, and the defective compiler is instrumented using a coverage tool to obtain several failed test coverages and successful test coverages of the defective compiler.
[0015] In step 5, after obtaining some coverage information of the defective compiler, the spectrum-based defect localization technique can calculate the suspicious values of the compiler's code lines.
[0016] In step 6, suspicious values of the compiler's code lines are aggregated to the file level, thereby obtaining the suspicious ranking of the compiler files. The higher the ranking of a file, the greater the probability that the file is a defective file.
[0017] This invention uses the construction of an optimized compiler configuration instead of the mutation generation of test programs to locate compiler defects, solving the problems of missing failure coverage information and excessive resource consumption in existing technologies. All steps of this invention are automated, resulting in significantly improved defect location compared to existing technologies, greatly reducing the defect location burden on compiler developers. The execution process of this invention is simple and efficient, effectively locating compiler defects for subsequent defect fixing.
[0018] Beneficial effects: This method can effectively locate defective compiler files while avoiding the generation of a large number of test cases through mutation. It effectively addresses the challenge of missing coverage for multiple failed tests and can effectively and efficiently locate defective compiler files, providing a new solution for compiler defect localization. Attached Figure Description
[0019] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments, and the advantages of the present invention as described above or otherwise will become clearer.
[0020] Figure 1 This is a flowchart of a compiler defect localization method based on fine-grained optimization option configuration differences.
[0021] Figure 2 It is a flowchart for identifying fine-grained defect-related and defect-independent optimization options.
[0022] Figure 3 This is a flowchart of the search compiler optimization configuration.
[0023] Figure 4 This is a flowchart for locating compiler defect files. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, this chapter provides a more detailed description of the invention in conjunction with the accompanying drawings.
[0025] Figure 1 This is a flowchart illustrating a compiler defect localization method based on fine-grained optimization option configuration differentials according to the present invention. It includes six steps, as follows:
[0026] Step 1: Identify the defect-related and fine-grained optimization options under the optimization level that triggers the defect;
[0027] Step 2: Initialize the compiler's optimization configuration, disable all defect-independent options and enable all defect-related options.
[0028] Step 3: Based on the fine-grained option set and the initial compiler optimization configuration, search for failed optimization configurations that optimize as few times as possible and similar successful optimization configurations.
[0029] Step 4: Based on the optimized configuration found, use a code coverage tool to obtain the corresponding coverage information for the compiler.
[0030] Step 5: Calculate suspicious values for compiler code lines using spectrum-based defect localization techniques.
[0031] Step 6: Aggregate suspicious values from compiler code lines into the compiler file, and locate the compiler defect file based on the file's ranking results.
[0032] Figure 2 This is a flowchart of step 1, identifying fine-grained defect-related and defect-independent optimization options. Given a coarse-grained optimization level that triggers a defect, the process of identifying the corresponding fine-grained optimization options is as follows:
[0033] Step 2-1: Collect the fine-grained optimization options enabled at the coarse-grained optimization level that triggered the defect, and disable these fine-grained optimization options one by one. For example, in defect #71439 of the defective compiler GCC, "-03" is the coarse-grained optimization level that triggered the defect, which enabled 136 fine-grained optimization options: -finline-functions-called-once, -fira-hoist-pressure, -ftree-loop-vectorize, -fpeel-loops, etc.
[0034] Step 2-2: The optimization level that triggers the defect and a fine-grained optimization option that is disabled constitute the optimization sequence configuration. The test program is compiled using the constructed optimization sequence. If the compilation result changes from failure to success, then the option is a defect-related optimization option; otherwise, it is a compilation-independent optimization option. For example, the "-03-fno-tree-loop-vectorize" compilation configuration changes the compilation result from failure to success, so "-ftree-loop-vectorize" is a fine-grained defect-related optimization option; while "-03-fno-peel-loops" does not change the compilation result, so "-fpeel-loops" is a fine-grained defect-independent optimization option.
[0035] Figure 3 This is a flowchart of step 3, searching for compiler optimization configurations. The process involves identifying failed optimization configurations that use as few optimizations as possible, as well as successful optimization configurations that are similar to the failed configurations. The process is as follows:
[0036] Step 3-1: In step 2, the initial optimization sequence was configured by disabling all defect-independent optimization options and enabling all defect-related optimization options. First, it is determined whether this optimization sequence can trigger a defect. If it can, proceed to step 3-2; otherwise, proceed to step 3-3.
[0037] Step 3-2: If the current optimization configuration can trigger a defect, add the configuration to the set of failed optimization configurations and proceed to step 3-4.
[0038] Step 3-3: If the current optimization configuration cannot trigger the defect, combine and enable the previously disabled optimization options. If the new optimization configuration can trigger the defect, proceed to step 3-2; otherwise, repeat step 3-3.
[0039] Step 3-4: Combine and disable the currently enabled fine-grained options and determine whether the new optimization option configuration can trigger a defect. If it can trigger a defect, repeat step 3-2; otherwise, proceed to step 3-5.
[0040] Step 3-5: Add the current optimized configuration to the set of successful optimized configurations. Determine if the number of elements in the set of successful optimized configurations is sufficient. If a sufficient number of successful optimized configurations have been collected, such as "30 successful optimized configurations have been collected", then end the process, indicating that sufficient optimized configurations have been collected; otherwise, repeat step 3-4.
[0041] Figure 4 This is a flowchart of step 6, which involves aggregating suspicious values from compiler code lines into the compiler file and locating compiler defects based on the ranking of suspicious values in the file. The process is as follows:
[0042] Step 5-1: Given a defective compiler's code line suspicion value, calculate the suspicion value of each compiler file using the average aggregation method. Rank the files according to their suspicion values and sort them in reverse order. The compiler files ranked higher are most likely to be defective files.
[0043] This invention provides a compiler defect localization method based on fine-grained optimization option configuration differentials. Many methods and approaches exist for implementing this technical solution; the above description is merely a preferred embodiment of the invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications should also be considered within the scope of protection of this invention. All components not explicitly stated in this embodiment can be implemented using existing technologies.
Claims
1. A compiler defect localization method based on fine-grained optimization option configuration differentials, characterized in that... This method utilizes multiple failed and successful optimization configurations to obtain coverage reports of defective compilers in order to locate defective compiler files. The steps include: First, identifying fine-grained optimization options. In this method, hundreds of fine-grained optimization options are enabled at the coarse-grained optimization level. Fine-grained optimization options at the coarse-grained optimization level that trigger defects are disabled one by one. If the compilation result changes from failure to success, the option is determined to be a defect-related optimization option; otherwise, it is determined to be a defect-independent optimization option. Second, initializing the optimization option configuration. This involves disabling all defect-independent fine-grained optimization options and enabling all defect-related fine-grained optimization options, thereby configuring an initial compiler optimization sequence that uses fewer optimizations and has a higher probability of triggering defects. Third, searching for optimization configurations. This involves using a combined search to disable or enable optimization options in the search space based on the initial compilation optimization configuration. The process involves six steps: First, constructing a failure optimization configuration with minimal optimization and a similar success optimization configuration. If compilation fails under the current configuration, enabled options are disabled to search for a success configuration. If compilation succeeds under the current configuration and a failure configuration has been found, enabled options are also disabled. If compilation succeeds under the current configuration but a failure configuration has not yet been found, disabled options are enabled to search for the first failure configuration. Second, generating a coverage report involves compiling test programs using the searched failure and success optimization configurations and instrumenting defective compilers using coverage tools to obtain several failure and success test coverages. Third, calculating code suspicious values involves calculating suspicious values for compiler code lines based on spectrum-based defect localization techniques after obtaining several coverage information. Fourth, defect localization involves aggregating the suspicious values of compiler code lines to the file level to obtain a file suspicious ranking. Files with higher rankings are more likely to be defective files.
2. The compiler defect localization method based on fine-grained optimization option configuration differential as described in claim 1, characterized in that... In step 1, this method utilizes fine-grained optimization options and introduces the concepts of defect-related optimization options and defect-independent optimization options, thereby making the compiler's defect localization more accurate and efficient.
3. The compiler defect localization method based on fine-grained optimization option configuration differential as described in claim 1, characterized in that... In step 2, this method initializes the optimization sequence by turning off the defect-independent option and turning on the defect-related option, which helps to accelerate the search process for optimization configuration.
4. The compiler defect localization method based on fine-grained optimization option configuration differential as described in claim 1, characterized in that... In step 3, based on the initial optimization configuration, this method uses a combinatorial search approach to disable or enable fine-grained optimization options to configure the optimization sequence. This process is short and can collect multiple failed optimization configurations and sufficient successful optimization configurations.
5. The compiler defect localization method based on fine-grained optimization option configuration differential as described in claim 1, characterized in that... In step 4, this method uses a code coverage tool to instrument the compiler to obtain a code line coverage report from the compiler. Utilizing existing mature tools to obtain coverage information improves the reliability of the coverage information.
6. The compiler defect localization method based on fine-grained optimization option configuration differential as described in claim 1, characterized in that... In step 5, this method uses a spectrum-based defect localization method to calculate the suspicious value of the compiler's code line, which can efficiently obtain the suspicious value of each line of the compiler's code for defect localization.
7. The compiler defect localization method based on fine-grained optimization option configuration differential as described in claim 1, characterized in that... In step 6, this method uses average aggregation to aggregate compiler line-level suspicious values to file-level values, improving the accuracy of compiler defect localization.
Citation Information
Patent Citations
Software defect data acquisition system based on code semantics and background information
CN110134613A
Search-based compiler optimization sequence fault location method
CN113064821A