Compilation optimization option grouping method, computer equipment and storage medium

By analyzing the function call relationship information of the compiler, grouping the compiled optimization options to form a target search space, solving the problem of low search efficiency caused by the excessive number of compiled optimization options, and achieving more efficient compiled optimization options combination search.

CN119088664AActive Publication Date: 2024-12-06ZTE CORP +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202310617641.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-29
Publication Date
2024-12-06
Estimated Expiration
2043-05-29

AI Technical Summary

Technical Problem

The too many compilation optimization options are caused by low search efficiency of compilation optimization option tuning algorithms, making it difficult to find a combination of compilation optimization options suitable for the target program in a short time.

Method used

By obtaining the function call relationship information of the compiler, all the compilation optimization options in the compiler are grouped, multiple target compilation optimization options groups are obtained, and they are used as the target search space of the compiler, thereby reducing the search space and improving search efficiency.

Benefits of technology

It significantly improves the search efficiency of the compilation optimization option tuning algorithm, reduces the search space, and can find a combination of compilation optimization option suitable for the target program more quickly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088664A_ABST
    Figure CN119088664A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a compilation optimization option grouping method, computer equipment and a storage medium, and belongs to the field of computers. The method comprises the steps of obtaining function call relation information of a compiler; according to the function calling relation information, grouping all compiling optimization options in the compiler to obtain a plurality of target compiling optimization option groups; and taking the plurality of target compiling optimization option groups as a target search space of the compiler. According to the method, the compilation optimization options of the compiler are grouped, and the plurality of compilation optimization option groups obtained by grouping serve as the target search space of the compiler, so that the search space of a compilation optimization option tuning algorithm can be reduced, and the search efficiency of the compilation optimization option tuning algorithm is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a compilation optimization option grouping method, a computer device and a storage medium. Background Art

[0002] The compiler is one of the most critical basic software in the computer hardware and software ecosystem. After years of research and development, modern compilers have strong optimization capabilities. Compiler developers have designed and implemented a large number of compilation optimization options. The rational use of these compilation optimization options can fully improve the program's running performance. However, there are too many compilation optimization options, and it is difficult to rely on manpower to find a combination of compilation optimization options suitable for the target program. In the related art, the compilation optimization option tuning algorithm is mainly used to select the most suitable compilation optimization option combination for the target program from the multiple compilation optimization options that come with the compiler. However, the number of compilation optimization options that come with the compiler is large, and it is difficult to find a combination of compilation optimization options suitable for the target program in a short time, and the search efficiency of the compilation optimization option tuning algorithm is low. Summary of the invention

[0003] The embodiments of the present invention provide a compilation optimization option grouping method, a computer device and a storage medium, which are intended to reduce the search space of a compilation optimization option tuning algorithm, thereby improving the search efficiency of the compilation optimization option tuning algorithm.

[0004] In a first aspect, an embodiment of the present invention provides a method for grouping compilation optimization options, comprising:

[0005] Get the compiler's function call relationship information;

[0006] According to the function call relationship information, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups, wherein the target compile optimization option groups include one or more of the compile optimization options;

[0007] The plurality of target compile optimization option groups are used as a target search space of the compiler, wherein the target search space includes a plurality of search objects, and one target compile optimization option group corresponds to one search object.

[0008] In a second aspect, an embodiment of the present invention further provides a computer device, comprising a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the compilation optimization option grouping method described in the first aspect is implemented.

[0009] In a third aspect, an embodiment of the present invention further provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the compilation optimization option grouping method as described in the first aspect.

[0010] An embodiment of the present invention provides a compilation optimization option grouping method, a computer device and a storage medium. The embodiment of the present invention groups all compilation optimization options in a compiler through function call relationship information of the compiler to obtain multiple target compilation optimization option groups, and uses the multiple target compilation optimization option groups as the target search space of the compiler, which can greatly reduce the search space of the compilation optimization option tuning algorithm, thereby improving the search efficiency of the compilation optimization option tuning algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1 is a schematic block diagram of the structure of a computer device provided by an embodiment of the present invention;

[0013] Figure 2 It is a flowchart of a compilation optimization option grouping method provided by an embodiment of the present invention;

[0014] Figure 3 yes Figure 2 Schematic diagram of the sub-step flow of the compilation optimization option grouping method in ;

[0015] Figure 4 yes Figure 2 Schematic diagram of the sub-step flow of the compilation optimization option grouping method in ;

[0016] Figure 5 yes Figure 2 Schematic diagram of the sub-step flow of the compilation optimization option grouping method in ;

[0017] Figure 6 yes Figure 2 Schematic diagram of the sub-step flow of the compilation optimization option grouping method in ;

[0018] Figure 7 yes Figure 2 Flowchart of the sub-steps of the compilation optimization option grouping method in . DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0020] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

[0021] It should be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0022] The compiler is one of the most critical basic software in the computer hardware and software ecosystem. After years of research and development, modern compilers have strong optimization capabilities. Compiler developers have designed and implemented a large number of compilation optimization options. The rational use of these compilation optimization options can fully improve the program's running performance. However, there are too many compilation optimization options, and it is difficult to rely on manpower to find a combination of compilation optimization options suitable for the target program. In the related art, the compilation optimization option tuning algorithm is mainly used to select the most suitable compilation optimization option combination for the target program from the multiple compilation optimization options that come with the compiler. However, the number of compilation optimization options that come with the compiler is large, and it is difficult to find a combination of compilation optimization options suitable for the target program in a short time, and the search efficiency of the compilation optimization option tuning algorithm is low.

