A method for extracting dependencies between programs based on higher-order functions

Through the inter-program dependency extraction method based on higher-order functions, the problem of low efficiency of dependency extraction in the existing technology is solved, and efficient dependency extraction is realized. The generated function summary has good scalability and flexibility, and can be quickly obtained Inter-process dependencies.

CN114238078BActive Publication Date: 2024-11-08NANJING UNIV OF POSTS & TELECOMM
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202111392045.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-23
Publication Date
2024-11-08
Estimated Expiration
2041-11-23

AI Technical Summary

Technical Problem

The existing program dependency extraction method has poor scalability when the software scale is expanded, resulting in low efficiency of dependency extraction and secondary analysis is required to complete the extraction.

Method used

Using the inter-program dependency extraction method based on higher-order functions, the dependencies between statements and variables are obtained by building a process call graph, and the summary information is saved in the form of higher-order functions. Inverse topological sorting and higher-order function characteristics are used to call the procedure Substitute parameters to generate dependencies between processes.

Benefits of technology

It improves the efficiency of dependency extraction between programs and avoids quadratic analysis. The generated function summary has good scalability and flexibility, and can quickly obtain the dependencies between formal and actual parameters during procedure calls.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238078B_ABST
    Figure CN114238078B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for extracting dependencies between programs based on high-order functions. First, the program is preprocessed, a process call graph of the program is constructed, the nodes in the process call graph are traversed, and the analysis order of the sub-processes is determined; the dependencies between statements and variables in each called sub-process are obtained, and summary information is saved in the form of a high-order function; according to the generated high-order function summary, the function parameters of the function summary are substituted with corresponding values ​​or functions at the process call point to obtain the dependencies between processes caused by process calls and parameter transfer. The present invention obtains the dependencies within the process through the characteristics of high-order functions, generates a function summary expressed in the form of a high-order function, can facilitate the substitution of high-order function parameters in the function summary on demand at the call point when calling between processes, quickly obtains the dependencies between formal parameters and actual parameters, and effectively improves the efficiency of extracting dependencies between programs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of functional programming and program analysis, and in particular to a method for extracting dependencies between programs based on high-order functions. Background Art

[0002] As the scale of software continues to grow, the dependencies between program statements in the software become more complex, and these dependencies may be indirect, dynamic and changeable. Currently, most mainstream program dependency extraction methods are based on graph reachability algorithms based on dependency graphs. Although such methods can intuitively display dependency relationships on graphs, the complexity of building dependency graphs also increases exponentially as the scale of software expands.

[0003] Traditional inter-procedural dependency analysis mainly focuses on how to quickly obtain the dependency between formal parameters and actual parameters in the function call process. Most of the methods adopted are based on function summaries, but the generated function summary information is a specific value, which does not have good scalability and flexibility. Secondary analysis is often required to complete the extraction of dependencies. Summary of the invention

[0004] In view of the deficiencies in the prior art, the present invention provides a method for extracting dependencies between programs with good scalability and flexibility based on the characteristics of high-order functions in functional programming, thereby avoiding secondary analysis, improving the efficiency of dependency extraction, and solving the problem of poor scalability of function summaries in traditional methods.

[0005] To achieve the above object, the present invention adopts the following technical solutions:

[0006] The embodiment of the present invention proposes a method for extracting dependencies between programs based on a high-order function, and the extraction method comprises the following steps:

[0007] S1, preprocess the program, build the process call graph of the program, traverse the nodes in the process call graph, and determine the analysis order of the sub-processes;

[0008] S2, obtaining the dependency relationship between statements and variables in each called sub-process, and saving the high-order function summary information of each called sub-process in the form of a high-order function;

[0009] S3, according to the function summary in the form of a high-order function of each called sub-process generated in step S2, the function parameters of the function summary are substituted with corresponding values ​​or functions at the process call point to obtain the dependency relationship between processes caused by process calls and parameter passing.

