Mass code program control flow and data flow dependency extraction method based on intermediate language

CN120561920APending Publication Date: 2025-08-29CHINA AUTOMOTIVE ENG RES INST
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510651618.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-08-29

Smart Images

  • Figure CN120561920A_ABST
    Figure CN120561920A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of program static analysis, and discloses an intermediate language-based massive code program control flow and data flow dependency extraction method, which comprises the following steps of: S1, obtaining intermediate language original text data from a compiler, and establishing a mapping relationship between a source file and an intermediate language symbol; s2, filtering nodes in the original text data of the intermediate language through a dynamically generated source file set, retaining effective nodes and reconstructing a static model; s3, performing standardized classification and storage on data types in the static model; s4, constructing a control dependency graph based on the control flow graph and the post-dominated tree; s5, constructing a data dependency graph through definition-use chain and pointer alias analysis; and S6, fusing the control dependency graph and the data dependency graph, and generating a program static structure view containing control flow and data flow quantization association. According to the method, efficient and accurate code analysis can be realized through deep fusion of intermediate language analysis and multi-dimensional dependency analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of program static analysis, and in particular to a method for extracting control flow and data flow dependencies of massive code programs based on an intermediate language. Background Art

[0002] With the development of intelligent connected vehicles, the scale of automotive software code is growing exponentially. Industry data shows that the amount of software code for typical on-board controllers has exceeded tens of millions of lines, posing a severe challenge to the processing efficiency and accuracy of program static analysis technology. Existing static analysis methods based on intermediate languages ​​use the original intermediate representation (IR) generated by compilers (such as LLVM) as the input source, but actual measured data shows that redundant information such as debug symbols and unreferenced variables in such IR accounts for as much as 35%-40%. This directly leads to the following problems:

[0003] (1) The efficiency of extracting static models of programs is low, and the time to build the control dependency graph (CDG) increases exponentially with the code size (O(n2) level); when processing millions of lines of code, the analysis time increases from minutes to hours.

[0004] (2) The dependency between control flow and data flow is prone to confusion. The false positive rate of cross-function pointer alias analysis exceeds 25% on the ISO26262 standard test set, which seriously affects the reliability of defect detection.

[0005] In the automotive electronics field, where functional safety requirements are stringent, this dual deficiency in efficiency and accuracy will directly threaten the safety certification of ASIL-D level systems. In addition, current mainstream program static analysis technologies have limitations in the following scenarios:

[0006] (1) In terms of redundant information processing, traditional methods use a static rule base for node filtering and lack a dynamic tagging mechanism based on compilation context. For example, when determining the scrp field (stack pointer register identifier) ​​in LLVM IR, existing technologies cannot effectively distinguish between debugging symbols and actual memory operation instructions, resulting in the accidental deletion of key control flow nodes.

[0007] (2) The post-dominator tree algorithm, which is widely used in the field of control dependency analysis, suffers from the path explosion problem when dealing with multi-layer loop nesting scenarios. Experiments show that when the number of loop nesting layers is greater than 3, the number of post-dominator tree traversal paths increases exponentially.

[0008] (3) In terms of data flow modeling, existing methods fail to achieve explicit association between control flow and data flow, especially the lack of cross-process dependency links established through edge types such as CTE (conditional transfer edge) and LIE (loop iteration edge), which makes it easy for data dependency relationships to be broken at branch merge points.

[0009] Therefore, it is urgent to establish an optimized reconstruction mechanism for the intermediate language to avoid the above problems by eliminating redundant interference and optimizing dependency modeling, and to improve the engineering practicality of static analysis. Summary of the Invention

[0010] The present invention aims to provide a method for extracting control flow and data flow dependencies from massive code programs based on an intermediate language, which is used to address the limitations of traditional technical methods. It can achieve efficient and accurate code analysis through the deep integration of intermediate language parsing and multi-dimensional dependency analysis. While improving the efficiency of massive code processing, it can systematically solve technical problems such as the separation of control flow and data flow, omission of dependencies in complex scenarios, and false alarms.