[0023] To solve the above problems, the embodiments of the present invention provide a compilation optimization option grouping method, a computer device and a storage medium. All compilation optimization options in the compiler are grouped through the function call relationship information of the compiler to obtain multiple target compilation optimization option groups, and the multiple target compilation optimization option groups are used as the target search space of the compiler, which can greatly reduce the search space of the compilation optimization option tuning algorithm, thereby improving the search efficiency of the compilation optimization option tuning algorithm.

[0024] In the embodiment of the present invention, the computer device may be a server or an electronic device. The server may be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The electronic device includes but is not limited to smartphones, tablet computers, laptops, desktop computers, personal digital assistants, and wearable devices.

[0025] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0026] See also Figure 1 , Figure 1 It is a schematic block diagram of the structure of a computer device provided by an embodiment of the present invention.

[0027] like Figure 1 As shown, the computer device 100 includes a processor 101 and a memory 102 , and the processor 101 and the memory 102 are connected via a bus 103 , such as an I2C (Inter-integrated Circuit) bus.

[0028] Specifically, the processor 101 is used to provide computing and control capabilities to support the operation of the entire computer device. The processor 101 can be a central processing unit (CPU), and the processor 101 can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0029] Specifically, the memory 102 may be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a mobile hard disk.

[0030] Those skilled in the art will understand that Figure 1The structure shown in the figure is only a block diagram of a part of the structure related to the embodiment of the present invention, and does not constitute a limitation on the computer device to which the embodiment of the present invention is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0031] The processor 101 is used to run the computer program stored in the memory 102, and implement any one of the compilation optimization option grouping methods provided by the embodiments of the present invention when executing the computer program.

[0032] In one embodiment, the processor 101 is used to run a computer program stored in the memory, and implements the following steps when executing the computer program:

[0033] Get the compiler's function call relationship information;

[0034] According to the function call relationship information, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups, wherein the target compile optimization option groups include one or more of the compile optimization options;

[0035] The target compilation optimization option groups are used as the target search space of the compiler, wherein the target search space includes multiple search objects, and one target compilation optimization option group corresponds to one search object.

[0036] In one embodiment, the function call relationship information includes a function call relationship graph of the compiler and / or a function call stack recorded when each of the called compile optimization options is called. When the processor 101 implements grouping all the compile optimization options in the compiler according to the function call relationship information to obtain multiple target compile optimization option groups, it is used to implement:

[0037] According to the function call relationship graph and / or the function call stack recorded when each of the called compile optimization options is called, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups.

[0038] In one embodiment, when the processor 101 implements grouping all the compile optimization options in the compiler according to the function call relationship graph and / or the function call stack recorded when each of the called compile optimization options is called to obtain multiple target compile optimization option groups, it is configured to implement:

[0039] Determine a first optimization process flow to which each of the compile optimization options belongs according to the function call relationship graph and the function to which each of the compile optimization options belongs;

[0040] According to the first optimization process to which each of the compile optimization options belongs, grouping all the compile optimization options in the compiler to obtain a plurality of first compile optimization option groups;

[0041] and / or, determining the second optimization process flow to which each of the called compilation optimization options belongs according to the function call stack recorded when each of the called compilation optimization options is called;

[0042] According to the second optimization process to which each of the called compilation optimization options belongs, all compilation optimization options in the compiler are grouped to obtain a plurality of second compilation optimization option groups;

[0043] A target compile optimization option group of the compiler is determined according to each of the first compile optimization option groups and / or each of the second compile optimization option groups.

[0044] In one embodiment, when the processor 101 implements grouping all the compile optimization options in the compiler according to the first optimization processing flow to which each of the compile optimization options belongs to obtain multiple first compile optimization option groups, it is configured to implement:

[0045] Dividing all the compile optimization options having the same first optimization process flow into a first compile optimization option group;

[0046] If there are ungrouped compile optimization options, the ungrouped compile optimization options belonging to the same first optimization process flow are divided into a first compile optimization option group.

[0047] In one embodiment, after implementing dividing the ungrouped compile optimization options belonging to the same first optimization process flow into a first compile optimization option group, the processor 101 is further configured to implement:

[0048] If there are multiple compiling optimization options that are not grouped, determining each of the compiling optimization options that are not grouped as a compiling optimization option to be grouped;

[0049] Determine the common function to which each of the to-be-grouped compilation optimization options belongs according to the function call relationship graph and the function to which each of the to-be-grouped compilation optimization options belongs;

[0050] All the to-be-grouped compile optimization options belonging to the same common function are divided into a new first compile optimization option group.

[0051] In one embodiment, when the processor 101 determines the target compile optimization option group of the compiler according to each of the first compile optimization option groups and / or each of the second compile optimization option groups, it is configured to implement:

[0052] Determine each of the first compile optimization option groups and / or each of the second compile optimization option groups as a target compile optimization option group of the compiler;

[0053] Alternatively, at least two of the first compile optimization option groups that have an intersection among the plurality of the first compile optimization option groups are combined into one group to obtain a plurality of third compile optimization option groups, and each of the third compile optimization option groups is determined as a target compile optimization option group of the compiler;

[0054] Alternatively, each of the third compiling optimization option groups and each of the second compiling optimization option groups are determined as target compiling optimization option groups of the compiler;

[0055] Alternatively, at least two of the second compiling optimization option groups that have an intersection among the plurality of the second compiling optimization option groups are combined into one group to obtain a plurality of fourth compiling optimization option groups, and each of the fourth compiling optimization option groups is determined as a target compiling optimization option group of the compiler;

