Compiler repetition defect identification method based on deep semantic representation
Through a method based on deep semantic representation, a pre-trained code representation model is used to extract error-causing semantic representation vectors and prioritize them, which solves the problem of low efficiency in compiler repeated silent defect identification and achieves more efficient repeated defect identification and priority sorting.
Patent Information
- Application Number
- CN202510802175.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-16
- Publication Date
- 2025-09-16
AI Technical Summary
Existing compiler repetitive silent defect identification technologies are difficult to identify and prioritize efficiently, resulting in a heavy diagnostic workload for developers, especially when resources are limited.
A method based on deep semantic representation is adopted to extract error-causing semantic representation vectors through a pre-trained code representation model. The farthest point first algorithm is used to prioritize compiler defects and identify repeated defects.
It improves the efficiency and effectiveness of compiler repetitive defect identification in a black-box manner, reduces the diagnostic workload of developers, and proves its effectiveness on 82 real defects.
Smart Images

Figure CN120653534A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of software engineering and software testing, and in particular to a compiler repetitive defect identification system and method. Background Art
[0002] Compiler testing is currently the most widely used compiler quality assurance technology. Many compiler testing technologies detect compiler defects by executing a large number of test programs.
[0003] Identifying repetitive silent compiler defects is a challenging task aimed at alleviating the diagnostic burden of highly repetitive test failures. Numerous techniques for identifying repetitive compiler defects have been proposed in the literature, and this task is framed as a prioritization problem. Specifically, test programs that are more likely to trigger distinct defects should be given higher priority so that developers can identify more distinct defects by examining fewer test failures during their diagnostic process. This is the goal of test failure prioritization, which can significantly reduce developers' diagnostic effort, especially when diagnostic resources are limited.
[0004] To facilitate prioritization, each existing recurring defect detection technique represents test failures as a vector. For example, state-of-the-art white-box techniques (D^3) analyze three dimensions of test failures (i.e., the test program that triggered the failure, test coverage, and fine-grained compiler optimizations) for vectorization. We follow the same pattern to address the problem of recurring silent compiler defects, capturing semantic information related to the failure from the test program that triggered the failure for vectorization and subsequent prioritization.
[0005] Compiler silent repetition defect detection techniques include white-box and black-box techniques. White-box techniques are generally more effective than black-box techniques. More specifically, compiler silent repetition defects often produce different results at different optimization levels, indicating the presence of an optimization defect. Existing work has explored this issue, with optimizations performed in the compiler's mid- or back-end based on semantic analysis. Therefore, capturing semantic information is helpful for detecting compiler silent repetition defects. Summary of the Invention
[0006] The present invention proposes a compiler repetitive defect identification method based on deep semantic representation, extracts error-causing semantic representation vectors based on error-causing semantic information learning results, and prioritizes repetitive defects based on the error-causing semantic representation vectors to achieve repetitive defect identification of silent compiler repetitive defects.
[0007] In order to achieve the above-mentioned object of the invention, the present invention proposes the following technical solutions:
[0008] The present invention proposes a compiler repetitive defect identification method based on deep semantic representation, which includes the following steps:
[0009] S1. Fine-tune the pre-trained code representation model using auxiliary classification tasks and use intermediate representation learning to learn error-causing semantic information related to test failures.
[0010] S2. Extracting an error-causing semantic representation vector from the fine-tuned pre-trained code representation model;
[0011] S3. Calculate the distance between each fault-causing program using the fault semantic representation vector to obtain a fault distance matrix between the fault-causing programs; prioritize the fault-causing programs based on the fault distance matrix, and prioritize access to compiler defects at the farthest locations to achieve duplicate defect identification in compiler code.
[0012] In some embodiments, the pre-trained code representation model in S1 is an encoder model that represents the code as an embedding vector.
[0013] In some embodiments, S2 includes re-inputting the error-causing test program into the fitted classification task to fine-tune the pre-trained code representation model, and using a deep learning interpretation algorithm to extract the input to the last linear layer and perform a Hadamard product with the gradient as the error-causing semantic representation vector.
[0014] In some embodiments, fine-tuning the pre-trained code representation model using the auxiliary classification task described in S1 includes constructing a fine-tuning dataset, setting four types of mutation rules for non-error-causing test program generation, and the mutation rules include (1) identifier level mutation rules, (2) operator level mutation rules, (3) separator level mutation rules, and (4) statement level mutation rules.
[0015] In some embodiments, S3 further includes iteratively selecting a test program that triggers a defect the furthest away from the prioritized test programs as the next test program in the priority list.
[0016] In some embodiments, using the fault semantic representation vector in S3 to calculate the distance between each fault-causing program includes using the farthest point first algorithm to prioritize the fault-causing programs based on the fault distance matrix, where test failures caused by triggering different compiler defects are ranked in a higher order, and test failures caused by the same compiler defect are ranked in a lower order.
[0017] Compared with the prior art, the present invention can achieve the following beneficial technical effects:
[0018] 1) It can capture the error-causing semantics learned by the model from the difficult-to-interpret neural network, and use the farthest point algorithm for priority sorting to improve the efficiency and effectiveness of black-box compiler defect duplication identification.
[0019] 2) Construct a fine-tuning paradigm suitable for capturing error-causing semantic information and perform first-order mutation on each test program that triggers a defect to ensure that it is slightly different from the defect-free test program.
[0020] 3) An empirical study is conducted on 82 real defects in two widely used compilers, confirming the effectiveness of the theory and method. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a block diagram of a compiler duplication defect identification system based on deep semantic representation according to the present invention;
[0022] Figure 2 This is an overall flow chart of a compiler duplication defect identification method based on deep semantic representation of the present invention;
[0023] Figure 3 This is an example of repeated defect identification of the present invention. DETAILED DESCRIPTION
[0024] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0025] Figure 1 A compiler repetitive defect identification method based on deep semantic representation of the present invention is shown, comprising the following steps:
[0026] Step 1: Using the entire dataset, including both non-error-causing and error-causing programs, we construct an auxiliary classification task and fine-tune the pre-trained code representation model. We then set up auxiliary binary classification tasks using positive and negative samples, fitting the error-causing semantics of the learned programs, and fine-tuning the model. Non-error-causing programs serve as negative samples, and error-causing programs serve as positive samples. The pre-trained code representation model is an encoder model that represents code as an embedding vector. During fine-tuning, it tends to use error-causing semantics to represent positive samples.
[0027] Step 2: Extract the error semantic information from the error semantic information related to the test failure obtained in step 1 to obtain an error semantic representation vector. This step introduces a model interpretation method to extract the vectorized error semantic information from the fine-tuned model. The specific process of this step is described as follows:
[0028] Step 2.1: Re-enter the error-inducing test program into the fitted classification task to fine-tune the pre-trained code representation model; the input of this model is the code, and the output is the binary classification probability prediction of the positive and negative sample labels;
[0029] Step 2.2: Use a deep learning interpretation algorithm to extract the input of the last linear layer and the gradient to perform a Hadamard product as the error semantic representation vector. The vectorized error semantic information serves as the semantic information basis for repeated defect identification.
[0030] Step 3: Based on the fault semantic representation vector obtained in step 2, preferentially access the test failure caused by the same compiler defect at the farthest position, thereby realizing repeated defect identification in the compiler code; further comprising iteratively selecting the test program that triggers the defect the farthest from the prioritized test programs as the next test program in the priority list; the specific process of this step is described as follows:
[0031] Step 3.1, using the error semantic representation vector obtained in step 2 to calculate the distance between each error-causing program, to obtain an error distance matrix between the error-causing programs;
[0032] Step 3.2: Prioritize the error-causing programs based on the error-causing distance matrix; wherein: the farthest point first algorithm is used to prioritize the error-causing programs based on the error-causing distance matrix, where a large distance (small similarity) corresponds to a test failure that is more likely to be caused by different compiler defects, and a small distance (large similarity) corresponds to a test failure that is more likely to be caused by the same compiler defect; wherein, test failures caused by triggering different compiler defects are ranked in a higher order, and test failures caused by the same compiler defect are ranked in a lower order; traversing in this manner will more likely prioritize accessing test failures caused by different compiler defects at the farthest position, thereby realizing duplicate defect identification of compiler code. By using the farthest point first (FPF) algorithm for duplicate defect identification priority sorting, test programs that trigger different compiler defects can obtain higher priority in subsequent diagnosis.
[0033] Figure 2 The technical implementation route of the compiler repetitive defect identification method based on deep semantic representation of the present invention is shown. The input overall data set includes non-error-causing programs and error-causing programs, where non-error-causing programs are used as negative samples and error-causing programs are used as positive samples. Positive and negative samples are set as auxiliary binary classification tasks to fit the error-causing semantic information of the learning program. Afterwards, according to the deep learning interpretability technology, the error-causing semantic vector is extracted from the fitted deep learning model for each error-causing program as the error-causing information representation for repetitive defect identification. Finally, the error-causing distance between the two is calculated through the error-causing semantic representation vectors of each pair of error-causing programs. For all error-causing programs, the error-causing distance between them is used, and the farthest point first algorithm is used to obtain the final repetitive defect identification ranking. The test failures caused by different defects are ranked in the front order, realizing the repetitive defect identification of silent compiler repetitive defects.
[0034] The technical implementation means of the present invention are specifically described as follows:
[0035] 1. Learning Error-Causing Semantic Information: This paper uses code representation learning to extract semantic information from each test program that triggers a failure. Intermediate representation learning is used to design an auxiliary target with easy-to-acquire labels for fine-tuning. The intermediate representation extracted from the model is then used to solve the target recurrence defect identification problem. Specifically, this paper uses a binary classification task (i.e., classifying error-causing (failure-triggering) test programs and non-error-causing test programs) as the auxiliary classification target, because identifying whether a test program triggers a failure is easier than determining the exact reason why the program triggered the test failure.
[0036] 1.1. Construct a fine-tuning dataset; set four types of mutation rules for non-fault-causing test program generation, including (1) identifier-level mutation rules, such as changing an identifier to a constant, (2) operator-level mutation rules, such as changing an operator to its opposite, (3) delimiter-level mutation rules, such as deleting a pair of braces, and (4) statement-level mutation rules, such as deleting one or more statements in a program through delta-debugging. Based on these mutation rules, the present invention performs first-order mutation on each defect-triggering test program to ensure that it is slightly different from the defect-free test program.
[0037] Algorithm 1: Test program generation for fine-tuning
[0038]
[0039]
[0040] Algorithm 1 shows the detailed steps for constructing a dataset for the fine-tuning task of a given faulty test program. Specifically, given a mutation rule r and a test program FP that triggers a bug, all applicable mutation locations in the faulty program (referred to as L(r)) are identified (Line 2). Then, for each location l in L(r), r is applied to l to construct a mutated test program (Line 5). If the program is a non-faulty test program (i.e., it does not trigger the compiler bug under the test oracle used by the faulty program), it is saved (Line 7); otherwise, it is discarded and the next location is processed. To address data imbalance and ensure the diversity of non-faulty test programs, a strategy of upsampling the given faulty test programs and downsampling the non-faulty test programs is adopted. Specifically, for each faulty test program, m replicas are upsampled (Line 11), and m / |R| test programs are randomly adopted from the non-faulty test programs generated by each mutation rule (Line 14), where |R| represents the number of mutation rules.
[0041] Figure 3This example shows the construction process of this test program. (a) is a minimally faulty test program, and (c) is a non-faulty test program constructed through the mutation process described above. In this example, the bug triggering is related to the cross-assignment of variables. After deleting this part, the mutated test program will not trigger the compiler bug. (b) is also a minimally faulty program, and (d) is a non-faulty test program constructed through the mutation process described above. In this example, the bug triggering is related to the assignment of addresses related to different code blocks. By breaking the semantics of this part, the mutated test program is a non-faulty program.
[0042] 1.2. Auxiliary classification task fitting; the auxiliary classification task consists of a code representation model and a classifier, which contains semantic information related to the defect trigger label in the test program. This is the core of BLADE to extract semantic information related to the defect for repeated defect identification. Next, we introduce the pre-trained code representation model and the designed classifier used in the present invention. The present invention uses three representation models and verifies their impact. Specifically, UniXCoder and CodeBERT are based on the Transformer architecture, where CodeBERT is pre-trained with code vocabulary information, while UniXCoder is pre-trained with code vocabulary information and code syntax information through abstract syntax tree (AST) analysis. InferCode is an AST-based self-supervised pre-training model based on the TBCNN structure, which takes AST subtree prediction as a training task.
[0043] In order to achieve the auxiliary classification task of classifying error-causing test programs and non-error-causing test programs, the present invention connects the multi-layer perceptron classification task with the pre-trained code representation model as a classification neural network. This classifier is based on a multi-layer perceptron and follows the general practice of using classification tasks for fine-tuning. Specifically, it consists of two fully connected hidden layers and uses the Softmax function for classification. The tanh activation function is used between the two layers, which helps to introduce nonlinearity in the classification network, thereby promoting the learning of more complex features. The cross-upper loss function is used for fine-tuning. Based on the adopted pre-trained code representation model and the designed classifier, the present invention starts the fitting process based on balanced fine-tuning data.
[0044] 2. Error semantic information extraction: In step 1, error semantic learning, this invention has already completed the modeling of the error semantic understanding task using the pre-trained code representation model through the auxiliary classification task. In this step, the task designs a model interpretation method to capture the error semantics learned by the model from the difficult-to-interpret neural network. This vectorized representation of the error semantics will be used in the final repeated defect identification task.
[0045] y=Σ_(k=1)^n w_k·x_k+b_k (1)
[0046]
[0047] v=Σ_(k=1)^n|x_k·g_k|=Σ_(k=1)^n|x_k·w_k|=|x|⊙|w| (3)
[0048] 2.1. Error semantic vectorization; For deep neural network (DNN) models, the ability to capture information about model behavior (especially the decision reasoning behind it) becomes more accurate as the number of layers increases. That is, the deeper layers in the fine-tuned model have a higher ability to reflect the implicit causal relationship between the error-causing test program and its error label. Therefore, semantic information related to test failure is extracted from the last layer of the model (for convenience, it is represented by F_(-1)(x)). The present invention uses the gradient-based contribution analysis idea to evaluate the contribution of each dimension of the input vector to the classification result (i.e., triggering the failure label). The gradient indicates how a small change in a specific input dimension affects the output of the model. By analyzing these gradients, it is possible to determine which input dimensions have the greatest impact on the model's prediction, thereby gaining a deeper understanding of the basic principles behind its decision-making. Specifically, as shown in formulas (1), (2), and (3), the gradient vector of the input vector of the last layer of the relevant model is calculated. Formula 1 represents the forward propagation calculation of the last layer F_(-1)(x) of the model, where x_k is the k-th dimension element of the input vector, w_k is the corresponding weight, b_k represents the bias, and yy represents the output. Then, the contribution of x_k (denoted as g_k) is measured by Formula 2. The gradient vector corresponds to the input vector in terms of dimension, indicating that they have a one-to-one correspondence of dimensions. The larger the gradient in each dimension, the more relevant the dimension of the input vector is to the decision-making process of the model, which indicates that the dimension is more relevant to the label that triggers the defect. Then, as shown in Formula (3), the present invention calculates the Hadamard product of the input vector and its corresponding gradient vector to represent the defect-related semantic information of the test program that triggers the defect (as a semantic vector).
[0049] In this way, the extraction of defect-related semantic information from the test program that triggers the defect runs through the code representation model and the classifier, which is consistent with the established (implicit) causal relationship from the test program to its label of the triggered defect.
[0050] d_manhattan(p_i,p_j)=Σ_(k=1)^n|v_(i,k)-v_(j,k)| (4)
[0051] 3. Error test program sorting
[0052] 3.1. Calculation of fault-causing distance; After obtaining the semantic vectors representing the defect-related semantic information of each test program that triggers the defect, the present invention uses these vectors to estimate whether the test failure corresponds to the same defect. Intuitively speaking, if two defect-triggering programs have similar defect-related semantic information, indicating that they have similar (implicit) causal relationships with the triggering of their corresponding test failures, then they are likely to be duplicates. On the contrary, the greater the distance between them, the more likely they are to trigger different defects. Given two test programs that trigger defects, denoted as p_i and p_j, respectively, and their corresponding semantic vectors as v_i and v_j, respectively, the present invention then calculates the Manhattan distance between v_i and v_j, as shown in Formula 4. Wherein, k represents the kth element in each semantic vector.
[0053] 3.2. The present invention then prioritizes the set of fault-causing test programs as the output of duplicate defect identification. This follows existing work on duplicate defect identification in compilers because the duplicate defect identification problem is usually solved by formulating it as a priority sorting problem. Specifically, test programs that are more likely to trigger different defects should have higher priorities. Following existing work, the present invention adopts the farthest point first (FPF) algorithm for priority sorting, which is based on the distance between each pair of test programs calculated by formula (4). It iteratively selects the test program that triggers the defect with the farthest distance from the prioritized test programs as the next test program in the priority list.
[0054] 4. Promote the present invention to a general framework; The present invention can be promoted to a general framework to extract defect-related features from various information (e.g., test coverage information used by white-box techniques), thereby more effectively identifying duplicate defects. The framework referred to in the present invention generally includes two stages: (1) performing auxiliary classification task fitting to establish an (implicit) causal relationship from the test program to its defect trigger label based on a given type of information; (2) extracting defect-related information from the given type of information as a vector to perform more accurate prioritization / duplicate defect identification based on model interpretation. Under this framework, we can design classifier structures and interpretation methods based on the features of the given type of information used for duplicate defect identification. Next, we use test coverage information as an example to illustrate that extracting defect-related information from general test coverage through the framework referred to in the present invention can help improve the effectiveness of coverage-based duplicate defect identification. We call this variant of duplicate defect identification based on white-box coverage BLADE_cov, and the framework of this variant is derived from the present invention (also referred to as BLADE in this article). Test coverage information has been proven to be effective for white-box duplicate defect identification. These white-box coverage-based techniques record the frequency of coverage of each compiler source code element in each defect-triggering test program to identify recurring defects. In other words, test coverage information is represented as a list of values. Due to significant differences between test coverage information and the test program information used in this invention, it is not possible to use a pre-trained code representation model and a multi-layer perceptron (MLP) classifier for the former. Due to the characteristics of test coverage information (a type of tabular information), BLADE_cov can employ traditional machine learning algorithms for auxiliary classification tasks. In our work, BLADE_cov uses random forests as a representative empirical study due to its high efficiency and proven effectiveness. Future studies could investigate the impact of different machine learning algorithms, but this is not the primary objective of this study. The data used for auxiliary classification fits includes test coverage collected from both defect-triggering and defect-free test program executions. BLADE_cov then uses the contribution analysis method built into random forests (i.e., mean decrease in Gini impurity) to measure the contribution of each code element in the test coverage information of the defect-triggering test program to the classification result (i.e., the defect-triggering label). Code elements with larger contribution scores are more relevant to the label that triggered the defect. BLADE_cov extracts the coverage information of the first k code elements as the defect-related test coverage information for the test failure, and represents each test failure as a k-dimensional vector. The Manhattan distance is then calculated between each pair of test failures. This distance is used for subsequent prioritization based on the farthest distance first algorithm described in the previous section.In our study, we also investigate the effectiveness of BLADE_cov and existing white-box coverage-based duplicate defect identification techniques to demonstrate the general effectiveness of the framework refined from this invention in compiler duplicate defect identification, which is able to extract more defect-related information from given general information.
[0055] The present invention ultimately achieves excellent results in identifying 82 real recurring defects in two widely used compilers, GCC and LLVM.
[0056] The verification results of the present invention are as follows:
[0057] Tables 1 and 2 show the comparison of the effects of BLADE of the present invention with two black-box technologies and two white-box technologies. Trans is a black-box repeated defect identification technology originally designed for repeated defect identification of repeated defects detected by transformation-based compiler testing. Tamer is a white-box repeated defect identification technology that records the number of times each compiler function is executed by each fault-causing program. It then calculates the distance between each pair of test failures based on the test coverage information. D^3 is a state-of-the-art white-box technology that uses three-dimensional information for repeated defect identification. It represents the information of each dimension as a vector for each test failure, and then performs repeated defect identification by integrating the vectors from the three-dimensional information. D^3 has a variant, a black-box technology, which only uses one-dimensional information (i.e., the test program information that triggers the compiler defect) for repeated defect identification. As shown in Table 1. The five columns of BLADE, Trans, D_prog^3, D^3, and Tamer of the present invention respectively represent the number of test failures that need to be checked when the corresponding non-repeating defects are found, and the remaining four columns show the improvement ratio of the present invention to Trans, D_prog^3, D^3, and Tamer. It can be seen that BLADE outperforms the black-box techniques Trans and D_prog^3, and reaches or even exceeds the performance of the white-box techniques D^3 and Tamer. Furthermore, the method was tested on the widely used RAUC metric. The specific results are shown in Table 2, showing that the proposed technique still outperforms existing techniques on this RAUC metric. Furthermore, we compared several BLADE variants. To explore the necessity of fine-tuning pre-trained code representation models using classification tasks, we constructed a BLADE variant, called BLADE_pre, that directly uses the pre-trained model to obtain semantic representations for recurring defect identification. We then examined the effectiveness of different pre-trained code representation models in BLADE. Specifically, we replaced the default pre-trained model (i.e., UniXCoder) in BLADE with CodeBERT and InferCode, respectively, to construct two BLADE variants. We refer to them as BLADE_CB and BLADE_IC, respectively. Furthermore, we examined the contribution of mutation-based defect-free data collection and, as a result, constructed a BLADE variant that uses the corresponding compiler's test suite as fine-tuning data with non-error-causing labels. We call it BLADE_ts. We study the contribution of the extraction strategy by building two variants of BLADE, namely BLADE_ll and BLADE_cr.Unlike BLADE (which calculates the Hadamard product of the input vector of the last layer and its corresponding gradient vector), BLADE_ll does not calculate the gradient vector, but directly uses the input vector of the last layer to obtain the semantic representation; while BLADE_cr replaces the input vector of the last layer with the input vector of the penultimate layer in BLADE (i.e., the output of the fine-tuned code representation model) to perform semantic representation. The comparison results of these variants with BLADE are shown in Table 3. It can be seen that these variants of BLADE have failed to achieve better results, proving that the settings of each stage of BLADE are reasonable. After elevating the present invention to a framework, we used test coverage as input to test its coverage effect compared with other white-box methods. As shown in Table 4, it can be seen that the error-causing feature extraction of the present invention and its use in repeated defect identification is better than other white-box methods. Based on the effectiveness of BLADE (the present invention) and BLADE_cov (a white-box variant of the elevated framework of the present invention), we further studied the effectiveness of combining them. Given that existing research has demonstrated the effectiveness of integrating black-box and white-box information (using D3), we also integrated BLADE and BLADE_cov following the strategy used in D^3 (calculating the distance between each type of information and the semantic vector and then calculating their weighted sum for priority ranking). Across all five datasets, the average workload of BLADE and BLADE_cov after integration increased by 2.1% and 13.6%, respectively.
[0058] As shown in Table 1, the repeated defect recognition effects of the present invention and the existing method are compared (GCC-4.3.0).
[0059] Table 1
[0060]
[0061] As shown in Table 2, the comparison of the repeated defect recognition effect (RAUC) of the present invention and the existing method is shown.
[0062] Table 2
[0063]
[0064] As shown in Table 3, some variants of the present invention were unable to achieve an effect superior to that of BLADE.
[0065] Table 3
[0066]
[0067] As shown in Table 4, the comparison of repeated defect recognition effects (RAUC) between the proposed framework and other white-box methods.
[0068] Table 4
[0069]
[0070] Although the duplicate defect identification process is performed offline, the time cost of each technique (from data collection for each test failure to generating prioritized results) is discussed to facilitate a thorough comparison. The time cost of each duplicate defect identification technique increases with the number of test failures with duplicate defects. Therefore, we measured the average per-test failure time cost across all test failures in all datasets for comparison. To better understand the time cost of each technique, we performed measurements in single-process and single-GPU scenarios. Specifically, the average time costs for BLADE, Trans, D_prog^3, Tamer, and D^3 were 34.1 seconds, 8.3 seconds, 27.4 seconds, 47.6 seconds, and 93.5 seconds, respectively. The overhead of each technique is acceptable, especially when compared to the extensive manual effort required for subsequent defect diagnosis. Furthermore, in practice, the offline process can be accelerated by parallelizing model fitting using multiple GPUs. Considering both the effectiveness of deduplication and the time cost, BLADE is indeed more cost-effective than existing techniques.
[0071] Manhattan distance is used in the test program prioritization component of the present invention, but the present invention does not only use Manhattan distance. In this paper, we conducted an experiment using the GCC-4.3.0 dataset as a representative to test the effectiveness of BLADE using different distance metrics (including three widely studied metrics - Manhattan distance, Euclidean distance and cosine distance). Using these metrics, the RAUC-100% values of BLADE are 96.12%, 95.91% and 95.76% respectively. The Wilcoxon signed rank test confirmed that there is no significant difference between them, although the performance of Manhattan distance is slightly better. In fact, this is also the reason why the present invention chooses Manhattan distance.
[0072] We further conducted a case analysis to demonstrate the effectiveness of the present invention's acquired defect-related semantic information, which serves as the foundation for the present invention's successful identification of recurring defects. Drawing on existing attention-based interpretation work, we used the attention mechanism to understand the defect-related semantic information of the test program that triggered the defect. The attention mechanism is commonly used to measure the contribution of each program element to the results in deep learning (code-related) tasks. Inspired by contribution transfer, we measured the incremental attention score of each program element after auxiliary classification fitting. This incremental score indicates that its contribution to capturing causal relationships (indicating defect-related semantic information) was enhanced during the fitting process. Specifically, we collected the top five program elements with the highest incremental attention scores as defect-related features for analysis. It is important to note that recurring defect identification is not achieved solely due to the presence of these highlighted elements, but rather based on their specific usage (indicating semantics). This type of semantics can be learned through deep learning in the present invention, but cannot be interpreted through the attention mechanism. In other words, due to the limitations of the attention mechanism, we can only highlight a subset of program elements for analysis. Figure 3 The test programs shown in (a) and (b) trigger different defects. The five program elements (i.e., defect-related features) with the largest attention increments identified for them (marked as highlighted) do differ. Specifically, Figure 3 The defect-related features identified in a involve structure definition, initialization, and assignment, which to a large extent indeed indicates the triggering defect semantics of assignment operations between structure variables. Figure 3 The defect-related features identified in (b) involve address assignments and variable definitions, which largely align with the semantics of a defect triggering an address assignment between variables defined in different scopes. This allows the present invention to correctly distinguish between the two defects. This demonstrates that the present invention can effectively extract defect-related semantic information through intermediate representation learning and model interpretation, thereby achieving more accurate duplicate defect identification.
[0073] Those skilled in the art will understand that the accompanying drawings are only a schematic diagram of a preferred embodiment, and the serial numbers of the embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0074] Furthermore, the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention.
[0075] The idea of the present invention is highly versatile and has been extended to a broader framework. It is capable of identifying defect-related features from various types of information. As more features are identified in the future, they can be seamlessly integrated into the framework to further enhance its effectiveness. In addition, although the present invention is implemented for compiler repetitive defect recognition, the idea is also applicable to other software that takes programs as input, such as databases and browsers. Specifically, the condition for applying the present invention is to have a model that can effectively embed test semantics. The present invention has proved that some code representation models can effectively embed program semantics.
[0076] Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention, such as replacing the tools used for program mutation: using other program analysis / mutation methods to construct non-error-causing test cases; replacing the upstream pre-training model for preliminary encoding of program features; using contrastive learning or other structures for binary classification tasks to fit positive and negative samples; replacing the error-causing semantic extraction method, etc., should be included in the scope of protection of the present invention.
Claims
1. A compiler repetitive defect identification method based on deep semantic representation, characterized by: The method comprises the following steps: S1. Fine-tune the pre-trained code representation model using auxiliary classification tasks and use intermediate representation learning to learn error-causing semantic information related to test failures. S2. Extracting an error-causing semantic representation vector from the fine-tuned pre-trained code representation model; S3. Calculate the distance between each fault-causing program using the fault semantic representation vector to obtain a fault distance matrix between the fault-causing programs; prioritize the fault-causing programs based on the fault distance matrix, and prioritize access to compiler defects at the farthest locations to achieve duplicate defect identification in compiler code.
2. The method for identifying compiler duplication defects based on deep semantic representation according to claim 1, characterized in that: The pre-trained code representation model in S1 is an encoder model that represents the code as an embedding vector.
3. The compiler repetitive defect identification method based on deep semantic representation according to claim 1, characterized in that: S2 includes re-inputting the error-causing test program into the fitted classification task to fine-tune the pre-trained code representation model, and using the deep learning interpretation algorithm to extract the input of the last linear layer and perform the Hadamard product with the gradient as the error-causing semantic representation vector.
4. The method for identifying compiler duplication defects based on deep semantic representation according to claim 1, characterized in that: The method of fine-tuning the pre-trained code representation model using the auxiliary classification task described in S1 includes constructing a fine-tuning dataset and setting four types of mutation rules for generating non-error-causing test programs. The mutation rules include (1) identifier-level mutation rules, (2) operator-level mutation rules, (3) separator-level mutation rules, and (4) statement-level mutation rules.
5. The method for identifying compiler duplication defects based on deep semantic representation according to claim 1, characterized in that: S3 further includes iteratively selecting a test program that triggers a defect the furthest away from the prioritized test programs as the next test program in the priority list.
6. The method for identifying compiler duplication defects based on deep semantic representation according to claim 1, characterized in that: In S3, the distance between each fault-causing program is calculated using the fault semantic representation vector, including using the farthest point first algorithm to prioritize the fault-causing programs based on the fault distance matrix, where test failures caused by triggering different compiler defects are ranked in a higher order, and test failures caused by the same compiler defect are ranked in a lower order.