[0011] The basic solution provided by the present invention is: a method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language, comprising the following steps:

[0012] S1. Obtain the intermediate language original text data from the compiler and establish a mapping relationship between the source file and the intermediate language symbols;

[0013] S2. Filter the nodes in the intermediate language original text data through the dynamically generated source file set, retain the valid nodes and reconstruct the static model;

[0014] S3. Standardize and classify the data types in the static model and store them;

[0015] S4. Construct a control dependency graph based on the control flow graph and the post-dominator tree;

[0016] S5. Construct data dependency graph through define-use chain and pointer alias analysis;

[0017] S6. Fuse the control dependency graph and the data dependency graph to generate a program static structure view that includes the quantitative association between control flow and data flow.

[0018] Furthermore, in S2, the following sub-steps are included:

[0019] S21. Group all program source file names into a set, thereby obtaining a source file set A = {A1, A2, ..., An};

[0020] S22. Filter according to the value of the node attribute field scrp: retain the node when scrp_value∈A, otherwise remove it;

[0021] S23. For the node whose scrp_value is empty, the retention state is determined by recursively determining the attributes of its child nodes.

[0022] Furthermore, in S4, the following sub-steps are included:

[0023] S41, using a branch statement as a basic block entry and a branch target label or a function return instruction as a basic block exit, and forming a basic block set by merging consecutive branchless instructions;

[0024] S42. Use the reverse traversal Tarjan algorithm to construct the post-dominator tree, and optimize the computational time complexity to O(Nα(N)); where α is the Ackermann function and N is the number of basic blocks;

[0025] S43, determining the control dependency relationship based on the post-dominant boundary, and establishing a dependency chain by backtracing the post-dominant tree when processing nested loops;

[0026] S44. Merge nodes that share the same control path to generate a simplified control dependency graph containing strong dependency and weak dependency markers.

[0027] Furthermore, in S5, the following sub-steps are included:

[0028] S51. Build a cross-function definition-use chain by traversing the control flow graph in reverse, and establish a function parameter mapping table to handle cross-function calls;

[0029] S52. Apply iterative data flow analysis to identify flow dependencies and anti-dependencies, and perform pointer alias analysis in conjunction with the Steensgaard algorithm.

[0030] S53. Separate alias sets by field offset for structure pointers and enable context-sensitive analysis for global pointers.

[0031] S54. When processing array elements, decompose them into three fixed values: base address, index and element for dependency tracking.

[0032] Furthermore, in S6, when fusing the control dependency graph and the data dependency graph, the following sub-steps are included:

[0033] S61. Create a shared node hash table with the key being the statement unique identifier and the value being the dual-graph node pointer; process the cross-graph mapping relationship through the call chain;

[0034] S62. Generate conditional trigger dependency edges and loop iteration dependency edges, marked as CTE and LIE respectively, to achieve quantitative association between control flow and data flow;

[0035] S63. Assign edge weights based on dependency types; where strong control dependency weight W = 1.0, weak control dependency weight W = 0.6, and data dependencies are weighted hierarchically based on variable scope;

[0036] S64. Insert synchronization fence nodes into parallel code segments, and use hierarchical clustering and super-node compression for visual optimization of massive nodes.

[0037] Furthermore, the source file set A is maintained through a dynamic incremental update mechanism, which triggers automatic addition and deletion operations of set elements when the code base changes.

[0038] Furthermore, the criteria for determining strong dependency and weak dependency include:

[0039] Strong dependency: control transfer relationship generated by direct conditional branch;

[0040] Weak dependency: Indirect control influence relationship generated by nested control structures.

[0041] Furthermore, the edge weight calculation adopts the following formula:

[0042] W=α×Control_Weight+β×Data_Weight;

[0043] Among them: α is the control factor, the value is 0.6; β is the data factor, the value is 1.2;

[0044] Control_Weight takes values ​​based on the control dependency type: strong dependency is 1.0, weak dependency is 0.6;

[0045] Data_Weight takes values ​​based on the variable scope: 0.8 for local variables, 1.0 for global variables, and 1.2 for pointer variables.