[0056] Alternatively, each of the fourth compiling optimization option groups and each of the first compiling optimization option groups are determined as target compiling optimization option groups of the compiler;

[0057] Alternatively, each of the third compiling optimization option groups and each of the fourth compiling optimization option groups are determined as target compiling optimization option groups of the compiler.

[0058] In one embodiment, when the processor 101 determines the target compile optimization option group of the compiler according to each of the first compile optimization option groups and each of the second compile optimization option groups, the processor 101 is configured to implement:

[0059] Acquire an uncalled compile optimization option, wherein the uncalled compile optimization option is determined in a process of dynamically debugging a compile process of the compiler using a preset debugging tool;

[0060] Deleting the uncalled compiling optimization option from the first compiling optimization option group including the uncalled compiling optimization option, so as to update the first compiling optimization option group;

[0061] A target compile optimization option group of the compiler is determined according to each of the second compile optimization option groups and each of the updated first compile optimization option groups.

[0062] In one embodiment, when the processor 101 obtains the function call relationship information of the compiler, it is used to implement:

[0063] Dynamically debugging the compilation process of the compiler using a preset debugging tool, and in the process of dynamically debugging the compilation process of the compiler, recording a function call stack of the called compilation optimization option;

[0064] When the dynamic debugging of the compilation process of the compiler ends, the function call stack of each of the called compilation optimization options is obtained.

[0065] In one embodiment, when the processor 101 obtains the function call relationship information of the compiler, it is used to implement:

[0066] Obtaining a source code analysis result of the compiler;

[0067] According to the source code analysis result, a function call relationship graph of the compiler is constructed.

[0068] In one embodiment, the processor 101 is further configured to implement the following steps:

[0069] Extracting variables used by each function from the source code analysis results, and obtaining variables corresponding to each of the compilation optimization options;

[0070] According to the variables used by each function and the variables corresponding to each of the compilation optimization options, the function to which each of the compilation optimization options belongs is determined.

[0071] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the computer device described above can refer to the corresponding process in the following compilation optimization option grouping method embodiment, which will not be repeated here.

[0072] The following will be combined Figure 1 The computer device in the embodiment of the present invention provides a detailed introduction to the compilation optimization option grouping method. It should be noted that Figure 1 The computer device in the description is only used to explain the compilation optimization option grouping method provided in the embodiment of the present invention, but does not constitute a limitation on the application scenario of the compilation optimization option grouping method provided in the embodiment of the present invention.

[0073] See also Figure 2 , Figure 2 It is a flowchart of a compilation optimization option grouping method provided by an embodiment of the present invention.

[0074] like Figure 2 As shown, the compile optimization option grouping method includes steps S101 to S103.

[0075] Step S101, obtaining function call relationship information of the compiler.

[0076] In this embodiment, the function call relationship information of the compiler may include the function call relationship graph of the compiler and / or the function call stack recorded when each called compilation optimization option is called. The function call relationship graph of the compiler is used to describe the call relationship between each function in the source code of the compiler, and the function call stack corresponding to the called compilation optimization option is used to describe the call relationship between each function involved when the compilation optimization option is called. Among them, the compiler can be a GCC (GNU Compiler Collection) compiler, or it can be other compilers containing compilation optimization options, and the embodiment of the present invention does not make specific limitations on this.

[0077] In some embodiments, Figure 3 As shown, step S101 includes sub-steps S1011 to S1012.

[0078] Sub-step S1011, using a preset debugging tool to dynamically debug the compilation process of the compiler, and in the process of dynamically debugging the compilation process of the compiler, recording the function call stack of the called compilation optimization option.

[0079] In this embodiment, the preset debugging tool may be a GDB (a debugging tool provided by the GNU software system community) debugging tool, and of course the preset debugging tool may also be other debugging tools capable of debugging the compiler, which is not specifically limited in the embodiment of the present invention. Among them, a preset buffer may be used to record the function call stack of the called compilation optimization option.

[0080] In some embodiments, the compilation process of the compiler is dynamically debugged using a preset debugging tool, and in the process of dynamically debugging the compilation process of the compiler, the method of recording the function call stack of the called compilation optimization option can be: setting each compilation optimization option of the compiler as an observation point of the preset debugging tool; selecting a compilation case from a preset compilation case library; starting the compiler to compile the compilation case, and starting the preset debugging tool to detect the compilation process of the compiler; in the process of the compiler compiling the compilation case, if the started preset debugging tool detects the observation point, it is determined that the compilation optimization option corresponding to the observation point is called, and the function call stack of the called compilation optimization option is recorded; if there is a compilation optimization option that has not been called, continue to select the compilation case from the preset compilation case library, and return to execute the steps of starting the compiler to compile the compilation case, and starting the preset debugging tool to detect the compilation process of the compiler, until each compilation case in the preset compilation case library is selected once or each compilation optimization option of the compiler is called; when each compilation case in the preset compilation case library is selected once or each compilation optimization option of the compiler is called, exit the preset debugging tool. The preset compilation case library includes multiple compilation cases, and each compilation case in the preset compilation case library can be set by the user based on actual conditions, which is not specifically limited in the embodiment of the present invention.

[0081] In some embodiments, each compilation optimization option of the compiler is set as the observation point of the preset debugging tool in a manner as follows: all compilation optimization options of the compiler are set as the observation points of the preset debugging tool in batches. For example, the compiler includes compilation optimization option A, compilation optimization option B, compilation optimization option C, compilation optimization option D, and compilation optimization option E. Compilation optimization option A, compilation optimization option B, and compilation optimization option C can be set as observation point a, observation point b, and observation point c of the preset debugging tool respectively. After completing the detection of observation point a, observation point b, and observation point c, compilation optimization option D and compilation optimization option E can be set as observation point d and observation point e of the preset debugging tool respectively.

