A domain-sensitive program slicing method based on high-order access paths
Through the method of higher-order access paths and function summary, the problem of complexity and overhead of program slicing algorithms in the prior art is solved, efficient and accurate domain-sensitive program analysis is achieved, and the efficiency and accuracy of program slicing is improved.
Patent Information
- Application Number
- CN202411273560.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-09-12
AI Technical Summary
The existing program slicing algorithm is based on the accessibility algorithm of dependency graphs to build huge PDGs or SDGs, which makes the graph complex and overhead difficult to achieve high-precision domain-sensitive analysis.
Using higher-order access paths instead of the extension of the graph, using higher-order function summary for interprocess information transmission, reducing composition overhead and improving dependency computing efficiency, and processing functions, function summary and pointing sets as mapping relationships.
It improves the efficiency and accuracy of program slices, avoids high-cost composition and graph expansion in conventional methods, and realizes more efficient domain-sensitive program analysis.
Smart Images

Figure CN118796712B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of functional programming and program analysis, and in particular to an efficient domain-sensitive program slicing method based on access paths. Background Art
[0002] With the rapid development of the Internet, the scale and complexity of software are increasing, so the cost of software maintenance is becoming more and more important. In order to solve this problem, it is necessary to identify the overall structure of the code and extract the key content. Program slicing is a recognition and extraction technology for program analysis. According to the given slicing criteria, the statements in the source code that affect the slicing criteria are extracted. Program slicing technology has a wide range of applications and a very important position in software testing, maintenance and program optimization.
[0003] Most of the slicing algorithms currently used are reachability algorithms based on dependency graphs, which require the construction of huge PDG or SDG. If more precise domain sensitivity is required, further expansion is required based on PDG or SDG. The graph construction will be more complicated and the overhead will increase significantly.
[0004] The present invention uses a high-order access path to replace the expansion of the graph, and uses a high-order function summary to transfer information between processes, thereby reducing the overhead required for graph construction and improving the efficiency of inter-process dependency calculation.
[0005] A higher-order function is a function that takes other functions as parameters or returns a function as a result. It is one of the most important features of functional programming languages and can bring high flexibility when developing functions. The idea of higher-order functions helps to write more refined code because the definition is concise and the data transfer efficiency is high, which can improve the efficiency of function-level program analysis. Making the function summary higher-order allows functions, function summaries, and pointer sets to be used as function inputs and outputs. During the analysis process, each function is first analyzed intra-procedurally to obtain its function summary. When a function call occurs, the function summary of the called function is used as part of the original function input. Similarly, the function output obtained in this way can also continue to be used as the input of another function when the function is called, making inter-procedural analysis more efficient and able to transmit more information. Summary of the invention
[0006] The present invention aims to provide an efficient domain-sensitive program slicing method based on access paths, which represents composite data structures in the form of access paths and uses the high-order function characteristics in functional programming to save dependency information related to the composite data structures, thereby improving the efficiency of program slicing.
[0007] To achieve the above-mentioned object of the invention, the present invention provides a domain-sensitive program slicing method based on a high-order access path, which comprises the following steps:
[0008] Step 1: Preprocess the source program; convert the C language code source program into the intermediate representation LLVM IR, determine the correspondence between the variables in the C language code source program and the variables in LLVM IR, and convert the source program variables , variables in LLVM IR (last evaluation point) and access path Form a triple , get the access path set;
[0009] Step 2: Slice the LLVM IR corresponding to the source program; update each variable in the LLVM IR as needed according to the memory operation instructions in the LLVM IR Corresponding access path , update the slice result according to the operation instruction. During the traversal process, each time the analysis of a process is completed, the corresponding high-order function summary will be generated to pass the access path information of the variable for use in the analysis of other processes;
[0010] Step 3: Map the LLVM IR slicing results to the source program; based on the slices on the LLVM IR obtained in step 2, the domain-sensitive slicing results of the source program are obtained according to the correspondence between the variables in the source program and the variables in the LLVM IR determined in step 1.
[0011] As a further improvement of the present invention, the step 1 preprocesses the source program, and the specific steps include:
[0012] Step 1.1: Convert the C language code source program into LLVM IR to obtain a mapping list;
[0013] Step 1.2: Extract each base variable in the source program, identify its corresponding variable set in LLVM IR, and obtain the access path table;
[0014] Step 1.3: Identify all structure variables defined in the source program and store their information in the mapping set;
[0015] Step 1.4: Construct the function call graph CG and the control flow graph CFG of each function, and then determine the analysis order according to the weak topological order.
[0016] As a further improvement of the present invention, the step 2 slices the LLVM IR corresponding to the source program, and the specific steps include:
[0017] Step 2.1: Initialize the access path of each variable in the LLVM IR. Initialize the access path of the variable in the mapping list to its corresponding variable name in the source program, otherwise initialize it to ;
[0018] Step 2.2: For a given slicing criterion, traverse from the program entry to the slicing criterion. If a memory operation instruction store, load, or getelementptr is encountered, update the access path according to the corresponding rule;
[0019] Step 2.3: Calculate the intra-procedure slice, initialize the control dependency table and the data dependency table, and then update the two dependency sets in the statement analysis order, and update them accordingly according to whether the variable is a base variable or a domain variable, and whether it is a single value or a multi-value. Finally, get the high-order function summary of the procedure, which stores the access path information of the domain variables.
[0020] Step 2.4: Calculate the interprocedural slice when a function call statement is encountered ,The inter-procedural analysis is performed through the function summary obtained in step 2.3. The anonymous function in the function summary expresses the relationship between the variables and their access paths, thus the inter-procedural domain-sensitive program slices are obtained.
[0021] As a further improvement of the present invention, in step 2.1, each variable in LLVM IR There is a corresponding It is expressed in the form of ;in is the base variable in the source program, is an access expression of the form ,in is the domain access identifier, which indicates the form of field access at each layer in the access path. It is divided into access_derefence, access_array and access_structure, which represent pointer dereference, array access and structure access respectively. First, each variable of Initialized to the corresponding source program base variable or , update the access path table to .
[0022] As a further improvement of the present invention, in step 2.2, for the instruction store, the update rule is as follows:
[0023] ;
[0024] Among them, store %x, %y represents an assignment statement, which assigns the value of %y to %x. The corresponding update operation is to update the access path of variable %x. Updated to ;
[0025] For instruction load, the update rules are as follows:
[0026] ;
[0027] Among them, %x = load %y represents a memory read statement, which reads the value in %y and assigns it to %x. The corresponding update operation is to change the access path of variable %x to Updated to ;
[0028] For the instruction getelementptr, the update rules are as follows:
[0029] ;
[0030] Among them, the getelementptr instruction is used to calculate the address of the structure or array element. Indicates the offset of the address, each offset corresponds to a domain access identifier , Indicates the domain access identifier calculated based on the offset value and the type of field access. The + operator indicates the concatenation operation of the access path, that is, the corresponding , that is, for the getelementptr instruction, the calculated access path is assigned to .
[0031] As a further improvement of the present invention, the step 2.3 is specifically as follows: calculating the instruction dependency set and variable dependency sets ; First initialize the dependency set and set the instruction dependency set to the instruction itself, ; At the same time, according to the different types of variables: global variables, formal parameters and local variables, the variable dependency set is initialized accordingly according to the following formula,
[0032] ;
[0033] in, Represents a set of global variables for all processes, Represents the set of formal parameters in process P; during the instruction traversal process, the instruction dependency set is continuously updated. , that is, each dependency set update will add and Two parts, corresponding to control dependency and data dependency, respectively. Indications and instructions There is a set of statements that control dependencies. Indicates in the instruction The set of variables defined or used in Indicates that Take the union of the instruction dependency sets of all statements in, Indicates that Take the union of the variable dependency sets of all statements in;
[0034] The update rules for the variable dependency set are as follows:
[0035] .
[0036] As a further improvement of the present invention, in step 2.4, the function summary form is as follows:
[0037] ;
[0038] Representation function The corresponding function summary for In terms of function The summary includes the function return value The corresponding backward slice set , and the relationship between the access paths corresponding to the input variables and the function return values, which is saved in the form of anonymous functions, where Represents an input , the output is Anonymous function of ; is the input variable, The access path corresponding to the function return value; this anonymous function is used to partially replace the content in the access expression to obtain a more accurate representation;
[0039] Get the value in step 2.4 The operation rules of the statement are as follows:
[0040] ;
[0041] in, For the update function of the access path table, the variable Corresponding access path Updated to .
[0042] As a further improvement of the present invention, the step 3 maps the LLVM IR slicing result to the source program, and the specific steps include:
[0043] Step 3.1: According to the mapping list obtained in the preprocessing stage, all variables in the slicing result of LLVM IR are returned to the source program to obtain the slice table for the source program;
[0044] Step 3.2: For statements in the source program, if all variables in a statement exist in the slice table, add the statement to the slice result; in domain-insensitive program slicing, the slice result is in rows. For domain-sensitive slicing, the granularity of the slice is increased from rows to variables; when a complete structure appears in a statement, and some of its fields are in the slice table and some are not in the slice table, a non-executable slice is generated, and the fields that are not in the slice table are replaced by the placeholder "_" in the slice result, indicating that the part is not in the slice result; finally, the slice result of the source program is obtained.
[0045] Beneficial effects: The present invention is based on a domain-sensitive program slicing method of a high-order access path, which converts the source program into LLVM IR for analysis, and obtains a variable mapping list between the source program and LLVM IR. The access path is used to accurately represent the fields in the domain, avoiding the conventional costly method of graph composition and graph expansion. At the same time, where function calls are involved, the analysis results of the sub-process are represented using a high-order function summary, which can more efficiently return more information to the main program to update the access path table. Finally, the slicing results on the LLVM IR are returned to the source program through the mapping list, which generally improves the accuracy and efficiency of domain-sensitive program slicing. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flow chart of the domain-sensitive program slicing method based on access path provided by the present invention.
[0047] Figure 2 This is an overall flow chart of the access path-based domain-sensitive program slicing method provided by the present invention. DETAILED DESCRIPTION
[0048] The present invention will be further described below in conjunction with the accompanying drawings.
[0049] like Figure 1-2 The domain-sensitive program slicing method based on access path shown includes the following steps:
[0050] Step 1: Preprocess the source program, convert the C language code source program into LLVM IR, determine the correspondence between the variables in the source code and the variables in LLVM IR, and generate a function call graph and a control flow graph for each function to obtain structural information;
[0051] Step 2: Update the access path ap(v) of each variable v in LLVM IR according to the memory operation instructions of LLVM IR, and then slice the specific slicing criteria according to the obtained access path, and obtain the specified function analysis order for on-demand analysis. Analyze from the function entry until the statement where the slicing criterion is located is analyzed, and the function summary of the function for this slicing criterion is obtained, and the access path information is stored in the function summary in a high-order form. Then recursively analyze the dependencies in the calling function until the end.
[0052] Step 3: Based on the slices on the LLVM IR obtained in step 2, the domain-sensitive slicing result of the source program is obtained according to the correspondence between the source program variables determined in step 1 and the variables in the LLVM IR.
[0053] In this embodiment, the selected program code is as follows:
[0054] #include<stdio.h>
[0055] #include<stdlib.h>
[0056] int add(int m, int n);
[0057] struct S {
[0058] int a;
[0059] int b;
[0060] };
[0061] int main()
[0062] {
[0063] int x = 5, y = 10;
[0064] int m,n,t;
[0065] struct S s1={x,y};
[0066] struct S s2={1,s1.a};
[0067] m = s2.a;
[0068] n = s2.b;
[0069] t = add(m,n);
[0070] printf("%d",t);
[0071] return(0);
[0072] }
[0073] int add(int m, int n){
[0074] return m + n;
[0075] }
[0076] The step 1 specifically includes:
[0077] Step 1.1: Convert the C language source code into LLVM IR format;
[0078] In this embodiment, the LLVM IR corresponding to the main function is as follows:
[0079] define dso_local i32 @main() #0 {
[0080] %1 = alloca i32, align 4
[0081] %2 = alloca i32, align 4
[0082] %3 = alloca i32, align 4
[0083] %4 = alloca i32, align 4
[0084] %5 = alloca i32, align 4
[0085] %6 = alloca i32, align 4
[0086] %7 = alloca %struct.S, align 4
[0087] %8 = alloca %struct.S, align 4
[0088] store i32 0, ptr %1, align 4
[0089] store i32 5, ptr %2, align 4
[0090] store i32 10, ptr %3, align 4
[0091] %9 = getelementptr inbounds %struct.S, ptr %7, i32 0, i32 0
[0092] %10 = load i32, ptr %2, align 4
[0093] store i32 %10, ptr %9, align 4
[0094] %11 = getelementptr inbounds %struct.S, ptr %7, i32 0, i32 1
[0095] %12 = load i32, ptr %3, align 4
[0096] store i32 %12, ptr %11, align 4
[0097] %13 = getelementptr inbounds %struct.S, ptr %8, i32 0, i32 0
[0098] store i32 1, ptr %13, align 4
[0099] %14 = getelementptr inbounds %struct.S, ptr %8, i32 0, i32 1
[0100] %15 = getelementptr inbounds %struct.S, ptr %7, i32 0, i32 0
[0101] %16 = load i32, ptr %15, align 4
[0102] store i32 %16, ptr %14, align 4
[0103] %17 = getelementptr inbounds %struct.S, ptr %8, i32 0, i32 0
[0104] %18 = load i32, ptr %17, align 4
[0105] store i32 %18, ptr %4, align 4
[0106] %19 = getelementptr inbounds %struct.S, ptr %8, i32 0, i32 1
[0107] %20 = load i32, ptr %19, align 4
[0108] store i32 %20, ptr %5, align 4
[0109] %21 = load i32, ptr %5, align 4
[0110] %22 = load i32, ptr %4, align 4
[0111] %23 = call i32 @add(i32 noundef %22, i32 noundef %21)
[0112] store i32 %23, ptr %6, align 4
[0113] %24 = load i32, ptr %6, align 4
[0114] %25 = call i32 (ptr,...) @printf(ptr noundef @"??_C@_02DPKJAMEF@?$CFd?$AA@", i32 noundef %24)
[0115] ret i32 0
[0116] }
[0117] In this embodiment, the LLVM IR corresponding to the add function is as follows:
[0118] define dso_local i32 @add(i32 noundef %0, i32 noundef %1) #0 {
[0119] %3 = alloca i32, align 4
[0120] %4 = alloca i32, align 4
[0121] store i32 %1, ptr %3, align 4
[0122] store i32 %0, ptr %4, align 4
[0123] %5 = load i32, ptr %4, align 4
[0124] %6 = load i32, ptr %3, align 4
[0125] %7 = add nsw i32 %5, %6
[0126] ret i32 %7
[0127] }
[0128] Step 1.2: Extract each base variable x in the source program and obtain the set V(x) of all its corresponding variables in LLVM IR.
[0129] In this embodiment, the mapping list is as follows:
[0130]
[0131] The first element of the tuple is the variable name, and the second element is the line number of the variable in the source program or LLVM IR. A variable in the source program may correspond to multiple versions in LLVM IR.
[0132] Step 1.3: Identify all structure variables defined in the program and obtain a mapping set of variable names and their member variables.
[0133] In this embodiment, the obtained mapping set is .
[0134] Step 1.4: Construct the function call graph of the C program and the control flow graph corresponding to each function, and determine the reverse topological order as the program analysis order.
[0135] The step 2 specifically includes:
[0136] Step 2.1: Initialize the access path ap(v) of each variable v in LLVM IR to its corresponding source program base variable x. If there is no corresponding source program base variable (i.e., it corresponds to a field in the source program), initialize ap(v) to null.
[0137] In this embodiment, according to the mapping list obtained in step 1.2, we can obtain ap(%2) = x, ap(%3) = y, ap(%7) = s1, and the access path values of the variables that do not appear in the second column of the list in the LLVM IR will be initialized to null and will be updated as needed in subsequent steps.
[0138] Step 2.2: Start traversing from the program entry point. If it is a memory operation instruction (store, load, and getelementptr), update the access path according to the corresponding rules.
[0139] In lines 13-15 of the LLVM IR in this example,
[0140] %9 = getelementptr inbounds %struct.S, ptr %7, i32 0, i32 0
[0141] %10 = load i32, ptr %2, align 4
[0142] store i32 %10, ptr %9, align 4
[0143] Since ap(%7) = s1, when executing "%9 = getelementptr inbounds %struct.S, ptr%7, i32 0, i32 0", we can get ap(%9)=s1.access_structure!0, which is instantiated as ap(%9)=s1.a. The load instruction in the statement "%10 = load i32, ptr %2, align 4" on line 14 will make ap(%10)=ap(%2). Similarly, the store instruction on line 15 will make ap(%9)=ap(%10). Field variables in LLVM IR can be distinguished from each other due to atomicity. However, even though the getelementptr instruction can identify different fields by offset address, this method is essentially based on domains. In order to achieve domain sensitivity, it needs to be further explained through the domain identifier fd. This traversal will match the variables in LLVM IR with the corresponding access paths in the source program one by one.
[0144] Step 2.3: Calculate the slice within the process: Update the control dependency table and the variable dependency table.
[0145] In this example, assuming that the slicing criterion is (n, 18), the statement "store i32 %20 ptr %5, align 4" on line 20 will be executed when %5 is already In this case, add %20 to the slice table.
[0146] Step 2.4: Compute the sub-procedural function summary for inter-procedural slice computation.
[0147] In this example, the main program calls the add function in line 19. It is necessary to analyze the add function separately and return the function summary to the main function. In the domain-insensitive analysis method, for the call statement "t = add(m, n)", m, n and t are all considered as a whole (or base variable), and only the dependency relationship between t and m and n can be obtained. More information cannot be transmitted in the function summary. In this example, the function summary can be obtained .
[0148] The step 3 specifically includes:
[0149] Step 3.1: According to the mapping list obtained in the preprocessing stage, all variables in the slicing result of LLVM IR are returned to the source program to obtain the slice table for the source program.
[0150] In this embodiment, assuming that the slicing criterion is (t, 19), the slicing table finally converted is {(t, 19), (n, 18), (m, 17), (s1.a, 16), (x, 15), (x, 13)}.
[0151] Step 3.2: For statements in the source program, if all variables in a statement exist in the slice table, add the statement to the slice result. In domain-insensitive program slicing, the slice result is often in lines, but for domain-sensitive slicing, this is not accurate enough, and the granularity of the slice must be increased from lines to variables. When a complete structure appears in a statement, and some of its fields are in the slice table and some are not in the slice table, a non-executable slice is generated, and the fields that are not in the slice table are replaced with "_" in the slice result. Finally, the slice result of the source code is obtained.
[0152] In this embodiment, assuming that the slicing criterion is (t, 19), the final slicing result is
[0153] int x = 5, _;
[0154] int m,n,t;
[0155] struct S s1={x,_};
[0156] struct S s2={1,s1.a};
[0157] m = s2.a;
[0158] n = s2.b;
[0159] t = add(m,n).
[0160] The present invention is based on a domain-sensitive program slicing method of a high-order access path, converts the source program into LLVM IR for analysis, and obtains a variable mapping list between the source program and LLVM IR. The access path is used to accurately represent the fields in the domain, avoiding the conventional costly method of graph composition and graph expansion. At the same time, where function calls are involved, the analysis results of the sub-process are represented using a high-order function summary, which can more efficiently return more information to the main program to update the access path table. Finally, the slicing results on the LLVM IR are returned to the source program through the mapping list, which generally improves the accuracy and efficiency of domain-sensitive program slicing.
[0161] The technical means disclosed in the scheme of the present invention are not limited to the technical means disclosed in the above-mentioned implementation mode, but also include technical schemes composed of any combination of the above-mentioned technical features. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications are also regarded as the protection scope of the present invention.
Claims
1. A domain-sensitive program slicing method based on high-order access paths, It is characterized in that The following steps are involved: Step 1: Preprocess the source program; convert the C language code source program into the intermediate representation LLVM IR, determine the correspondence between the variables in the C language code source program and the variables in LLVM IR, and convert the source program variables , variables in LLVM IR and access path Form a triple , get the access path set; Step 2: Slice the LLVM IR corresponding to the source program; Update each variable in LLVM IR as needed based on the memory operation instructions in LLVM IR Corresponding access path , update the slice result according to the operation instruction. During the traversal process, each time the analysis of a process is completed, the corresponding high-order function summary will be generated to pass the access path information of the variable for use in the analysis of other processes; Step 3: Map the LLVM IR slicing results to the source program; based on the slices on the LLVM IR obtained in step 2, the domain-sensitive slicing results of the source program are obtained according to the correspondence between the variables in the source program and the variables in the LLVM IR determined in step 1; The step 2 slices the LLVM IR corresponding to the source program, and the specific steps include: Step 2.1: Initialize the access path of each variable in LLVM IR. Initialize the access path of the variable in the mapping list obtained in the preprocessing stage to its corresponding variable name in the source program, otherwise initialize it to ; Step 2.2: For a given slicing criterion, traverse from the program entry to the slicing criterion. If a memory operation instruction store, load, or getelementptr is encountered, update the access path according to the corresponding rule; Step 2.3: Calculate the intra-procedure slice, initialize the control dependency table and the data dependency table, and then update the two dependency sets in the statement analysis order, and update them accordingly according to whether the variable is a base variable or a domain variable, and whether it is a single value or a multi-value. Finally, get the high-order function summary of the procedure, which stores the access path information of the domain variables. Step 2.4: Calculate the interprocedural slice when a function call statement is encountered , perform inter-procedural analysis through the function summary obtained in step 2.
3. The anonymous function in the function summary expresses the relationship between variables and their access paths, thereby obtaining inter-procedural domain-sensitive program slices; In step 2.4, the function summary is as follows: ; Representation function The corresponding function summary for In terms of function The summary includes the function return value The corresponding backward slice set , and the relationship between the access paths corresponding to the input variables and the function return values, which is saved in the form of anonymous functions, where Represents an input , the output is Anonymous function of ; is the input variable, The access path corresponding to the function return value; this anonymous function is used to partially replace the content in the access expression to obtain a more accurate representation; Get the value in step 2.4 The operation rules of the statement are as follows: ; in, For the update function of the access path table, the variable Corresponding access path Updated to .
2. According to the domain-sensitive program slicing method based on high-order access paths according to claim 1, It is characterized in that The step 1 preprocesses the source program, and the specific steps include: Step 1.1: Convert the C language code source program into LLVM IR to obtain a mapping list; Step 1.2: Extract each base variable in the source program, identify its corresponding variable set in LLVM IR, and obtain the access path table; Step 1.3: Identify all structure variables defined in the source program and store their information in the mapping set; Step 1.4: Construct the function call graph CG and the control flow graph CFG of each function, and then determine the analysis order according to the weak topological order.
3. According to claim 2, a domain-sensitive program slicing method based on a high-order access path, It is characterized in that In step 2.1, each variable in LLVM IR There is a corresponding It is expressed in the form of ;in is the base variable in the source program, is an access expression of the form ,in is the domain access identifier, which indicates the form of field access at each layer in the access path. It is divided into access_derefence, access_array and access_structure, which represent pointer dereference, array access and structure access respectively. First, each variable of Initialized to the corresponding source program base variable or , update the access path table to .
4. According to claim 3, a domain-sensitive program slicing method based on a high-order access path, It is characterized in that In step 2.2, for the instruction store, the update rules are as follows: ; Among them, store %x, %y represents an assignment statement, which assigns the value of %y to %x. The corresponding update operation is to update the access path of variable %x. Updated to ; For instruction load, the update rules are as follows: ; Among them, %x = load %y represents a memory read statement, which reads the value in %y and assigns it to %x. The corresponding update operation is to change the access path of variable %x to Updated to ; For the instruction getelementptr, the update rules are as follows: ; Among them, the getelementptr instruction is used to calculate the address of the structure or array element. Indicates the offset of the address, each offset corresponds to a domain access identifier , Indicates the domain access identifier calculated based on the offset value and the type of field access. The + operator indicates the concatenation operation of the access path, that is, the corresponding , that is, for the getelementptr instruction, the calculated access path is assigned to .
5. According to claim 4, a domain-sensitive program slicing method based on high-order access paths, It is characterized in that The step 2.3 is specifically as follows: Calculate the instruction dependency set and variable dependency sets ; First initialize the dependency set and set the instruction dependency set to the instruction itself, ; At the same time, according to the different types of variables: global variables, formal parameters and local variables, the variable dependency set is initialized accordingly according to the following formula, ; in, Represents a set of global variables for all processes, Represents the set of formal parameters in process P; during the instruction traversal process, the instruction dependency set is continuously updated. , that is, each dependency set update will add and Two parts, corresponding to control dependency and data dependency, respectively. Indications and instructions There is a set of statements that control dependencies. Indicates in the instruction The set of variables defined or used in Indicates that Take the union of the instruction dependency sets of all statements in, Indicates that Take the union of the variable dependency sets of all statements in; The update rules for the variable dependency set are as follows: 。 6. A domain-sensitive program slicing method based on high-order access paths according to claim 5, It is characterized in that The step 3 maps the LLVM IR slicing result to the source program, and the specific steps include: Step 3.1: According to the mapping list obtained in the preprocessing stage, all variables in the slicing result of LLVM IR are returned to the source program to obtain the slice table for the source program; Step 3.2: For statements in the source program, if all variables in a statement exist in the slice table, then the statement is added to the slice result; in domain-insensitive program slicing, the slice result is in rows, and for domain-sensitive slicing, the granularity of the slice is increased from rows to variables; when a complete structure appears in a statement, and some of its fields are in the slice table and some are not in the slice table, a non-executable slice is generated, and the fields that are not in the slice table are replaced with a placeholder "_" in the slice result, indicating that the part is not in the slice result; finally, the slice result of the source program is obtained.
Citation Information
Patent Citations
Measurement model based on LLVM intermediate representation program slices
CN106933572A
Dynamic program dependency cluster detection method based on high-order function
CN115794120A