[0046] Furthermore, in S52, a secondary pointer alias checking step is also included:

[0047] After the initial alias analysis is completed, the key pointer variables are reconstructed in SSA form by Function instrumentation verifies the accuracy of alias sets and corrects false positive dependencies.

[0048] Furthermore, the static structure view supports interactive exploration, including:

[0049] Click on a supernode to expand the detailed dependency subgraph;

[0050] Suspended display of dependent edge weights and associated variable information;

[0051] Perform subgraph isolation analysis by module / function dimension.

[0052] The working principle and advantages of the present invention are:

[0053] The present invention is based on an intermediate language-based method for extracting control flow and data flow dependencies from massive code programs. It is designed to address the limitations of traditional technical methods and can achieve efficient and accurate code analysis through the deep integration of intermediate language parsing and multi-dimensional dependency analysis. While improving the efficiency of massive code processing, it can systematically solve technical problems such as the separation of control flow and data flow, the omission of dependencies in complex scenarios, and false positives. The key points are:

[0054] First, this solution dynamically generates a source file set A and implements node filtering based on the scrp field value, converting node validity determination into a set member query operation. This reduces the filtering time complexity of a single node to O(1). Experimental verification shows that it can improve the efficiency of static model extraction by more than 40%. This mechanism, combined with recursive null-value node subgraph verification rules, can form a hybrid filtering strategy that combines dynamic and static filtering, ensuring the complete retention of valid nodes while avoiding the performance loss caused by traditional layer-by-layer traversal. Furthermore, the incremental maintenance mechanism of the dynamic source file set A can respond to code base changes in real time, ensuring the continued accuracy of the analysis results.

[0055] Second, when dealing with control dependencies, this solution creatively transforms the application direction of the Tarjan algorithm, adopting a reverse traversal strategy to build the post-dominator tree starting from the function exit block, which can optimize the algorithm's time complexity from the conventional implementation of O(n2) to the O(nα(n)) level. Actual engineering tests show that this optimization can shorten the construction time of the control dependency graph by 30%.

[0056] Third, this solution introduces two groundbreaking weighted edge types: CTE (Conditional Trigger Dependency Edge) and LIE (Loop Iteration Dependency Edge). This enables the quantitative association of control flow and data flow dependencies, unifying these dependencies into a measurable association network, resolving the issue of the two types of dependencies being separated in traditional approaches. Specifically, when calculating edge weights, a hierarchical strategy for strong and weak control dependencies, combined with differentiated weighting rules for local variables, global variables, and pointer variables, accurately characterizes the inherent connection between control decisions and data evolution during program execution.

[0057] Fourth, the data dependency algorithm designed in this solution integrates the flow-insensitive Steensgaard algorithm and the context-sensitive SSA verification mechanism, and corrects the initial analysis results through a secondary pointer alias verification process, which can effectively solve the problems of dependency omissions and false positives in complex scenarios.

[0058] Fifth, in generating static structural views, a shared node hash table and cross-graph call chain mapping design are employed. This enables efficient collaborative analysis of the control dependency graph and data dependency graph while maintaining independence. Synchronization fence nodes designed specifically for parallel code segments help address the dependency disorder issues that plague traditional approaches when processing multi-threaded programs. Furthermore, a hierarchical clustering algorithm and supernode compression technology are employed for visualization optimization, enabling interactive analysis of hundreds of thousands of nodes. Its modular subgraph isolation mechanism and detailed expansion capabilities enable fine-grained dependency querying while ensuring global structural visualization. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 A schematic diagram of a method flow of an embodiment of a method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to the present invention;

[0060] Figure 2 A schematic diagram of a node optimization process in an embodiment of a method for extracting control flow and data flow dependencies of a massive code program based on an intermediate language according to the present invention;

[0061] Figure 3 A control flow dependency extraction flow chart of an embodiment of a method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to the present invention;

[0062] Figure 4 This is a data flow dependency extraction flow chart of an embodiment of the method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language of the present invention. DETAILED DESCRIPTION

[0063] The following is a further detailed description through specific implementation methods:

[0064] The embodiment is basically as shown in the attached Figure 1 As shown: A method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language includes the following steps:

[0065] S1. Obtain the intermediate language original text data from the compiler and establish a mapping relationship between the source file and the intermediate language symbols.

[0066] Specifically, in this embodiment, the processed code data is the vehicle software code of the intelligent connected vehicle (such as the software code of the intelligent driving system).

[0067] Import the automotive software code into the compiler (such as LLVM, etc.), obtain all the original information text data displayed in the IR intermediate language through commands (such as "-emit-llvm"), and establish a file mapping table (FileMap) to record the mapping relationship between the source file and the IR symbol (intermediate language symbol).

[0068] S2, such as Figure 2 As shown, the nodes in the intermediate language original text data are filtered through the dynamically generated source file set, the valid nodes are retained and the static model is reconstructed.

[0069] It includes the following sub-steps:

[0070] S21. Group all program source file names into a set, thereby obtaining a source file set A = {A1, A2, ..., An}.

[0071] The source file collection A is maintained through a dynamic incremental update mechanism, which triggers automatic addition and deletion operations of collection elements when the code base changes.

[0072] S22. Filter according to the value of the node attribute field scrp: when scrp_value∈A, determine that the node is a valid node and retain the node; otherwise, determine that it is an invalid node and remove it.

[0073] S23. For the node whose scrp_value is empty, the retention state is determined by recursively determining the attributes of its child nodes.

[0074] That is, for a node whose scrp_value is empty, the node is included in the pending node map, and then the node attributes of the child nodes in the pending node map are determined in the same manner as S22 and S23.

[0075] Through the above settings, a hybrid filtering strategy of dynamic set judgment and recursive child node verification is adopted instead of traditional static rule filtering, which can significantly optimize the real-time performance of large-scale code processing.

[0076] S3. Normalize and classify the data types in the static model and store them, such as Figure 2 shown.

[0077] Specifically, for the valid node map retained in S2, the nodes are classified by data type, and a hash table is constructed to store metadata.

[0078] The metadata structure stored in the hash table contains the following fields:

[0079] Node type identifier (NodeType), used to distinguish statements, variables and expressions;

[0080] Scope level (scope_level), used to support cross-function analysis;

[0081] Original intermediate language fragment (ir_code);

[0082] Pre-association dependency edge set (edges);

[0083] The hash function of the hash table uses the NumunHash3 (ir_code+scope_level) algorithm to generate a unique key value to achieve fast storage and retrieval of metadata.

[0084] S4, such as Figure 3 As shown, a control dependency graph is constructed based on the control flow graph and the post-dominator tree.

[0085] It includes the following sub-steps:

[0086] S41. Use branch statements (such as br, switch, and other instructions) as basic block entries and branch target labels or function return instructions (ret) as basic block exits. Form a basic block set by merging consecutive branchless instructions. Output a control dependency graph (CDG) node set {B1, B2, ..., Bn}, and an edge set represents a jump relationship (such as B1→B2).

[0087] S42. The post-dominator tree is constructed using the reverse traversal Tarjan algorithm, and the computational time complexity is optimized to O(Nα(N)); where α is the Ackermann function and N is the number of basic blocks.

[0088] The Tarjan algorithm using reverse traversal to construct a post-dominator tree refers to traversing backward from the exit block (e.g., the end block of a function) of the control flow graph (CFG), calculating the post-dominator boundary of each basic block, and then generating a post-dominator tree structure in which the parent node is the basic block that directly post-dominates its child node.

[0089] S43. Determine the control dependency based on the post-dominant boundary. If the execution of basic block B is determined by the conditional branch (such as if-else) of block A, and B is not covered by the post-dominant tree of A, then B is control-dependent on A.

[0090] When processing nested loops, the dependency chain within the loop body is established by backtracking through the post-dominator tree.

[0091] S44. Merge nodes that share the same control path (such as multiple if statements share the same else branch) to generate a simplified control dependency graph (CDG) containing strong dependency (direct branch) and weak dependency (indirect transfer) markers.