[0082] Sub-step S1012: when the dynamic debugging of the compilation process of the compiler ends, obtain the function call stack of each called compilation optimization option.

[0083] In this embodiment, after the preset debugging tool exits, it can be determined that the dynamic debugging of the compiler's compilation process ends, and at this time, the function call stack of each compiled optimization option called can be obtained. For example, when the dynamic debugging of the compiler's compilation process ends, the function call stack of each compiled optimization option called is obtained from the preset buffer. In this embodiment, by dynamically debugging the compiler's compilation process, the function call stack of the compiled optimization option called can be accurately recorded during the dynamic debugging of the compiler's compilation process.

[0084] In some embodiments, Figure 4 As shown, step S101 includes sub-steps S1013 and S1014.

[0085] Sub-step S1013: Obtain source code analysis results of the compiler.

[0086] In this embodiment, the source code analysis result of the compiler is the analysis result of the source code of the compiler. Source code analysis tools such as Source Insight and Linux Cross Reference can be used to analyze the source code of the compiler to obtain the source code analysis result of the compiler.

[0087] Sub-step S1014: construct a function call relationship diagram of the compiler according to the source code analysis result.

[0088] In this embodiment, by performing static analysis on the source code of the compiler, a source code analysis result can be obtained, so that the function call relationship graph of the compiler can be accurately constructed based on the source code analysis result, thereby improving the construction accuracy of the function call relationship body.

[0089] In some embodiments, the method of constructing the function call relationship graph of the compiler according to the source code analysis result may be: the computer device extracts each function from the source code of the compiler according to the source code analysis result, and determines the function called by each function during the execution process according to the source code analysis result; and constructs the function call relationship graph of the compiler according to each function and the functions called by each function during the execution process. The function call relationship graph may be a directed graph.

[0090] It should be noted that the computer device may only execute sub-steps S1011 and S1012, or only execute sub-steps S1013 and S1014, or execute sub-steps S1013 and S1014 while executing sub-steps S1011 and S1012. That is, the computer device may only perform static analysis on the compiler, and build a function call relationship graph of the compiler according to the result of the static analysis, or may only use a preset debugging tool to dynamically debug the compilation process of the compiler, and obtain the function call stack of the compilation optimization option called in the process of dynamically debugging the compilation process of the compiler. It is also possible not only to perform static analysis on the compiler, and build a function call relationship graph of the compiler according to the result of the static analysis, but also to use a preset debugging tool to dynamically debug the compilation process of the compiler, and obtain the function call stack of the compilation optimization option called in the process of dynamically debugging the compilation process of the compiler, and the embodiment of the present invention does not specifically limit this.

[0091] Step S102: group all compile optimization options in the compiler according to the function call relationship information to obtain multiple target compile optimization option groups.

[0092] In this embodiment, the target compilation optimization option group includes one or more compilation optimization options, that is, one compilation optimization option can be divided into one target compilation optimization option group, and multiple compilation optimization options can also be divided into one target compilation optimization option group. The embodiment of the present invention does not make specific limitations on this.

[0093] In some embodiments, according to the function call relationship information, all the compiling optimization options in the compiler are grouped, and the method for obtaining multiple target compiling optimization option groups can be: the computer device groups all the compiling optimization options in the compiler according to the function call relationship diagram and / or the function call stack recorded when each called compiling optimization option is called, and obtains multiple target compiling optimization option groups. This embodiment can quickly group the compiling optimization options by performing static analysis on the compiler, greatly improving the efficiency of compiling optimization option grouping. Or this embodiment can accurately group the compiling optimization options by performing dynamic analysis on the compiler, greatly improving the accuracy of compiling optimization option grouping. Or this embodiment can further improve the accuracy of compiling optimization option grouping by performing static analysis and dynamic analysis on the compiler.

[0094] In some embodiments, Figure 5 As shown, step S102 includes sub-steps S1021 to S1023.

[0095] Sub-step S1021: determining a first optimization process flow to which each compilation optimization option belongs according to the function call relationship graph and the function to which each compilation optimization option belongs.

[0096] In this embodiment, the first optimization process (Pass) to which the compilation optimization option belongs can be one or more, which is not specifically limited in the embodiment of the present invention. The function to which each compilation optimization option belongs is determined by the computer device according to the source code analysis result of the compiler.

[0097] In some embodiments, the variables used by each function are extracted from the source code analysis results of the compiler, and the variables corresponding to each compilation optimization option are obtained; the function to which each compilation optimization option belongs is determined based on the variables used by each function and the variables corresponding to each compilation optimization option. This embodiment can accurately determine the function to which each compilation optimization option belongs through the variables used by each function in the source code analysis results and the variables corresponding to each compilation optimization option. For example, the source code analysis results of the compiler include function A, function B, function C, and function D, and the variables used by function A, function B, function C, and function D are variable a, variable b, variable c, and variable d, respectively. If the variable corresponding to compilation optimization option F is variable c, then it can be determined that the function to which compilation optimization option F belongs is function C.