[0010] Further, in step S1, the procedure call graph is traversed in the order of reverse topological sorting.

[0011] Furthermore, in step S2, the process of obtaining the dependency relationship between statements and variables in each called sub-process includes the following sub-steps:

[0012] S21, sequentially selecting one of the processes to be analyzed, denoted as P, initializing the dependency relationship of the process to be analyzed P, initializing the statement dependency set to empty, and initializing the variable dependency set according to the type of the variable;

[0013] S22, obtain the control dependency CD of one of the statements i in process P according to the CFG diagram i , the control dependency of statement i includes the union of the control dependency and data dependency of node j that is directly or indirectly connected to node i on the CFG graph; CD i =S(i), where S(i) represents the set of statements that have control dependencies with statement i;

[0014] S23, for a variable a in statement i in step S22, obtain its data dependency relationship DD i,(a) ;

[0015] S24, repeat steps S22 and S23, iteratively update the dependency of each statement and variable in process P to reach a constant value, and store the complete dependency between statements and variables within the process in the form of a higher-order function, and generate a function summary of process P in the form of a high-order function.

[0016] Furthermore, in step S21, the process of initializing the variable dependency set according to the type of the variable includes the following steps:

[0017] For global variables or formal parameters, their variable dependency sets are initialized to function parameter variables glo m or fun n , where the parameter glo m Corresponding to the mth defined global variable, fun n Corresponds to the nth parameter of the procedure fun and globs the function parameter at the call site m or fun n Substitute the corresponding summary information;

[0018] For variables other than formal parameters or global variables, initialize the variable dependency set to empty.

[0019] Further, in step S23, for a variable a in statement i in step S22, its data dependency relation DD is obtained. i,(a) The process includes the following steps:

[0020] S231, determine whether statement i is an assignment or memory modification statement. If yes, update the variable dependency set of variable a defined in statement i to the statement dependency set of statement i, and obtain the data dependency relationship DD of statement i. i,(a) , go to step S232; otherwise, go directly to step S232;

[0021] S232, determine whether statement i is a procedure call statement, if so, DD i,(a) It is expressed as λx.R(x) in the form of a high-order function, where x is the initialization function parameter corresponding to the formal parameter or global variable. The corresponding value or function is substituted into the function parameter at the process call point, and the current process ends; otherwise, the current process ends directly.

[0022] Furthermore, for a statement i containing multiple reference variables a, b, c...p, the data dependency of variables a, b, c...p is updated according to the assignment or memory modification expression of each variable, and the data dependency information when multiple variables exist is represented by a higher-order function:

[0023] DD i,(a||b||c,...||p) =λxλyλz...λu.R(x)∪R(y)∪R(z)∪...∪R(u)

[0024] In the formula, i, (a||b||c,...||p) represents one of the variables a to p in statement i; x, y, z,...u are the initialization function parameters corresponding to the formal parameters or global variables; x, y,...u in R(x), R(y),...R(u) represent the function summary corresponding to the function parameters.

[0025] Furthermore, in step S24, the dependency relationship between each statement and variable in the iterative update process P is made to reach a constant value. Except for the dependencies represented by higher-order functions, other dependencies without formal parameters or global variable function parameters will not be updated through iteration.

[0026] Furthermore, in step S3, the process of obtaining the dependency relationship between processes due to process calls and parameter transfer includes the following steps:

[0027] S31, obtaining the control dependency relationship of the called process and generating a set of control dependency relationships between processes;

[0028] S32, classifying the formal parameters according to the call type, obtaining the data dependency caused by parameter transfer and global variables according to their respective types, and substituting the function parameters in the generated high-order function summary into the corresponding relationship between the formal parameters and the actual parameters at the call point;

[0029] S33, using step S31 and step S32, iteratively update the dependency set of each statement and variable in the program to reach a fixed value, and generate a complete dependency relationship between statements and variables between procedures.

[0030] Furthermore, in step S32, the process of classifying the formal parameters according to the call type includes the following steps:

[0031] If the obtained dependency information includes not only the formal function parameter itself but also other parameters, it means that the formal parameter is a call-by-result or call-by-value result type; otherwise, it is a call-by-value type.

[0032] Furthermore, for the formal parameter types that are called by value, the dependencies at the call point are obtained from the function summary information in the form of a higher-order function; for the formal parameter types that are called by result or called by value-result, the dependencies of the formal parameters with function parameters are obtained through the function summary information in the form of a higher-order function, and the dependencies of the actual parameters are used to substitute values ​​or functions into the function parameters in the formal parameter dependency information to obtain the complete dependencies of the formal parameters.

[0033] The beneficial effects of the present invention are:

[0034] 1. The present invention obtains the dependency relationship within the process through the characteristics of high-order functions, and generates a function summary expressed in the form of a high-order function, which can facilitate the substitution of high-order function parameters in the function summary at the call point when calling between processes, quickly obtain the dependency relationship between formal parameters and actual parameters, and effectively improve the efficiency of extracting dependency relationships between programs.

[0035] 2. The high-order function summary of the present invention will not become more complicated as the number of process call layers increases like ordinary function summaries. On the contrary, as the analysis goes deeper, more and more parameters are determined, and the function parameters in the function summary will be clearer. The high-order function parameters in the high-order function summary are substituted with corresponding values ​​or functions at the process call point, and the corresponding process summary can be found based on the missing parameters and their dependencies.

[0036] 3. The present invention utilizes the characteristics of high-order functions to achieve the purpose of calling a function through partial parameters, thereby obtaining a partial application function. This property is conducive to improving the efficiency of program execution.

[0037] 4. In the present invention, when all parameters are not determined, the function summary can still be transmitted in the form of a function, and analyzing the program in a different order will not affect / interrupt / pause the generation of the function summary. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 The framework flow chart of the method for extracting dependencies between programs based on high-order functions according to an embodiment of the present invention.

[0039] Figure 2 The flowchart is a detailed description of the method for extracting dependencies between programs according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] The present invention will now be described in further detail with reference to the accompanying drawings.

[0041] It should be noted that the terms such as "upper", "lower", "left", "right", "front", "back", etc. cited in the invention are only for the convenience of description and are not used to limit the scope of implementation of the present invention. Changes or adjustments in their relative relationships should be regarded as the scope of implementation of the present invention without substantially changing the technical content.

[0042] Figure 1 Flow chart of a method for extracting dependencies between programs based on a high-order function according to an embodiment of the present invention. This embodiment is applicable to a method for extracting dependencies between programs based on a high-order function, and the method comprises the following steps:

[0043] S1, preprocess the program, build the process call graph of the program, traverse the nodes in the process call graph, and determine the analysis order of the sub-processes.

[0044] S2, obtains the dependency relationship between statements and variables in each called sub-process, and saves the high-order function summary information of each called sub-process in the form of a high-order function.

[0045] S3, according to the function summary in the form of a high-order function of each called sub-process generated in step S2, the function parameters of the function summary are substituted with corresponding values ​​or functions at the process call point to obtain the dependency relationship between processes caused by process calls and parameter passing.

[0046] Higher-order functions are also an important feature of functional programming. In functional programming, functions have equal status with other data types. They can be passed as parameters to other functions and can also be used as return values ​​of other functions. In addition, higher-order functions have some application characteristics. In functions with multiple parameters, this feature can be used to simplify the function for subsequent analysis.

[0047] 1. Program preprocessing

[0048] Construct the procedure call graph of the program, traverse the procedure call graph in the order of reverse topological sorting, and determine the analysis order of sub-procedures.

[0049] The program codes selected in this embodiment are shown in Table 1.

[0050] Table 1 Example code

[0051]

[0052] In this embodiment, the analysis order of the sub-process is fac->main.

[0053] 2. Get the dependencies between statements and variables in each called sub-procedure

