Abstract
The register allocation problem for an imperative program is often modelled as the coloring problem of the interference graph of the control-flow graph of the program. The interference graph of a flow graph G is the intersection graph of some connected subgraphs of G. These connected subgraphs represent the lives, or life times, of variables, so the coloring problem models that two variables with overlapping life times should be in different registers. For general programs with unrestricted gotos, the interference graph can be any graph, and hence we cannot in general color within a factor O(n ɛ) from optimality unless NP=P.
It is shown that if a graph has tree-width k, we can efficiently color any intersection graph of connected subgraphs within a factor ([k/2] + 1) from optimality. Moreover, it is shown that structured (≡ goto-free) programs, including, for example, short. circuit evaluations and multiple exits from loops, have tree-width at most 6. Thus, for every structured program, we can do register allocation efficiently within a factor 4 from optimality, regardless of how many registers are needed.
The bounded tree-decomposition may be derived directly from the parsing of a structured programs, and it implies that the many techniques for bounded tree-width may now be applied in control-flow analysis, solving problems in linear time that are NP-hard, or even P-space hard, for general graphs
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
Preview
Unable to display preview. Download preview PDF.
References
S. Alstrup, P.W. Lauridsen, and M. Thorup, Generalized dominators for structured programs. In Proceedings of the 3rd Static Analysis Symposium, LNCS 1145, pages 42–51, 1996.
A.V. Aho, R. Sethi, and J.D. Ullman, Compilers: Principles, Techniques, and Tools, Addison-Wesley, Reading, Mass., 1986.
S. Arnborg, D.G. Corneil, and A. Proskorowski, Complexity of Finding Embeddings in a k-Tree, SIAM J. Alg. Disc. Meth.8 (1987) 277–284.
S. Arnborg, J. Lagergren, and D. Sesse, Easy problems for tree-decomposable graphs, J. Algorithms12 (1991) 308–340.
S. Arnborg and A. Proskorowski, Linear time algorithms for NP-hard problems restricted to partial k-trees, SIAM J. Alg. Disc. Meth.23 (1989) 11–24.
L. Birkdal, M. Tofte, and M. Vejlstrup, From region inference to von Neyman Machines via region representation inference. in “Proc. POPL'96,” pp. 171–183, 1996.
H.L. Bodlaender, A Tourist Guide Through Treewidth, Acta Cybernetica11 (1993) 1–23.
H.L. Bodlaender, A Linear Time Algorithm for Finding Tree-Decompositions of Small Treewidth, in “Proc. 25th STOC,” pp. 226–234, 1993.
H.L. Bodlaender, Complexity of Path Forming Games, Theor. Comp. Sc.110 (1993) 215–245.
H.L. Bodlaender, J.R. Gilbert, H. Hapsteinsson, and T. Kloks, Approximating Treewidth, Pathwidth, Frontsize, and Shortest Elimination Tree, J. Algorithms18, 2 (1995) 221–237.
R.B. Boris, R.C. Parker, and C.A. Tovey, Automatic Generation of Linear-Time Algorithms from Predicate Calculus Descriptions of Problems on Recursively Constructed Graph Families, Algorithmica7 (1992) 555–581.
P. Briggs, Register allocation via graph coloring, PhD Thesis, Rice University, 1992.
P. Briggs, K.D. Cooper, K. Kennedy, and L. Torozon, Coloring heuristics for register allocation, in “Proc. SIGPLAN'89 Conf. Programming Language Design and Implementation,” pp. 275–284, 1989.
D. Callahan and B. Koblenz, Register allocation via hierarchical graph coloring, in “Proc. SIGPLAN'91 Conf. Programming Language Design and Implementation,” pp. 192–203, 1991.
G.J. Chaitin, Register Allocation and Spilling via Graph Coloring, in “Proc. SIGPLAN'82 Symp. Compiler Construction,” pp. 98–105, 1982.
G.J. Chaitin, M.A. Auslander, A.K. Chandra, J. Cocks, M.E. Hoplins, and P.W. Markstein, Register allocation via graph coloring, Computer Languages6 (1981) 47–57.
B. Courcelle and M. Mosbah, Monadic second-order evaluations on tree-decomposable graphs, 6 (1993) 49–82.
O.J. Dahl, E.W. Dijkstra, and C.A.R. Hoare, Structured Programming, Academic Press, London, 1972.
N. Dendris, L. Kirousis, and D. Thilkos, Fugitive-serach gamses on graphs and related parameters, Theor. Comp. Sc.172 (1997) 233–254.
E.W. Dijkstra, Go To Statement Considered Harmful, Comm. ACM11, 3 (1968) 147–148.
A.P. Ershov, Reduction of the problem of memory allocation in programming to the problem of colouring the vertices of a graph, Doklady Academii Nauk SSSR142, 4 (1962) 785–787. English version in Soviet Mathematics3 (1962) 163–165.
M.R. Carey, D.S. Johnson, G.L. Miller, and C.H. Papadimitriou, The Complexity of Coloring Circular Arcs and Chords, SIAM J. Alg. Discr. Meth.1, 2 (1980) 216–227.
F. Gavril, Algorithms for Minimum Coloring; Maximum Clique, Minimum Covers by Cliques, and Maximum Independent Set of Chordal Graphs, SIAM J. Comp.1, 2 (1972) 180–187.
F. Gavril, The Intersection Graph of Subtrees in Trees Are Exactly the Chordal Graphs, J. Comb. Th. Ser. B16 (1974) 47–56.
R. Gupta, M.L. Soffa, and T. Steele, Register allocation via clique separators, in “Proc. SIGPLAN'89 Conf. Programming Language Design and Implementation,” pp. 264–274, 1989.
M. M. Halldórsson, A Still Better Performance Guarantee for Approximate Graph Coloring, Inf. Proc. Lett.45 (1993) 19–23.
S. Kannan and T. Proebsting, Register Allocation in Structured Programs, in “Proc. 6th SODA,” pp. 360–368, 1995.
B.R. Kernighan and D.M. Ritchie, The C Programming Language, Prentice-Hall, New Jersey, 1978.
D.E. Knuth, Structured Programming with Go To Statements, ACM Computing Surveys6, 4 (1974) 261–301.
C. Lund and M. Yannakakis, On the Hardness of Approximating Minimization Problems, J. ACM41 (1994) 960–981.
P. Naur, Revised Report on the Algorithmic Language Algol 60, Comm. ACM6, 1 (1963) 1–17.
P. Naur, Go To Statements and Good Algol Style, BIT3, 3 (1963) 204–208.
T. Nishizeki, K. Takamizawa, and N. Saito, Algorithms for detecting seriesparallel graphs and D-charts, Trans. Inst. Elect. Commun. Eng. Japan59, 3 (1976) 259–260.
C. Norris and L.L. Pollock, Register Allocation over the Program Dependence Graph, in “Proc. SIGPLAN'94 Conf. Programming Language Design and Implementation,” pp. 266–277, 1994.
N. Robertson and P.D. Seymour, Graph Minors 1: Excluding a Forest, J. Comb. Th. Ser. B35 (1983) 39–61.
N. Robertson and P.D. Seymour, Graph Minors XIII: The Disjoint Paths Problem. J. Comb. Th. Ser. B63 (1995) 65–110.
M. Thorup, Structured Programs have Small Tree-Width and Good Register Allocation, Latest full version: http,//www.diku.dk/≈mtharsap/PAPERS/register.ps.gz.
M. Tofte and J-P. Talpin, Implementing the call-by-value lambda-calculus using a stack of regions. in “Proc. POPL'94,” pp. 188–201., 1994.
N. Wirth, The Programming Language PASCAL, Acta Informatics1 (1971), 35–63.
N. Wirth, Programming in Modula-2 (3rd corr. ed.), Springer-Verlag, Berlin, New York, 1985.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1997 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Thorup, M. (1997). Structured programs have small tree-width and good register allocation. In: Möhring, R.H. (eds) Graph-Theoretic Concepts in Computer Science. WG 1997. Lecture Notes in Computer Science, vol 1335. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0024507
Download citation
DOI: https://doi.org/10.1007/BFb0024507
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-63757-8
Online ISBN: 978-3-540-69643-8
eBook Packages: Springer Book Archive