[0098] In some embodiments, according to the function call relationship graph and the function to which each compilation optimization option belongs, the method of determining the first optimization processing flow to which each compilation optimization option belongs can be: for each compilation optimization option, the function call relationship path including the function to which the compilation optimization option belongs is determined in the function call relationship graph, and the tail function of the function call relationship path is a preset function; the optimization processing flow corresponding to the tail function of the function call relationship path is determined as the first optimization processing flow to which the compilation optimization option belongs. Among them, the preset function is an execute function or a gate function, and the function call relationship path including the function to which the compilation optimization option belongs can be one or more, and the embodiment of the present invention does not make specific limitations on this. For example, the function to which the compilation optimization option G belongs is function E, and the function call relationship path including function E determined in the function call relationship graph is function E→function F→function G→function H, function H is the tail function, and function H is the execute function of the optimization processing flow pass_rtl_pre, therefore, the first optimization processing flow to which the compilation optimization option G belongs is pass_rtl_pre.

[0099] Sub-step S1022: grouping all the compile optimization options in the compiler according to the first optimization process to which each compile optimization option belongs, to obtain a plurality of first compile optimization option groups.

[0100] In this embodiment, the computer device can group all the compiling optimization options with the same first optimization process into one first compiling optimization option group; if there are ungrouped compiling optimization options, the ungrouped compiling optimization options belonging to the same first optimization process are grouped into one first compiling optimization option group; if there are no ungrouped compiling optimization options, the grouping is terminated. One first compiling optimization option group corresponds to one first optimization process.

[0101] For example, the compiler includes compilation optimization option N1, compilation optimization option N2, compilation optimization option N3, compilation optimization option N4, compilation optimization option N5 and compilation optimization option N6, and the first optimization processing flow to which compilation optimization option N1 belongs includes a first Pass1 and a first Pass2, the first optimization processing flow to which compilation optimization option N2 belongs is a first Pass2, the first optimization processing flow to which compilation optimization option N3 belongs is a first Pass3, the first optimization processing flow to which compilation optimization option N4 belongs is a first Pass3, the first optimization processing flow to which compilation optimization option N5 belongs is a first Pass4, and the first optimization processing flow to which compilation optimization option N6 belongs is a first Pass5.

[0102] Therefore, the compile optimization options N1 and N2 with the same first Pass2 can be grouped into a first compile optimization option group, and the compile optimization options N3 and N4 with the same first Pass3 can be grouped into a first compile optimization option group. If the compile optimization options N5 and N6 are left ungrouped, the compile optimization option N5 can be grouped into a first compile optimization option group, and the compile optimization option N6 can be grouped into a first compile optimization option group, so that four first compile optimization option groups can be obtained.

[0103] In some embodiments, if there are multiple compilation optimization options that are not grouped, each compilation optimization option that is not grouped is determined as a compilation optimization option to be grouped; the common function to which each compilation optimization option to be grouped belongs is determined according to the function call relationship graph and the function to which each compilation optimization option to be grouped belongs; and all the compilation optimization options to be grouped belonging to the same common function are divided into a new first compilation optimization option group. In this embodiment, when there are compilation optimization options that cannot be grouped according to the first optimization process flow, the ungrouped compilation optimization options belonging to the same common function can be divided into a new first compilation optimization option group, which can further reduce the search space of the compilation optimization options.

[0104] For example, the compiler includes compilation optimization option N1, compilation optimization option N2, compilation optimization option N3, compilation optimization option N4, compilation optimization option N5 and compilation optimization option N6, and the first optimization processing flow to which compilation optimization option N1 belongs includes the first Pass1 and the first Pass2, the first optimization processing flow to which compilation optimization option N2 belongs includes the first Pass3 and the first Pass4, the first optimization processing flow to which compilation optimization option N3 belongs is the first Pass5, the first optimization processing flow to which compilation optimization option N4 belongs is the first Pass5, the first optimization processing flow to which compilation optimization option N5 belongs is the first Pass6, and the first optimization processing flow to which compilation optimization option N6 belongs is the first Pass7.

[0105] Therefore, the compilation optimization option N3 and the compilation optimization option N3 having the same first Pass5 can be divided into a first compilation optimization option group, and the compilation optimization option N1, the compilation optimization option N2, the compilation optimization option N5 and the compilation optimization option N6 are left ungrouped, then the compilation optimization option N5 can be divided into a first compilation optimization option group, and the compilation optimization option N6 can be divided into a first compilation optimization option group. Then, the common function to which the compilation optimization option N1 belongs and the common function to which the compilation optimization option N2 belongs are determined. If the common function to which the compilation optimization option N1 belongs and the common function to which the compilation optimization option N2 belongs are the same, then the compilation optimization option N1 and the compilation optimization option N2 can be divided into a new first compilation optimization option group, so that four first compilation optimization option groups can be obtained. If the common function to which the compilation optimization option N1 belongs and the common function to which the compilation optimization option N2 belongs are different, then the compilation optimization option N1 can be divided into a new first compilation optimization option group, and the compilation optimization option N2 can be divided into a new first compilation optimization option group, so that five first compilation optimization option groups can be obtained.

[0106] Sub-step S1023: determining a target compile optimization option group of the compiler according to each first compile optimization option group.

[0107] In this embodiment, each first compilation optimization option group can be determined as a target compilation optimization option group of the compiler. In some embodiments, at least two first compilation optimization option groups that have an intersection in the plurality of first compilation optimization option groups can also be merged into one group to obtain a plurality of third compilation optimization option groups, and each third compilation optimization option group can be determined as a target compilation optimization option group of the compiler.

[0108] For example, there are five first compilation optimization option groups, namely, first compilation optimization option group P1, first compilation optimization option group P2, first compilation optimization option group P3, first compilation optimization option group P4 and first compilation optimization option group P5. Therefore, first compilation optimization option group P1, first compilation optimization option group P2, first compilation optimization option group P3, first compilation optimization option group P4 and first compilation optimization option group P5 can all be used as target compilation optimization option groups of the compiler, thereby obtaining five target compilation optimization option groups.