[0054] See also Figure 2 In step S2, the process of obtaining the dependency relationship between statements and variables in each called sub-process includes the following sub-steps:

[0055] S21, select one of the processes to be analyzed in order, record it as P, initialize the dependency relationship of the process to be analyzed P, initialize the statement dependency set to empty, and initialize the variable dependency set according to the type of the variable.

[0056] S22, obtain the control dependency CD of one of the statements i in process P according to the CFG diagram i , the control dependency of statement i includes the union of the control dependency and data dependency of node j that is directly or indirectly connected to node i on the CFG graph; CD i =S(i), S(i) represents the set of statements that have control dependency with statement i.

[0057] S23, for a variable a in statement i in step S22, obtain its data dependency relationship DD i,(a) .

[0058] S24, repeat steps S22 and S23, iteratively update the dependency of each statement and variable in process P to reach a constant value, and store the complete dependency between statements and variables within the process in the form of a higher-order function, and generate a function summary of process P in the form of a high-order function.

[0059] Preferably, in step S21, the process of initializing the variable dependency set according to the type of the variable includes the following steps:

[0060] For global variables or formal parameters, their variable dependency sets are initialized to function parameter variables glo m or fun n , where the parameter glo m Corresponding to the mth defined global variable, fun n Corresponds to the nth parameter of the procedure fun and globs the function parameter at the call site m or fun n Substitute the appropriate summary information.

[0061] For variables other than formal parameters or global variables, initialize the variable dependency set to empty.

[0062] In step S23 of this embodiment, for a variable a in statement i in step S22, its data dependency relationship DD is obtained. i,(a) The process includes the following steps:

[0063] S231, determine whether statement i is an assignment or memory modification statement. If yes, update the variable dependency set of variable a defined in statement i to the statement dependency set of statement i, and obtain the data dependency relationship DD of statement i. i,(a) , go to step S232; otherwise, go directly to step S232.

[0064] S232, determine whether statement i is a procedure call statement, if so, DD i,(a) It is expressed as λx.R(x) in the form of a high-order function, where x is the initialization function parameter corresponding to the formal parameter or global variable. The corresponding value or function is substituted into the function parameter at the process call point, and the current process ends; otherwise, the current process ends directly.

[0065] Preferably, for a statement i containing multiple reference variables a, b, c...p, the data dependency relationship of the variables a, b, c...p is updated according to the assignment or memory modification expression of each variable, and the data dependency information when there are multiple variables is represented by a higher-order function:

[0066] DD i,(a||b||c,...||p) =λxλyλz...λu.R(x)∪R(y)∪R(z)∪...∪R(u)

[0067] In the formula, i, (a||b||c,...||p) represents one of the variables a to p in statement i; x, y, z,...u are the initialization function parameters corresponding to the formal parameters or global variables; x, y,...u in R(x), R(y),...R(u) represent the function summary corresponding to the function parameters.

[0068] In step S24 of this embodiment, the dependency relationship between each statement and variable in the iterative update process P is made to reach a constant value. Except for the dependencies represented by higher-order functions, other dependencies without formal parameters or global variable function parameters will not be updated through iteration.

[0069] For example, in this embodiment, the statement dependency set is initialized to empty. The variable dependency set will be initialized according to the type of the variable. For global variables or formal parameters, their variable dependency sets will be initialized as function parameter variables glo m or fun n , where the parameter glo m Corresponding to the mth defined global variable, fun nThe nth parameter of the corresponding procedure fun is used to generate a higher-order function summary and to glob the function parameter at the call site. m or fun n Substitute the corresponding summary information (which can be a value or a function) and initialize the variable dependency set to empty for variables other than formal parameters or global variables.

[0070] Obtain the dependency relationship for the procedure fac. For the formal parameter x, it can be determined that x is the first parameter of the fac procedure, so the variable dependency set of the formal parameter is initialized to the function parameter variable fac1.