[0092] Through the above setup, the dominator tree algorithm is applied in reverse to post-dominator calculations, combined with specific processing logic for circular dependency chains, breaking through the limitations of traditional forward dominator tree methods. Furthermore, the Tarjan algorithm combined with reverse traversal reduces the time complexity from O(n²) to O(Nα(N)), speeding up control dependency graph (CDG) construction by 30%. Furthermore, backtracking through the post-dominator tree can resolve nested circular dependency chains.

[0093] S5, such as Figure 4As shown, the data dependency graph is constructed through define-use chain (Def_Use_Chain) and pointer alias analysis.

[0094] It includes the following sub-steps:

[0095] S51. By traversing the control flow graph in reverse, a cross-function definition-use chain is constructed, and a function parameter mapping table is established to handle cross-function calls.

[0096] Specifically, by traversing the CFG in reverse, trace back from the variable use point (such as y in x=y+z) to the nearest definition point of the value (such as y=1); for cross-function calls, the actual parameters and formal parameters need to be associated through the function parameter mapping table (ParaMap), and finally the chain set of variables Def_Use_Chain(v)={d1→u1,d2→u2,...} is output.

[0097] S52. Apply iterative data flow analysis to identify flow dependencies and anti-dependencies, and perform pointer alias analysis in combination with the Steensgaard algorithm.

[0098] Specifically, the Reaching Definitions algorithm is used to identify data flow dependencies. If a variable v is defined in block A and used in block B, and there is a reachable path from A to B, then B is flow-dependent on A. If the variable is redefined in a subsequent block (e.g., A: x = 1; B: x = 2), an anti-dependency edge B→A is generated.

[0099] Based on Steensgaard's flow-insensitive alias analysis, equivalence classes of pointer variables are established (for example, when p=q, p and q are merged into the same alias set; if variables a and b are aliases of each other, and b and c are aliases of each other, then a and c are merged into the same equivalence class).

[0100] This step also includes a secondary pointer alias check step:

[0101] After the initial alias analysis is completed, the key pointer variables are reconstructed in SSA form by Function instrumentation verifies the accuracy of alias sets and corrects false positive dependencies.

[0102] S53. Separate alias sets for structure pointers by field offset and enable context-sensitive analysis for global pointers.

[0103] Specifically, when processing structure pointers, the alias set is separated by field offset (for example, p->f1 and p->f2 are considered different variables); at the same time, context-sensitive analysis is enabled for key pointers (such as global variables) based on the SSA form.

[0104] S54. When processing array elements, decompose them into three fixed values: base address, index and element for dependency tracking.

[0105] For example, decompose a[i] into three constants a, i, and a[i], and preferentially trace the dependencies of specific elements.

[0106] Through the above settings, a hybrid pointer analysis that integrates flow-insensitive (Steensgaard) and context-sensitive (SSA) is implemented, which helps to reduce dependency omissions in complex scenarios and improve the accuracy of array element decomposition tracking. In addition, in this solution, the alias set of structure pointers is separated by field offsets, overcoming the defect of treating the entire structure as a single alias set in traditional methods.

[0107] S6. Merge the control dependence graph and the data dependence graph to generate a static program structure view that includes the quantitative association between the control flow and the data flow.

[0108] Specifically, when merging the control dependence graph and the data dependence graph, the following sub-steps are included:

[0109] S61. Establish a shared node hash table, where the key is the unique identifier of the statement and the value is the pointer to the dual-graph node; handle the cross-graph mapping relationship through the call chain.

[0110] Specifically, according to the strong / weak dependence edge sets of the control dependence graph (CDG) and the flow / anti-dependence edge sets of the data dependence graph (DDG), establish a shared node hash table for CDG and DDG, where the key is the unique identifier of the statement (such as the intermediate language line number + function name) and the value is the pointer to the dual-graph node; for cross-function call nodes, establish a cross-graph mapping relationship through the call chain (Call Chain). If there are attribute conflicts (such as loop body boundary determination) for the same statement in different graphs, preferentially adopt the control flow boundary of the CDG.