[0109] For another example, the first compilation optimization option group P4 and the first compilation optimization option group P5 have an intersection, so the first compilation optimization option group P4 and the first compilation optimization option group P5 in the first compilation optimization option group P1, the first compilation optimization option group P2, the first compilation optimization option group P3, the first compilation optimization option group P4 and the first compilation optimization option group P5 can be merged into one group, thereby obtaining a third compilation optimization option group Q1 (the same as the first compilation optimization option group P1), a third compilation optimization option group Q2 (the same as the first compilation optimization option group P2), a third compilation optimization option group Q3 (the same as the first compilation optimization option group P3) and a third compilation optimization option group Q4 (obtained by merging the first compilation optimization option group P4 and the first compilation optimization option group P5).

[0110] In some embodiments, Figure 6 As shown, step S102 includes sub-steps S1024 to S1026.

[0111] Sub-step S1024: determining the second optimization process flow to which each called compilation optimization option belongs according to the function call stack recorded when each called compilation optimization option is called.

[0112] In this embodiment, for each compilation optimization option that is called, the computer device can generate a function call relationship path of the called compilation optimization option based on the function call stack recorded when the called compilation optimization option is called, and the tail function of the function call relationship path is a preset function; the optimization processing flow corresponding to the tail function of the function call relationship path is determined as the second optimization processing flow to which the called compilation optimization option belongs.

[0113] Sub-step S1025: grouping all the compile optimization options in the compiler according to the second optimization process to which each called compile optimization option belongs, to obtain a plurality of second compile optimization option groups.

[0114] In this embodiment, all the compile optimization options belonging to the same second optimization process flow can be divided into a group to obtain multiple second compile optimization option groups. For example, the compiler includes 10 compile optimization options. When the compiler is dynamically debugged, these 10 compile optimization options are all called, so the function call stack of each of the 10 compile optimization options can be obtained. According to the function call stack of each of the 10 compile optimization options, the second optimization process flow to which each of the 10 compile optimization options belongs can be determined.

[0115] If the second optimization processing flows to which compilation optimization option N1, compilation optimization option N2 and compilation optimization option N3 among the 10 compilation optimization options belong are the same, and the second optimization processing flows to which compilation optimization option N4, compilation optimization option N5 and compilation optimization option N6 belong are the same, and the second optimization processing flows to which compilation optimization option N7, compilation optimization option N8, compilation optimization option N9 and compilation optimization option N10 belong are the same, then compilation optimization option N1, compilation optimization option N2 and compilation optimization option N3 can be divided into one second compilation optimization option group, compilation optimization option N4, compilation optimization option N5 and compilation optimization option N6 can be divided into one second compilation optimization option group, and compilation optimization option N7, compilation optimization option N8, compilation optimization option N9 and compilation optimization option N10 can be divided into one second compilation optimization option group, so as to obtain three second compilation optimization option groups in total.

[0116] For another example, when dynamically debugging the compiler, compile optimization options N1, N2, N3, N4, N5, N6, N7, N8, and N9 are all called, but N10 is not called. Therefore, the second optimization process flow to which compile optimization options N1, N2, N3, N4, N5, N6, N7, N8, and N9 belong can be determined based on the function call stacks of the compile optimization options N1, N2, N3, N4, N5, N6, N7, N8, and N9.

[0117] If the second optimization processing flows to which compilation optimization option N1 and compilation optimization option N2 belong are the same, and the second optimization processing flows to which compilation optimization option N3, compilation optimization option N4 and compilation optimization option N5 belong are the same, and the second optimization processing flows to which compilation optimization option N6 and compilation optimization option N7 belong are the same, and the second optimization processing flows to which compilation optimization option N8 and compilation optimization option N9 belong are the same, then compilation optimization option N1 and compilation optimization option N2 can be divided into one second compilation optimization option group, compilation optimization option N3, compilation optimization option N4 and compilation optimization option N5 can be divided into one second compilation optimization option group, compilation optimization option N6 and compilation optimization option N7 can be divided into one second compilation optimization option group, and compilation optimization option N8 and compilation optimization option N9 can be divided into one second compilation optimization option group, and compilation optimization option N10 is not grouped.

[0118] Sub-step S1026: Determine a target compile optimization option group of the compiler according to each second compile optimization option group.

[0119] In this embodiment, the computer device can determine each second compilation optimization option group as the target compilation optimization option group of the compiler. In some embodiments, at least two second compilation optimization option groups with intersections in multiple second compilation optimization option groups can also be merged into one group to obtain multiple fourth compilation optimization option groups, and each fourth compilation optimization option group can be determined as the target compilation optimization option group of the compiler. For example, there are 5 second compilation optimization option groups in total, namely, second compilation optimization option group T1, second compilation optimization option group T2, second compilation optimization option group T3, second compilation optimization option group T4 and second compilation optimization option group T5, so the second compilation optimization option group T1, second compilation optimization option group T2, second compilation optimization option group T3, second compilation optimization option group T4 and second compilation optimization option group T5 can all be used as the target compilation optimization option group of the compiler, thereby obtaining 5 target compilation optimization option groups.

