Efficient construction of pruned SSA form
Intermediate representations of computer code are efficiently generated. More particularly, methods described herein may be used to construct a static single assignment representation of computer code without unnecessary phi-function nodes. Potentially necessary phi-function node assignments may be analyzed to determine whether they directly reach a non-phi use or a necessary phi-use of a corresponding variable. Those that ultimately reach such a use may be determined to be necessary and a pruned static single assignment may be constructed by including those potentially necessary phi-functions determined to be in fact necessary. Also, some phi-function nodes may be determined to be necessary based on their dependency relationship to other phi-functions previously determined to be necessary (e.g., because they directly reach a non-phi use). A phi-function dependency graph may be used to record dependency relationships between phi-function nodes. The analysis can proceed during a forward walk of a control flow representation of the program.
Latest Microsoft Patents:
- Systems and methods for electromagnetic shielding of thermal fin packs
- Application programming interface proxy with behavior simulation
- Artificial intelligence workload migration for planet-scale artificial intelligence infrastructure service
- Machine learning driven teleprompter
- Efficient electro-optical transfer function (EOTF) curve for standard dynamic range (SDR) content
The technical field relates to software development tools, such as compilers for a computer program.
BACKGROUNDSoftware compilers use internal data structures (e.g., control flow graphs, data flow graphs, etc.) for maintaining abstract representations of a program being compiled. Among other things, these program representations are used for implementing optimization techniques (e.g., constant propagation, redundancy elimination, etc.). Thus, the form of internal data structure representations of a program can directly influence the power and effectiveness of the various optimization techniques.
More recently, static single assignment (SSA) form and control dependency graphs have been used for representing data flow and control flow of a program in an efficient manner so as to improve the effectiveness of the compiler optimization techniques. In particular, SSA form can be viewed as a sparse representation of the traditional use-definition and definition-use chains related to a program. The SSA form provides several advantages to optimizing compilers. For instance, in SSA form, strict discipline is imposed on the name space used for representing values in computation. Thus, each reference of a name in an SSA form corresponds to the value resulting from precisely a single assignment (this explains the “Single Assignment” in the name SSA). Also, in an SSA form, each use refers to a single name.
Thus, to produce SSA form, a compiler may rewrite the intermediate code representation by inventing new names for each definition and substituting these new names in subsequent uses of the original names. Typically, unique names are created by adding a subscript to the name provided in the original program code. For instance, if a program had a variable “X”, then an assignment to the variable in the program's SSA representation may be renamed “X1” whereas another assignment may be renamed as “X2” and so on. Such renaming is simple in the context of straight-line code. However, the presence of more complex control flow presents a challenge for such a renaming process and the interpretation of the resulting code. For instance, if a name in the original code is defined along two converging paths, the SSA form may have multiple names when it reaches a reference.
One way to solve this problem is to introduce a pseudo function (typically referred to as a phi-function, phi-function node, phi-node, φ-function, φ-function node or φ-node) which takes as its arguments the two renamed names converging at the paths and results in a single value being assigned to a new name depending on the control flow. The phi-function can be added into the SSA form where appropriate. For example, a phi-function such as φ(X1, X2) may resolve which value, X1 or X2, applies at a particular convergence path depending on how control flow reached that path (i.e., via the path 1 or 2). A phi-function is sometimes referred to as a “join” function.
Several methods have been proposed for constructing SSA form from the original code related to a program. Each method may result in varying forms of the SSA form with differences in the size of the name space and the number of phi-functions. For instance, Cytron et al. proposes a “minimal” construction for SSA form in their paper titled “Efficiently computing static single assignment form and the control dependence graph,” (ACM Transactions on Programming Languages and Systems, 13(4), 450-490, 1991). The so-called “minimal” construction inserts a phi-function at every point where a control-flow merge or join point brings together two SSA form names originating from a single name of the original code. However, this method may insert phi-functions that are unnecessary in an SSA form. For example, phi-functions may be inserted to resolve converging paths of a variable that are never used after the merge. Such values are also typically referred to as not being “live.”
The so-called “minimal” SSA construction as taught by Cytron et al. relies entirely on the dominance frontier information of the variables of the program, which accurately captures the potential flow of values in a program but ignores the actual facts related to the data-flow. In particular, Cytron et al. ignores any knowledge about the lifetimes of values determined from analyzing their definitions and uses. Because of this, the so-called “minimal” SSA construction method may in fact insert an unnecessary phi-function at a join point or a merge point for a variable that may not be live.
Several proposed methods address the unnecessary phi-functions. For instance, Choi et al. (Jong-Deok Choi, Ron Cytron, and Jeanne Ferrante; “Automatic Construction of Sparse Data Flow Evaluation Graphs,” Conference Record of the Eighteenth Annual ACM Symposium on Principles of Programming Languages, January 1991) propose a method for generating a pruned SSA form wherein all unnecessary phi-functions may be eliminated from the final SSA form. The method proposed by Choi et al. uses a traditional liveness analysis (e.g., via a backward walk) on the original, yet to be renamed variables in a prepass. In a different pass, Choi's method generates an SSA form relying on the liveness analysis, indicating which variables are live. However, such a process may be inefficient and time consuming because it requires multiple passes over the flow graph to generate a pruned SSA form without any unnecessary phi-functions.
A method of generating a so-called “Semi-Pruned” SSA form has also been proposed. For instance, Briggs et al., propose such a method in “Practical improvements to the construction and destruction of static single assignment form,” (Software: Practice and Experience, pages 28(8):859-881, 1998). This method proposes a less expensive local liveness analysis for each block of a control flow graph. However, this method does not always remove all the unnecessary phi-function nodes. Thus, there is a need for a method of generating a pruned SSA form which is efficient and accurate.
SUMMARYDescribed herein are methods for constructing intermediate representations of computer code. More particularly, described herein are methods for a software development tool to construct efficient SSA forms of computer code by determining which phi-function nodes are necessary. In one aspect, potentially necessary phi-function nodes with assignments that reach a non-phi use of a variable corresponding to the assignment are determined to be necessary and included in an SSA form of the computer code.
In another aspect, other phi-function nodes that are relied on by the phi-function nodes whose assignments reach non-phi uses are also determined to be necessary and included in an SSA form of the computer code. For instance, those phi-function nodes that reach a phi-function node previously determined to be necessary are also determined to be necessary.
Furthermore, in another aspect, a phi-function dependency data structure is constructed to determine whether potentially necessary phi-function nodes may be confirmed to be necessary based on their relationship to other phi-function nodes already confirmed to be necessary. In a further aspect, a pruned SSA form may be constructed during a forward reachability walk of a control flow representation of the original program.
In yet another aspect, the pruned SSA form of a program may be constructed by initially assuming that potentially necessary phi-function nodes having an unkown status (e.g., initially all the nodes) are unnecessary and changing their liveness status upon determining that they are necessary.
Additional features and advantages will be made apparent from the following detailed description of illustrated embodiments, which proceeds with reference to accompanying drawings.
In an SSA form for the program, the assignments would be explicit such that no inference would be needed. Thus, as shown in
In any of the examples herein, a phi-function can accept two or more parameters. A phi-function is sometimes called a “static single assignment phi-function.”
Ensuring that each use refers to exactly one name becomes more challenging as control flows become more complex. In particular, if a named variable in original code is defined along two different but converging paths, the SSA form of the code would have two different names and possibly two different values assigned for each of the names depending on the chosen control flow path.
In an SSA form (
However, a phi-function is not necessary at every merge point or join point. For example, a phi-function placed at a merge point may involve a variable for which there is no subsequent use. Such a phi-function is not live (and is therefore unnecessary) and need not be included in SSA form of the program. In any of the examples herein, those phi-functions determined to be live can be considered to be necessary, and those that are determined to not be live (dead) can be considered to be unnecessary.
Some other phi-functions may be necessary (e.g., they may involve a variable for which there is a subsequent use). For instance, the phi-function at 235 in
Some methods of generating an SSA-form cannot make the distinction between necessary and unnecessary phi-functions and thus, may place them at all merge points. For instance, the so-called “minimal” construction taught by Cytron et al. above is one such method.
Exemplary Semi-pruned SSA FormIn any of the examples herein, although the terms “prune” or “pruned” are used, a technique need not remove phi-nodes. For example, a technique can determine which phi-nodes to add (e.g., rather than removing them), and still result in an SSA representation that has fewer phi-nodes than an unpruned SSA representation.
Exemplary ProgramsAs described herein, a program includes any set of software instructions (e.g., a procedure, sub-routines, method, or the like).
An Exemplary Overall Method for Generating an SSA Form by Adding Necessary Phi-function NodesOne efficient SSA representation of a program may include just the necessary phi-function nodes. According to the method described in
Including phi-function nodes in an SSA form may comprise, for example, changing a status or otherwise taking action that results in the phi-function being included in the resulting SSA form. For example, all phi-functions can be assumed to be unnecessary but remain in the SSA form. Subsequently, those that are included (e.g., by changing their status) remain and others are removed.
The methods described herein, can be implemented by computer-executable instructions (e.g., stored in one or more computer-readable mediums).
An Exemplary Detailed Method for Generating a Pruned SSA Form by Determining Unnecessary Phi-function NodesThen at 420, a reachability walk may be conducted on the control flow representation such that its branches and sub-branches are visited at least once for analysis. For instance, one such suitable walk may be a forward reachability walk such as a depth-first walk. Other walks may also be used. At 420, during such a reachability walk, among the potential phi-function assignment nodes that are encountered, it may be determined that at least some of these phi-function assignments or definitions of their respective variables in fact do directly reach non-phi uses (non-phi uses are sometimes referred to as real uses). Such potentially necessary phi-functions whose assignments reach non-phi uses may be marked as necessary and thus, included even in a pruned form of SSA control flow representation. For instance, in
However, not all phi-function nodes may be determined to be necessary based solely on the direct reachability of their assignments to non-phi uses. Some phi-functions may be determined to be necessary based on their dependency relationships to other phi-functions whose assignments directly reach non-phi uses of their respective variables. Thus, at 425, those phi-function nodes that directly reach other phi-function nodes which were previously determined to be necessary (e.g., because they reach a non-phi use) are also determined to be necessary.
However, depending on the flow of control, some of these dependency relationships may be, several times removed from a successor assignment that in fact reaches a non-phi use. Thus, at 430, during the reachability walk, a phi-function dependency graph may be generated to capture the dependency relationships between the various potential phi-function assignments nodes and any related subsequent phi-function uses of their respective variables in the control flow representation of a program. If need be, a dependency graph may also record relationships between all assignments and their subsequent uses not necessarily just the phi-function nodes.
Later at 440, based on the relationships between the various potential phi-function nodes as established via a phi-function dependency graph, a live-closure procedure may be implemented to determine which of the phi-functions nodes in the phi-function dependency graph are predecessors of phi-function nodes currently determined to be necessary. These phi-functions too then would be determined to be necessary and if these phi-function nodes, newly determined to be necessary, have any other phi-function predecessors they too may be determined to be necessary. Depending on the control flow scenarios, this process may go on further determining liveness in accordance with the dependency chains. Thus, at the end of such a live-closure process for each of the variables of the program the necessary phi-functions are confirmed and conversely, the unnecessary phi-nodes are also known. Later, only those phi-function nodes determined to be necessary may be included in the resulting pruned SSA form with the unnecessary phi-function nodes eliminated.
An Exemplary Method for Generating a Pruned SSA Form by Renaming the Variables and Determining Unnecessary Phi-function Nodes During a Single Reachability WalkA renaming process for constructing an SSA form may comprise identifying the various assignments associated with the variables of the original program and assigning new names for the variables such that each variable name corresponds to a single assignment. For instance, if a program had given a name “X” to a certain variable used in the program then a first assignment to the variable in the program's representation may be renamed “X1” whereas another assignment may be renamed as “X2” and so on.
The above described method for generating a pruned SSA form may also be implemented concurrently with renaming the variables for generating an SSA form. For instance, during the reachability walk described above, any method of renaming variables may be applied to concurrently accord new names to variables as control flow scenarios of assignments and uses unfold during the reachability walk. A separate reachability walk of the original unrenamed control flow representation of the original code of the program is not needed.
Thus, as shown in
In any of the examples described herein, an optimistic assumption can be implemented by initially marking phi-function nodes (e.g., those with unknown status) as unnecessary (e.g., dead).
Exemplary WalksIn any of the example described herein, determining which phi-nodes are necessary can be accomplished via a walk of a control flow representing a program. For example, a single pass through the program is sufficient. Accordingly, a potential phi-node need be visited only once.
An Exemplary Method of Constructing a Pruned SSA Form with the Initial Optimistic Assumption that Phi-function Nodes are Unnecessary or DeadIn one exemplary form of the method 400 of
The method 450 of
The method 400 of
At 485, an assignment record stack associated with a variable may be first initialized to be empty if it is not already so. At 490, during the reachability walk of a control flow representation related to a program code, data descriptive of an assignment node may be added to the stack. Also, as described at 495, as uses of the subject variable are encountered, a phi-function dependency data structure (e.g., dependency flow graph) may also be constructed by recording edges from nodes on top of the assignment stack to their related subsequent uses reached by the top assignment node on the stack. Later during a live-closure phase (e.g., 440) these edges may be used to determine which of the phi-functions (initially assumed to be dead or unnecessary) may in fact be necessary because of their dependency relationships to other phi-functions that directly reach non-phi uses or necessary phi-uses of the variable in question. Also, at 490, nodes related to assignments may be removed from the stack once it is determined that the particular node in question does not reach a previously unvisited branch of the control flow representation.
A Programmatic Implementation of a Method of Generating a Pruned SSA Form Via Constructing a Phi-function Dependency GraphStarting at a first node, which typically is the entry block to a control flow representation of a program, an assignment stack (e.g., 490) is maintained and updated by pushing assignment nodes onto the stack at 510 and removing them after the return statement at 515 brings the program execution control back to the “Pop” statement at 520. As the stack grows, edges are added from the top of the stack to subsequent uses at 525. As described above, this part of the process helps construct the phi-function dependency data structure (495). Also, assignments on the stack that directly reach non-phi uses or necessary phi-uses are also marked as necessary by the “mark top(stack) as live” statement at 530 guarded by the “if” statement at 535. Later the liveness information updated during the process (500 of
As noted above, some of the potentially necessary phi-function nodes may be confirmed to be necessary during the process of generating a phi-function dependency graph (e.g., 500 as described above with reference to
In one method shown in
Furthermore, according to one process described above for generating a pruned SSA form, initially, all nodes 1-7 are assumed to not be necessary (dead) for the purposes of analysis. Thus, as illustrated in
For instance, according to the process 400 of
Next, the “DFS-SSA-Search(current-node, stack)” 540 procedure is called again for each of the successors of node 2(705), which are nodes 3(703) and 7(704). In the exemplary reachability walk (e.g., depth-first) either node 3(703) or node 7(704) may be chosen. For the purposes of illustration, here in this case node 3(703) may be chosen to be the next current node. As a simple assignment node, node 3(703) is just pushed onto the stack at 753 and no edges are built in this iteration. Next “DFS-SSA-Search(current-node, stack)” 540 procedure is called with the successor node 4(710) as the current node. As before node 4(710) comprises a phi-use. Thus, at 525 an edge is added from the current top of the node stack 550, which is the node 3(703) at 753, and use at node 4(710). This edge may be recorded as shown at 777 in
Next, the “DFS-SSA-Search(current-node, stack)” 540 is called with the successor node 6(715) as the current node. Node 6(715) is a phi-function node comprising a phi-use. Thus, at 525 an edge is added to the dependency data structure 775 from the current top of the node stack 750, which is node 4(710), to its corresponding use at node 6(715). Thus, at 779 in
Each time the return path counters a previously visited assignment node, at 520, it is removed off the stack starting with the node 6(715) being removed at 756. After node 3(703) is removed at 757 control returns back to node 2(705) on the return path. This time the previously unvisited branch comprising node 7(704) is visited by calling the “DFS-SSA-Search(current-node, stack)” with node 7(704) as the current node. Node 7(704) is an assignment node. As a result, node 7(704) is pushed onto the stack at 755 which reflects the state of assignment stack 750 after node 3(703) was removed at 757. The successor node of node 7(704) is the previously visited node 4(710), which is a phi-use node. Thus at 781, an edge is added from node 7(704) which would be the current top of the stack to node 4(710). Also then at 535, the current top of the assignment node stack node 7(704) is updated to a status of necessary, which is indicated at 745 in
During a live-closure process such as the implementation described in
At the end of live-closure process it can be determined that among three potentially necessary phi-function nodes that were identified earlier (nodes 2, 4 and 6 at 705, 703 and 715 respectively in
An analysis of the control flow representation of
During the analysis, assignment nodes 1, 2, 3 and 4 at 801, 805, 802 and 810 respectively of
Since node 2(805) was previously visited once, the process begins to unwind while removing assignment nodes (e.g., as shown at 857-859 in
Using the completed dependency data structure 875 and the updated liveness data from 840, the live-closure process may now be implemented. Applying the live-closure process shows that node 6(815) should also have its liveness data updated to necessary at 848 because node 6(815) is a predecessor of the node 2(805) which is now set to a liveness status of necessary. Thus, according to the analysis, now all potentially necessary phi-function nodes (i.e., nodes 2, 4 and 6 at 805, 810 and 815 respectively) are confirmed in fact to be necessary.
Another Exemplary Pruning of an SSA form wherein Some of the Potential Phi-function Nodes are Confirmed to be UnnecessaryAccording to the process implemented as shown in
Later during the live-closure phase, based on the dependencies indicated in the phi-function dependency data structure it can be confirmed that no other potential phi-function node from the control flow representation has a potential assignment that may reach a non-phi use. Node 3(905), which is the only phi-function node whose liveness status is updated to necessary, during the reachability walk, does not have any predecessors in the dependency data structure 975 that is not already marked necessary. As a result, no other phi-function is updated to a necessary status. Thus, in a pruned form of the SSA representation of a program, node 3(905) is the only phi-function node that is included.
Another Exemplary SSA Representation wherein all the Potential Phi-function Nodes are Confirmed to be NecessaryAs noted above with reference to
As result of the non-phi uses of variable X at nodes 2 and 4 at 1002 and 1003 respectively, nodes 1 and 3 at 1004 and 1005 respectively, will have their liveness status updated to necessary as shown at 1041 and 1042 respectively. Node 7(1015) is also changed to a liveness status of necessary at 1043 in
During the initial reachability walk analysis, according to the exemplary implementation 1100 at
Similarly, with respect to variable W, it can be determined that the phi-assignment at node 4(1210) reaches the non-phi use at node 6(1203), which can result in node 4(1210) to be listed as necessary at 1242. Also, the phi-function assignment related to variable X at node 8(1220) is determined to reach a non-phi use at node 9(1204), which can cause it now to be listed as necessary at 1243. Thus, at the end of the reachability walk, the phi-function nodes 3(1205), 4(1210) and 8(1220) are determined to be necessary. Also, the dependency relationships between the various assignments and their uses are recorded. The completed data structure for recording the respective edges between the various assignment and use nodes may be as shown in
During the live-closure process, the updated liveness data 1240 and the corresponding dependency data from
The methods of constructing a pruned SSA form discussed above present several advantages. For one, the process can dependably yield a fully pruned SSA without the need for a traditional pre-pass full liveness analysis (e.g., via a backward walk) requiring multiple passes over the control flow representations of the original code (e.g., as used in Choi et al.) Also, the renaming phase of constructing an SSA form may be concurrently implemented with the reachability walk (e.g., a forward walk) phase described above for confirming which among the potentially necessary phi-function nodes are indeed necessary. As a result, the methods described above can be much less computationally expensive than the other known methods of constructing a pruned SSA form. Also, unlike the methods of constructing semi-pruned SSA forms, the methods described above can result in the unnecessary phi-function nodes being identified accurately.
The following table illustrates that the results of one exemplary implementation of the novel methods described above result in significant improvement in the processing time required to generate a pruned SSA form when compared to the methods of Choi, et. al.
As table 1 shows, results of test conducted on a computer equipped with a Pentium® 4 2.6 gigahertz processor running a number of programs. Technique A generated a pruned SSA form via a technique based on that shown in
With reference to
The PC 1300 further includes a hard disk drive 1314 for reading from and writing to a hard disk (not shown), a magnetic disk drive 1316 for reading from or writing to a removable magnetic disk 1317, and an optical disk drive 1318 for reading from or writing to a removable optical disk 1319 (such as a CD-ROM or other optical media). The hard disk drive 1314, magnetic disk drive 1316, and optical disk drive 1318 are connected to the system bus 1306 by a hard disk drive interface 1320, a magnetic disk drive interface 1322, and an optical drive interface 1324, respectively. The drives and their associated computer-readable media provide nonvolatile storage of computer-readable instructions, data structures, program modules, and other data for the PC 1300. Other types of computer-readable media which can store data that is accessible by a PC, such as magnetic cassettes, flash memory cards, digital video disks, CDs, DVDs, RAMs, ROMs, and the like, may also be used in the exemplary operating environment.
A number of program modules may be stored on the hard disk, magnetic disk 1317, optical disk 1319, ROM 1308, or RAM 1310, including an operating system 1330, one or more application programs 1332, other program modules 1334, and program data 1336. A user may enter commands and information into the PC 1300 through input devices such as a keyboard 1340 and pointing device 1342 (such as a mouse). Other input devices (not shown) may include a digital camera, microphone, joystick, game pad, satellite dish, scanner, or the like. These and other input devices are often connected to the processing unit 1302 through a serial port interface 1344 that is coupled to the system bus 1306, but may be connected by other interfaces such as a parallel port, game port, or universal serial bus (USB). A monitor 1346 or other type of display device is also connected to the system bus 1306 via an interface, such as a video adapter 1348. Other peripheral output devices, such as speakers and printers (not shown), may be included.
The PC 1300 may operate in a networked environment using logical connections to one or more remote computers, such as a remote computer 1350. The remote computer 1350 may be another PC, a server, a router, a network PC, or a peer device or other common network node, and typically includes many or all of the elements described above relative to the PC 1300, although only a memory storage device 1352 has been illustrated in
When used in a LAN networking environment, the PC 1300 is connected to the LAN 1354 through a network interface 1358. When used in a WAN networking environment, the PC 1300 typically includes a modem 1360 or other means for establishing communications over the WAN 1356, such as the Internet. The modem 1360, which may be internal or external, is connected to the system bus 1306 via the serial port interface 1344. In a networked environment, program modules depicted relative to the personal computer 1300, or portions thereof, may be stored in the remote memory storage device. The network connections shown are exemplary, and other means of establishing a communications link between the computers may be used.
AlternativesHaving described and illustrated the principles of our invention with reference to the illustrated embodiments, it will be recognized that the illustrated embodiments can be modified in arrangement and detail without departing from such principles. For instance, potentially necessary phi-functions may be identified by any method. Also, many suitable data structures such as stacks or tables have been described above for illustrating the principles of the SSA form pruning methods. However, the particular form and combination of data structures are merely illustrative examples and do not limit what is claimed below.
It should also be understood that the programs, processes, or methods described herein are not related or limited to any particular type of computer apparatus. Various types of general purpose or specialized computer apparatus may be used with or perform operations in accordance with the teachings described herein. Actions described herein can be achieved by computer-readable media (e.g., Compact Disk, Floppy Disk, Hard Disk, Memory etc.), comprising computer-executable instructions for performing such actions. Elements of the illustrated embodiment shown in software may be implemented in hardware and vice versa.
Also, the technologies from any example can be combined with the technologies described in any one or more of the other examples. In view of the many possible embodiments to which the principles of the invention may be applied, it should be recognized that the illustrated embodiments are examples of the invention and should not be taken as a limitation on the scope of the invention. Rather, the scope of the invention includes what is covered by the following claims. We therefore claim as our invention all that comes within the scope and spirit of these claims.
Claims
1. A method of generating a pruned static single assignment representation of a computer program, the method comprising:
- receiving data indicative of potentially necessary phi-function nodes;
- implementing an optimistic assumption that phi-function nodes are not necessary by initially marking nodes with unknown status as unnecessary;
- during a forward reachability walk of a control flow representation of the computer program, determining phi-function nodes whose assignments reach non-phi uses as necessary;
- during the forward reachability walk of a control flow representation of the computer program, determining other phi-function nodes that are relied on by the phi-function nodes whose assignments reach non-phi uses as necessary;
- and constructing a pruned static single assignment representation of the computer program by including only those phi-function nodes that are determined to be necessary in the static single assignment representation.
2. The method of claim 1, wherein determining the phi-function nodes whose assignments reach non-phi uses comprises: maintaining a record of the phi-function assignments encountered during a reachability walk of a control flow representation of the computer program; and upon reaching a non-phi use, determining which of the previously encountered phi-function assignments it relies on.
3. The method of claim 1, wherein determining the other phi-function nodes that are relied on by the phi-function nodes whose assignments reach non-phi uses comprises: maintaining a record of the phi-function assignments encountered during a reachability walk of a control flow representation of the computer program; upon encountering a necessary phi-function node, determining which of the previously encountered assignments it relies on.
4. The method of claim 1, wherein determining the other phi-function nodes that are relied on by the phi-function nodes whose assignments reach non-phi uses comprises: determining relationships between phi-function nodes by constructing a phi-function dependency data structure comprising representations of dependency relationships between phi-function nodes.
5. The method of claim 4, wherein the phi-function dependency data structure comprises: edges from the phi-function nodes comprising a potential assignment related to one or more variables of the computer program to the phi-function nodes comprising a potential use of the one of the one or more variables.
6. The method of claim 4, wherein determining the other phi-function nodes further comprises: conducting a live-closure of the phi-function dependency data structure.
7. The method of claim 1, wherein the forward reachability walk is a depth-first walk.
8. The method of claim 1, wherein determining which of the potentially necessary phi-function nodes are necessary comprises: determining those potentially necessary phi-function nodes whose assignments reach a necessary phi-function node or a non-phi use of one or more variables of the computer program.
9. The method of claim 1, wherein determining which of the potentially necessary phi-function nodes are necessary comprises: constructing a phi-function dependency data structure comprising representations of dependency relationships between the potentially necessary phi-function nodes.
10. The method claim 9, wherein constructing the phi-function dependency data structure comprises: maintaining a record of assignment nodes encountered during the forward reachability walk; and recording edges from the recorded assignments nodes to nodes comprising a use of the one of one or more variables of the computer program.
11. The method of claim 9, wherein determining which of the potentially necessary phi-function nodes are necessary further comprises: completing a live-closure of the phi-function dependency data structure wherein the potentially necessary phi-function nodes identified in the phi-function dependency data structure as predecessors of phi-functions previously determined to be necessary are also determined to be necessary.
12. The method of claim 1, further comprising maintaining a data structure comprising liveness status of the potentially necessary phi-function nodes, wherein the liveness status associated with the potentially necessary phi-function nodes is initially recorded as unnecessary and updated when the potentially necessary phi-function nodes are determined to be necessary.
13. At least one computer-readable medium having stored thereon computer-executable instructions for performing the method of claim 1.
14. In a computer system comprising a complier program for compiling computer programs a method of generating a pruned static single assignment representation of the computer program, the method comprising:
- receiving data related to potentially necessary phi-function nodes;
- initializing liveness status of the potentially necessary phi-function nodes as unnecessary;
- constructing a phi-function dependency graph for determining phi-functions whose assignments reach non-phi-uses and for determining other phi-function nodes that are relied on by the phi-function nodes whose assignments reach non-phi uses,
- the construction comprising:
- during a forward reachability walk,
- changing the liveness status to neccessary for those potentially necessary phi-function nodes comprising: the phi-function nodes whose assignments reach non-phi uses and the other phi-function nodes that are relied on by the phi-function nodes whose assignments reach non-phi uses;
- and constructing a pruned static single assignment representation of the computer program by including only those phi-function nodes that are determined to be necessary in the static single assignment representation.
15. The method of claim 14, further comprising changing the liveness status to necessary for those potentially necessary phi-function nodes that are identified in the phi-function dependency graph as predecessors of necessary phi-function nodes.
16. The method of claim 14, wherein constructing the phi-function dependency graph comprises: recording edges from the potentially necessary phi-function nodes comprising a potential assignment associated with one or more variables of the computer program to the potentially necessary phi-function nodes comprising a potential use of the one or more variables.
17. The method of claim 1, wherein determining phi-function nodes whose assignments reach non-phi uses further comprises marking the phi-function nodes whose assignments reach non-phi uses as necessary; wherein determining other phi-function nodes that are relied on by the phi-function nodes whose assignments reach non-phi uses further comprises marking the other phi-function nodes that are relied on by the phi-function nodes whose assignments reach non-phi uses as necessary; and further comprising not including the nodes marked as unnecessary in the static single assignment representation of the computer program.
5448737 | September 5, 1995 | Burke et al. |
5659754 | August 19, 1997 | Grove et al. |
5768596 | June 16, 1998 | Chow et al. |
6026241 | February 15, 2000 | Chow et al. |
6151706 | November 21, 2000 | Lo et al. |
6182284 | January 30, 2001 | Sreedhar et al. |
6427234 | July 30, 2002 | Chambers et al. |
6571387 | May 27, 2003 | Chow et al. |
6738967 | May 18, 2004 | Radigan |
20040098710 | May 20, 2004 | Radigan |
20050166194 | July 28, 2005 | Rubin et al. |
20060070050 | March 30, 2006 | Chen |
- Cooper, Keith, Simpson, L. Taylor, Vick, Christopher A.. “Operartor Strength Reduction.” ACM Transaction on Programming Languages and Systems 23 No. 5(2001): 603-623.
- Kaplan, Adam, Brisk, Philip, Kastner, Ryan. “Data Communication Estimation and Reduction for Reconfigurable Systems.” Annual ACM IEEE Design Automation Conference (2003): 616-621.
- Ron Cytron, Jeanne Ferrante, Barry K.Rosen, Mark N. Wegman, and F. Kenneth Zadeck. “An efficient method for computing static single assignment form”, Annual ACM Symposium on Principles of Programming Languages, 16(1989): 25-35.
- Automatic Construction of Sparse Data Flow Evaluation Graphs, Jong-Deok Choi, Ron Cytron and Jeanne Ferrante, In Conference Record of the 20th Annual Association of Computing Machinery Symposium on Principles of Programming Languages, 1991, pp. 55-66.
- Efficiently Computing Static Single Assignment Form and the Control Dependence Graph, Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N. Wegman and F. Kenneth Zadeck, Association of Computing Machinery, vol. 13, No. 4, Oct. 1991, pp. 451-490.
- Practical Improvements to the Construction and Destruction of Static Single Assignment Form, Preston Briggs, Keith D. Cooper, Timothy J. Harvey, and L. Taylor Simpson, Software-Parctioce and Experience, vol. 28, Issue 8, pp. 859-881, Published by John Wiley & Sons, Inc., Jul. 1998.
- Efficiently Computing Ø-Nodes On-The-Fly, Ron K. Cytron and Jeanne Ferrante, Association of Computing Machinery, vol. 17, No. 3, May 1995, pp. 487-506.
- Single-Pass Generation of Static Single-Assignment Form for Structured Languages, Marc M. Branis and Hanspeter Mössenböck, Association of Computing Machinery, vol. 16, No. 6, Nov. 1994, pp. 1684-1698.
- Data Specialization, Todd B. Knoblock and Erik Ruf, Microsoft Research, Advanced Technology Division, Microsoft Corporation, Feb. 5, 1996.
- Algorithms for Computing the Static Single Assignment Form, Gianfranco Bilardi and Keshav-Pingali, Association of Computing Machinery, vol. 50, No. 3, May 2003, pp. 375-425.
- Characterizing the Optimility of Minimal SSA Using the Value Flow Graph, Hideki Saito, Constantine D. Polychronopoulos, Center for Super Computing Research and Development, University of Illinois at Urbana, Champaign, Jul. 17, 1996.
Type: Grant
Filed: Jun 7, 2004
Date of Patent: Jul 8, 2008
Patent Publication Number: 20050273777
Assignee: Microsoft Corporation (Redmond, WA)
Inventors: Vinod K. Grover (Mercer Island, WA), Weiping Hu (Sammamish, WA)
Primary Examiner: Wei Zhen
Assistant Examiner: Matthew J Brophy
Attorney: Klarquist Sparkman, LLP
Application Number: 10/863,000
International Classification: G06F 9/45 (20060101);