[0071] According to the CFG graph, we can obtain the control dependency of statement i, i.e. CD i The control dependency of statement i includes the union of the control dependency and data dependency of node j that is directly or indirectly connected to node i on the CFG graph.

[0072] The statement dependency set is represented as CD i =S(i), where S(i) represents the set of statements that have control dependency with statement i.

[0073] In this embodiment, the control dependency relationship of statement 6 can be expressed as CD6={3}.

[0074] According to step S23, the data dependency relationship of variable a in statement i, namely DD i,(a) Here we will use DD i,(a) It is expressed as λx.R(x) in the form of a high-order function, where x is generally a formal parameter or a global variable corresponding to the initialization function parameter similar to fun in step S21. n or glo m , at subsequent call points, the corresponding function summary can be a value or a function substituted into the function parameter, similar to: DD i,(a) =λy.R(sum(y)), where sum(y) indicates that the function summary information of the actual parameter y corresponding to the formal parameter can be a function, and the function parameter in the high-order function summary corresponding to the process fac is fac1, that is, DD 6,(x) =λfac1.R(fac1).

[0075] For assignment statements or memory modification related statements i, update the variable dependency set of variable a defined in the statement i to the statement dependency set of the statement i; for statements other than assignment statements or memory modification related statements, skip this step.

[0076] For statement i containing multiple reference variables a, b, c...p, update the data dependency relationship of variables a, b, c...p according to the assignment or memory modification expression of each variable, and use high-order functions to represent the data dependency information when there are multiple variables, for example: DD i,(a||b||c,...||p) =λxλyλz...λu.R(x)∪R(y)∪R(z)∪...∪R(u), where "i,(a||b||c,...||p)" represents one of the variables a to p in statement i, and x, y, z,...u are generally the initialization function parameters corresponding to formal parameters or global variables, similar to fun in step S22. n or glo m , x, y, ...u in R(x), R(y), ...R(u) represent the function summary corresponding to the function parameters, which can be a function.

[0077] According to step S22 and step S23, the dependency relationship of each statement and variable in the process P is iteratively updated to reach a fixed value, and the complete dependency relationship of the statements and variables in the process is stored in the form of a high-order function, and a function summary in the form of a high-order function is generated. The condition for reaching a fixed value means that, except for the dependencies represented by the high-order function, other dependencies without formal parameters or global variable function parameters will not be updated through iteration.

[0078] After iteration, the dependency of variable x reaches a fixed value, namely DD 6,(x) =λfac1.{3}∪{6}∪fac1, and save it as the function summary of the fac procedure to facilitate corresponding substitution when calling the fac procedure.

[0079] 3. Obtaining dependencies between procedures due to procedure calls and parameter passing

[0080] In step S3, the process of obtaining the dependency relationship between processes due to process calls and parameter transfer includes the following steps:

[0081] S31, obtaining control dependency relations of called processes, and generating a set of control dependency relations between processes.

[0082] S32, classify the formal parameters according to the call type, obtain the data dependency caused by parameter passing and global variables according to their respective types, and substitute the function parameters in the generated high-order functional function summary according to the correspondence between the formal parameters and the actual parameters at the call point.

[0083] S33, using step S31 and step S32, iteratively update the dependency set of each statement and variable in the program to reach a fixed value, and generate a complete dependency relationship between statements and variables between procedures.

[0084] In step S32 of this embodiment, the process of classifying the formal parameters according to the call type includes the following steps:

[0085] If the obtained dependency information includes not only the formal function parameter itself but also other parameters, it means that the formal parameter is a call-by-result or call-by-value result type; otherwise, it is a call-by-value type.

[0086] Preferably, for formal parameter types that are called by value, the dependencies at the call point are obtained from the function summary information in the form of a higher-order function; for formal parameter types that are called by result or called by value-result, the dependencies of the formal parameters with function parameters are obtained through the function summary information in the form of a higher-order function, and the dependencies of the actual parameters are used to substitute values ​​or functions into the function parameters in the formal parameter dependency information to obtain the complete dependencies of the formal parameters.