[0120] For another example, the second compilation optimization option group T1 and the second compilation optimization option group T2 have an intersection, so the second compilation optimization option group T1 and the second compilation optimization option group T2 in the second compilation optimization option group T1, the second compilation optimization option group T2, the second compilation optimization option group T3, the second compilation optimization option group T4, and the second compilation optimization option group T5 can be merged into one group to obtain a fourth compilation optimization option group Y1 (obtained by merging the second compilation optimization option group T1 and the second compilation optimization option group T2), a fourth compilation optimization option group Y2 (the same as the second compilation optimization option group T3), a fourth compilation optimization option group Y3 (the same as the second compilation optimization option group T4), and a fourth compilation optimization option group Y4 (the same as the second compilation optimization option group T5).

[0121] In some embodiments, Figure 7 As shown, step S102 also includes sub-step S1027.

[0122] Sub-step S1027: determining a target compile optimization option group of the compiler according to each first compile optimization option group and each second compile optimization option group.

[0123] In this embodiment, the computer device can determine each first compilation optimization option group and each second compilation optimization option group as the target compilation optimization option group of the compiler. For example, there are 5 first compilation optimization option groups, namely, the first compilation optimization option group P1, the first compilation optimization option group P2, the first compilation optimization option group P3, the first compilation optimization option group P4 and the first compilation optimization option group P5, and there are 5 second compilation optimization option groups, namely, the second compilation optimization option group T1, the second compilation optimization option group T2, the second compilation optimization option group T3, the second compilation optimization option group T4 and the second compilation optimization option group T5. Therefore, the first compilation optimization option group P1, the first compilation optimization option group P2, the first compilation optimization option group P3, the first compilation optimization option group P4 and the first compilation optimization option group P5 and the second compilation optimization option group T1, the second compilation optimization option group T2, the second compilation optimization option group T3, the second compilation optimization option group T4 and the second compilation optimization option group T5 can be used as the target compilation optimization option group of the compiler, thereby obtaining 10 target compilation optimization option groups.

[0124] In some embodiments, the computer device may combine at least two first compilation optimization option groups that have an intersection among the multiple first compilation optimization option groups into one group to obtain multiple third compilation optimization option groups; and determine each third compilation optimization option group and each second compilation optimization option group as the target compilation optimization option group of the compiler. Or combine at least two second compilation optimization option groups that have an intersection among the multiple second compilation optimization option groups into one group to obtain multiple fourth compilation optimization option groups; and determine each fourth compilation optimization option group and each first compilation optimization option group as the target compilation optimization option group of the compiler. Alternatively, each third compilation optimization option group and each fourth compilation optimization option group are determined as the target compilation optimization option group of the compiler.

[0125] In some embodiments, according to each first compilation optimization option group and each second compilation optimization option group, the target compilation optimization option group of the compiler can be determined by: the computer device obtains the uncalled compilation optimization option, and the uncalled compilation optimization option is determined in the process of dynamically debugging the compilation process of the compiler using a preset debugging tool; deletes the uncalled compilation optimization option from the first compilation optimization option group including the uncalled compilation optimization option to update the first compilation optimization option group; and determines the target compilation optimization option group of the compiler according to each second compilation optimization option group and each updated first compilation optimization option group. This embodiment can reduce the search space by deleting the uncalled compilation optimization option from the first compilation optimization option group including the uncalled compilation optimization option.

[0126] For example, when dynamically debugging the compiler, compile optimization options N1, N2, N3, N4, N5, N6, N7, N8 and N9 are all called, and compile optimization option N10 is not called. There are five first compile optimization option groups, namely, first compile optimization option group P1, first compile optimization option group P2, first compile optimization option group P3, first compile optimization option group P4 and first compile optimization option group P5, and the first compile optimization option group P2 includes the uncalled compile optimization option N10, then the uncalled compile optimization option N10 can be deleted from the first compile optimization option group P2 to obtain the updated first compile optimization option group P2.

[0127] Step S103: Using multiple target compilation optimization option groups as target search spaces of the compiler.

[0128] In this embodiment, the target search space includes multiple search objects, and one target compile optimization option group corresponds to one search object. For example, if the compiler includes 100 compile optimization options, then when using the compile optimization option tuning algorithm without grouping, it is necessary to select the compile optimization options from these 100 compile optimization options. However, through the compile optimization option grouping method provided by the embodiment of the present invention, after grouping these 100 compile optimization options, 10 target compile optimization option groups can be obtained, so when using the compile optimization option tuning algorithm, it is only necessary to select one or more target compile optimization option groups from these 10 target compile optimization option groups, which greatly reduces the search space of the compile optimization option tuning algorithm, thereby improving the search efficiency of the compile optimization option tuning algorithm.

[0129] An embodiment of the present invention further provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement any compilation optimization option grouping method provided in the description of the embodiment of the present invention.

[0130] The storage medium may be an internal storage unit of the computer device described in the above embodiment, such as a hard disk or memory of the computer device. The storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device.

[0131] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware embodiment, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0132] It should be understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system including the element.

[0133] The serial numbers of the embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. The above description is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for grouping compilation optimization options. It is characterized in that include: Get the compiler's function call relationship information; According to the function call relationship information, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups, wherein the target compile optimization option groups include one or more of the compile optimization options; The plurality of target compile optimization option groups are used as a target search space of the compiler, wherein the target search space includes a plurality of search objects, and one target compile optimization option group corresponds to one search object.

2. The method for grouping compilation optimization options according to claim 1, It is characterized in that The function call relationship information includes a function call relationship graph of the compiler and / or a function call stack recorded when each of the called compile optimization options is called. According to the function call relationship information, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups, including: According to the function call relationship graph and / or the function call stack recorded when each of the called compile optimization options is called, all the compile optimization options in the compiler are grouped to obtain a plurality of target compile optimization option groups.