[0111] S62. Generate conditional trigger dependence edges and loop iteration dependence edges, which are respectively marked as CTE and LIE, to achieve the quantitative association between the control flow and the data flow.

[0112] Specifically, for conditional branch statements (such as if(x>0)), associate the data dependence edge (DDG) of the conditional variable x with the control jump edge (CDG) to generate a conditional trigger dependence edge and mark it as CTE; for loop control variables (such as for(i=0;i<N;i++)), bind the data modification edge (DDG) of the loop variable i to the loop body entry control edge (CDG) to generate a loop iteration dependence edge and mark it as LIE.

[0113] S63. Assign weights to the edges according to the dependence type; among them, the weight of strong control dependence W = 1.0, the weight of weak control dependence W = 0.6, and the data dependence is weighted according to the variable scope.

[0114] The determination criteria for the strong dependence and the weak dependence include:

[0115] Strong dependency: control transfer relationship generated by direct conditional branch (such as direct if-else branch);

[0116] Weak dependency: Indirect control influence relationship generated by nested control structure transmission (such as nested loop transmission).

[0117] The edge weight calculation adopts the following formula:

[0118] W=α×Control_Weight+β×Data_Weight;

[0119] Among them: α is the control factor, the value is 0.6; β is the data factor, the value is 1.2;

[0120] Control_Weight takes values ​​based on the control dependency type: strong dependency is 1.0, weak dependency is 0.6;

[0121] Data_Weight takes values ​​based on the variable scope: 0.8 for local variables, 1.0 for global variables, and 1.2 for pointer variables. S64. Adopt an incremental graph fusion algorithm to preferentially merge high-frequency paths (number of executions > threshold) to avoid full graph traversal.

[0122] Insert synchronization barrier nodes (Barrier Node) into parallel code sections (such as OpenMP directives) to enforce dependency order.

[0123] For massive nodes (>100,000 nodes), we use hierarchical clustering and supernode compression for visualization optimization. Nodes with similar dependency patterns (such as continuous assignments in loop bodies) are merged into supernodes.

[0124] In addition, the static structure view supports interactive exploration, including:

[0125] Click a supernode to expand the detailed dependency subgraph.

[0126] Hover to display the dependent edge weight and associated variable information.

[0127] Perform subgraph isolation analysis by module / function dimension.

[0128] For cross-function calls, the parameter transfer path is marked with dotted arrows and the data dependency weight is bound.

[0129] This embodiment provides a method for extracting control flow and data flow dependencies from massive code programs based on an intermediate language, which is used to address the limitations of traditional technical methods. It can achieve efficient and accurate code analysis through the deep integration of intermediate language parsing and multi-dimensional dependency analysis. While improving the efficiency of massive code processing, it can systematically solve technical problems such as the separation of control flow and data flow, omission of dependencies in complex scenarios, and false alarms.

[0130] The above is only an embodiment of the present invention. Common knowledge such as the specific structure and characteristics of the scheme is not described in detail here. Ordinary technicians in the relevant field are aware of all common technical knowledge in the technical field of the invention before the application date or priority date, can obtain all existing technologies in the field, and have the ability to apply conventional experimental means before that date. Ordinary technicians in the relevant field can improve and implement this scheme in combination with their own abilities under the guidance of this application. Some typical well-known structures or well-known methods should not become obstacles for ordinary technicians in the relevant field to implement this application. It should be pointed out that for those skilled in the art, without departing from the structure of the present invention, several variations and improvements can be made, which should also be regarded as the scope of protection of the present invention. These will not affect the effect of the implementation of the present invention and the practicality of the patent.

Claims

1. A method for extracting control flow and data flow dependencies from massive code programs based on an intermediate language, characterized in that: The following steps are involved: S1. Obtain the intermediate language original text data from the compiler and establish a mapping relationship between the source file and the intermediate language symbols; S2. Filter the nodes in the intermediate language original text data through the dynamically generated source file set, retain the valid nodes and reconstruct the static model; S3. Standardize and classify the data types in the static model and store them; S4. Construct a control dependency graph based on the control flow graph and the post-dominator tree; S5. Construct data dependency graph through define-use chain and pointer alias analysis; S6. Fuse the control dependency graph and the data dependency graph to generate a program static structure view that includes the quantitative association between control flow and data flow.

2. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 1, characterized in that: In S2, the following sub-steps are included: S21. Group all program source file names into a set, thereby obtaining a source file set A = {A1, A2, ..., An}; S22. Filter according to the value of the node attribute field scrp: retain the node when scrp_value∈A, otherwise remove it; S23. For the node whose scrp_value is empty, the retention state is determined by recursively determining the attributes of its child nodes.

3. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 1, characterized in that: In S4, the following sub-steps are included: S41, using a branch statement as a basic block entry and a branch target label or a function return instruction as a basic block exit, and forming a basic block set by merging consecutive branchless instructions; S42. Use the reverse traversal Tarjan algorithm to construct the post-dominator tree, and optimize the computational time complexity to O(Nα(N)); where α is the Ackermann function and N is the number of basic blocks; S43, determining the control dependency relationship based on the post-dominant boundary, and establishing a dependency chain by backtracing the post-dominant tree when processing nested loops; S44. Merge nodes that share the same control path to generate a simplified control dependency graph containing strong dependency and weak dependency markers.

4. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 1, characterized in that: In S5, the following sub-steps are included: S51. Build a cross-function definition-use chain by traversing the control flow graph in reverse, and establish a function parameter mapping table to handle cross-function calls; S52. Apply iterative data flow analysis to identify flow dependencies and anti-dependencies, and perform pointer alias analysis in conjunction with the Steensgaard algorithm. S53. Separate alias sets by field offset for structure pointers and enable context-sensitive analysis for global pointers. S54. When processing array elements, decompose them into three fixed values: base address, index and element for dependency tracking.

5. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 1, characterized in that: In S6, when fusing the control dependency graph and the data dependency graph, the following sub-steps are included: S61. Create a shared node hash table with the key being the statement unique identifier and the value being the dual-graph node pointer; process the cross-graph mapping relationship through the call chain; S62. Generate conditional trigger dependency edges and loop iteration dependency edges, marked as CTE and LIE respectively, to achieve quantitative association between control flow and data flow; S63. Assign edge weights based on dependency types; where strong control dependency weight W = 1.0, weak control dependency weight W = 0.6, and data dependencies are weighted hierarchically based on variable scope; S64. Insert synchronization fence nodes into parallel code segments, and use hierarchical clustering and super-node compression for visual optimization of massive nodes.

6. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 1, characterized in that: The source file collection A is maintained through a dynamic incremental update mechanism, which triggers automatic addition and deletion operations of collection elements when the code base changes.

7. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 5, characterized in that: The criteria for determining strong dependence and weak dependence include: Strong dependency: control transfer relationship generated by direct conditional branch; Weak dependency: Indirect control influence relationship generated by nested control structures.

8. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 5, characterized in that: The edge weight calculation adopts the following formula: W=α×Control_Weight+β×Data_Weight; Among them: α is the control factor, the value is 0.6; β is the data factor, the value is 1.2; Control_Weight takes values ​​based on the control dependency type: strong dependency is 1.0, weak dependency is 0.6; Data_Weight takes values ​​based on the variable scope: 0.8 for local variables, 1.0 for global variables, and 1.2 for pointer variables.

9. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 4, characterized in that: In S52, a secondary pointer alias checking step is also included: After the initial alias analysis is completed, the key pointer variables are reconstructed in SSA form, the accuracy of the alias set is verified through φ function instrumentation, and the false positive dependencies are corrected.

10. The method for extracting control flow and data flow dependencies from a massive code program based on an intermediate language according to claim 1, characterized in that: The static structure view supports interactive exploration, including: Click on a supernode to expand the detailed dependency subgraph; Suspended display of dependent edge weights and associated variable information; Perform subgraph isolation analysis by module / function dimension.

Citation Information

Cited By

  • Software source code analysis method and device, computer equipment, readable storage medium and program product

    CN121478328A

  • Code detection method and device, storage medium and electronic equipment

    CN121579325A