[0087] For example, in this embodiment, since the dependency relationship obtained for the formal parameter x only includes the formal parameter function parameters and does not include other parameters, the formal parameter is a call-by-value type.

[0088] Then treat the global variable as a call by value result, and the return value as a call by result; for the formal parameter type called by value, the dependency at the call point can be directly obtained from the function summary information in the form of a high-order function described in step S24; for the formal parameter type called by result or called by value-result, the dependency of the formal parameter can be directly obtained through the function summary information in the form of a high-order function, with function parameters, and then the dependency of the actual parameter is used to substitute the value or function into the function parameter in the formal parameter dependency information to obtain the complete dependency of the formal parameter.

[0089] According to the function summary information in the form of a high-order function, the data dependency of the actual parameter variable a at line 16 of the call point is: DD 16,(a) =λy.{11,13,14,15,16}∪y, where the higher-order function parameter of the parameter x corresponding to the actual parameter a is fac1, so DD 16,(a) The variable y in DD is used to summarize the corresponding function parameters 6,(x) Substitute, that is, DD 16,(a) =λfac1.{11,13,14,15,16}∪DD 6,(x) , where DD 6,(x) =λfac1.{3}∪{6}∪fac1, and then continue to substitute the function summary information of other processes according to the corresponding relationship of the high-order function parameters. It is a function. In this example, iteration can still be continued, but the function summary corresponding to the function parameter fac1 is still DD 6,(x) .

[0090] According to step S31 and step S32, the dependency relationship of each statement and variable in the program is iteratively updated to reach a fixed value, and the complete dependency relationship between inter-procedural statements and variables is obtained. The result of inter-procedural dependency analysis of the main function is: variable a: {3, 6, 11, 13, 14, 15, 16} variable b: {3, 4, 6, 11, 12, 13, 14, 15, 16} variable c: {14}.

[0091] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.

Claims

1. A method for extracting dependencies between programs based on high-order functions, characterized in that: The extraction method comprises the following steps: S1, preprocess the program, build the process call graph of the program, traverse the nodes in the process call graph, and determine the analysis order of the sub-processes; S2, obtaining the dependency relationship between statements and variables in each called sub-process, and saving the high-order function summary information of each called sub-process in the form of a high-order function; S3, according to the function summary in the form of a high-order function of each called sub-process generated in step S2, corresponding values ​​or functions are substituted into the function parameters of the function summary at the process call point to obtain the dependency relationship between processes caused by process calls and parameter passing; In step S2, the process of obtaining the dependency relationship between statements and variables in each called sub-process includes the following sub-steps: S21, sequentially selecting one of the processes to be analyzed, denoted as P, initializing the dependency relationship of the process to be analyzed P, initializing the statement dependency set to empty, and initializing the variable dependency set according to the type of the variable; S22, obtain the control dependency CD of one of the statements i in process P according to the CFG diagram i , the control dependency of statement i includes the union of the control dependency and data dependency of node j that is directly or indirectly connected to node i on the CFG graph; CD i =S(i), where S(i) represents the set of statements that have control dependencies with statement i; S23, for a variable a in statement i in step S22, obtain its data dependency relationship DD i,(a) ; S24, repeating steps S22 and S23, iteratively updating the dependency relationship between each statement and variable in process P to reach a fixed value, and storing the complete dependency relationship between statements and variables in the process in the form of a high-order function, generating a function summary in the form of a high-order function of process P; S25, repeating steps S21 to S24 until function summaries in the form of high-order functions of all processes to be analyzed are generated; In step S23, for a variable a in statement i in step S22, obtain its data dependency relation DD i,(a) The process includes the following steps: S231, determine whether statement i is an assignment or memory modification statement. If yes, update the variable dependency set of variable a defined in statement i to the statement dependency set of statement i, and obtain the data dependency relationship DD of statement i. i,(a) , go to step S232; otherwise, go directly to step S232; S232, determine whether statement i is a procedure call statement, if so, DD i,(a) It is expressed as λx.R(x) in the form of a high-order function, where x is the initialization function parameter corresponding to the formal parameter or global variable. At the process call point, the function parameter is substituted with the corresponding value or function, and the current process ends; otherwise, the current process ends directly. In step S3, the process of obtaining the dependency relationship between processes due to process calls and parameter transfer includes the following steps: S31, obtaining the control dependency relationship of the called process and generating a set of control dependency relationships between processes; S32, classifying the formal parameters according to the call type, obtaining the data dependency caused by parameter transfer and global variables according to their respective types, and substituting the function parameters in the generated high-order function summary into the corresponding relationship between the formal parameters and the actual parameters at the call point; S33, using step S31 and step S32, iteratively update the dependency set of each statement and variable in the program to reach a fixed value, and generate a complete dependency relationship between statements and variables between procedures.