3. The method for grouping compilation optimization options according to claim 2, It is characterized in that The method further comprises grouping all the compile optimization options in the compiler according to the function call relationship graph and / or the function call stack recorded when each of the called compile optimization options is called, to obtain a plurality of target compile optimization option groups, including: Determine a first optimization process flow to which each of the compile optimization options belongs according to the function call relationship graph and the function to which each of the compile optimization options belongs; According to the first optimization process to which each of the compile optimization options belongs, grouping all the compile optimization options in the compiler to obtain a plurality of first compile optimization option groups; and / or, determining the second optimization process flow to which each of the called compilation optimization options belongs according to the function call stack recorded when each of the called compilation optimization options is called; According to the second optimization process to which each of the called compilation optimization options belongs, all compilation optimization options in the compiler are grouped to obtain a plurality of second compilation optimization option groups; A target compile optimization option group of the compiler is determined according to each of the first compile optimization option groups and / or each of the second compile optimization option groups.

4. The method for grouping compilation optimization options according to claim 3, It is characterized in that The step of grouping all the compile optimization options in the compiler according to the first optimization process to which each compile optimization option belongs, to obtain a plurality of first compile optimization option groups, includes: Dividing all the compile optimization options having the same first optimization process flow into a first compile optimization option group; If there are ungrouped compile optimization options, the ungrouped compile optimization options belonging to the same first optimization process flow are divided into a first compile optimization option group.

5. The method for grouping compilation optimization options according to claim 4, It is characterized in that After the ungrouped compiling optimization options belonging to the same first optimization process flow are divided into a first compiling optimization option group, the method further includes: If there are multiple compiling optimization options that are not grouped, determining each of the compiling optimization options that are not grouped as a compiling optimization option to be grouped; Determine the common function to which each of the to-be-grouped compilation optimization options belongs according to the function call relationship graph and the function to which each of the to-be-grouped compilation optimization options belongs; All the to-be-grouped compile optimization options belonging to the same common function are divided into a new first compile optimization option group.

6. The method for grouping compilation optimization options according to claim 3, It is characterized in that Determining the target compile optimization option group of the compiler according to each of the first compile optimization option groups and / or each of the second compile optimization option groups includes: Determine each of the first compile optimization option groups and / or each of the second compile optimization option groups as a target compile optimization option group of the compiler; Alternatively, at least two of the first compile optimization option groups that have an intersection among the plurality of the first compile optimization option groups are combined into one group to obtain a plurality of third compile optimization option groups, and each of the third compile optimization option groups is determined as a target compile optimization option group of the compiler; Alternatively, each of the third compiling optimization option groups and each of the second compiling optimization option groups are determined as target compiling optimization option groups of the compiler; Alternatively, at least two of the second compiling optimization option groups that have an intersection among the plurality of the second compiling optimization option groups are combined into one group to obtain a plurality of fourth compiling optimization option groups, and each of the fourth compiling optimization option groups is determined as a target compiling optimization option group of the compiler; Alternatively, each of the fourth compiling optimization option groups and each of the first compiling optimization option groups are determined as target compiling optimization option groups of the compiler; Alternatively, each of the third compiling optimization option groups and each of the fourth compiling optimization option groups are determined as target compiling optimization option groups of the compiler.

7. The method for grouping compilation optimization options according to claim 3, It is characterized in that The step of determining a target compile optimization option group of the compiler according to each of the first compile optimization option groups and each of the second compile optimization option groups comprises: Acquire an uncalled compile optimization option, wherein the uncalled compile optimization option is determined in a process of dynamically debugging a compile process of the compiler using a preset debugging tool; Deleting the uncalled compiling optimization option from the first compiling optimization option group including the uncalled compiling optimization option, so as to update the first compiling optimization option group; A target compile optimization option group of the compiler is determined according to each of the second compile optimization option groups and each of the updated first compile optimization option groups.

8. The method for grouping compilation optimization options according to any one of claims 1 to 7, It is characterized in that The obtaining of the function call relationship information of the compiler includes: Dynamically debugging the compilation process of the compiler using a preset debugging tool, and in the process of dynamically debugging the compilation process of the compiler, recording a function call stack of the called compilation optimization option; When the dynamic debugging of the compilation process of the compiler ends, the function call stack of each of the called compilation optimization options is obtained.

9. The method for grouping compilation optimization options according to any one of claims 1 to 7, It is characterized in that The obtaining of the function call relationship information of the compiler includes: Obtaining a source code analysis result of the compiler; According to the source code analysis result, a function call relationship graph of the compiler is constructed.

10. The method for grouping compilation optimization options according to claim 9, It is characterized in that The method further comprises: Extracting variables used by each function from the source code analysis result, and obtaining variables corresponding to each of the compilation optimization options; According to the variables used by each function and the variables corresponding to each of the compilation optimization options, the function to which each of the compilation optimization options belongs is determined.

11. A computer device, It is characterized in that The computer device includes a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the steps of the compilation optimization option grouping method according to any one of claims 1 to 10 are realized.

12. A storage medium for computer-readable storage, It is characterized in that The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the method for grouping compilation optimization options according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Linux kernel module relation extracting method based on compiling options

    CN103699389A

  • Iterative compilation optimization method based on program characteristic analysis

    CN107885503A

  • Compiling option tuning method and device, processor chip and server

    CN112433706A

  • Multi-target-oriented fine-grained compilation self-tuning method

    CN112527300A

  • Compilation sequence determination method and related equipment

    CN114564201A