2. The method for extracting dependencies between programs based on high-order functions according to claim 1, characterized in that: In step S1, the procedure call graph is traversed in the order of reverse topological sorting.

3. The method for extracting dependencies between programs based on high-order functions according to claim 1 is characterized in that: In step S21, the process of initializing the variable dependency set according to the type of the variable includes the following steps: For global variables or formal parameters, their variable dependency sets are initialized to function parameter variables glo m or fun n , where the parameter glo m Corresponding to the mth defined global variable, fun n Corresponds to the nth parameter of the procedure fun and globs the function parameter at the call site m or fun n Substitute the corresponding summary information; For variables other than formal parameters or global variables, initialize the variable dependency set to empty.

4. The method for extracting dependencies between programs based on high-order functions according to claim 1, characterized in that: For statement i containing multiple reference variables a, b, c...p, the data dependency relationship of variables a, b, c...p is updated according to the assignment or memory modification expression of each variable, and the data dependency information when there are multiple variables is expressed in a high-order function: DD i,(a||b||c,...||p) =λxλyλz...λu.R(x)∪R(y)∪R(z)∪...∪R(u) In the formula, i, (a||b||c,...||p) represents one of the variables a to p in statement i; x, y, z,...u are the initialization function parameters corresponding to the formal parameters or global variables; x, y,...u in R(x), R(y),...R(u) represent the (higher-order) function summary corresponding to the function parameters.

5. The method for extracting dependencies between programs based on high-order functions according to claim 1, characterized in that: In step S24, the dependency relationship between each statement and variable in the iterative update process P is made to reach a constant value. Except for the dependencies represented by higher-order functions, other dependencies without formal parameters or global variable function parameters will not be updated through iteration.

6. The method for extracting dependencies between programs based on high-order functions according to claim 1, characterized in that: In step S32, the process of classifying the formal parameters according to the call type includes the following steps: If the obtained dependency information includes not only the formal function parameter itself but also other parameters, it means that the formal parameter is a call-by-result or call-by-value result type; otherwise, it is a call-by-value type.

7. The method for extracting dependencies between programs based on high-order functions according to claim 6 is characterized in that: For parameter types that are called by value, the dependencies at the call point are obtained from the function summary information in the form of a higher-order function. For parameter types that are called by result or by value-result, the dependencies of the formal parameters with function parameters are obtained through the function summary information in the form of a higher-order function, and the dependencies of the actual parameters are used to substitute values ​​or functions into the function parameters in the formal parameter dependency information to obtain the complete dependencies of the formal parameters.

Citation Information

Patent Citations

  • Software FMEA (failure mode and effects analysis) method based on level dependency modeling

    CN103473400A

  • Program execution trajectory-based interprocess dynamic program slicing system

    CN104461883A

  • LLVM IR program slicing method based on improved system dependence graph

    CN105700893A

  • Information processor, information processing method, and information processing program

    JP2008282174A

  • Paralleled program generation program, paralleled program generation device, and paralleled program generation method

    WO2007105309A1