Skip to main content

Structured programs have small tree-width and good register allocation

extended abstract

  • Conference paper
  • First Online:
Graph-Theoretic Concepts in Computer Science (WG 1997)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1335))

Included in the following conference series:

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

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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.

    Google Scholar 

  2. A.V. Aho, R. Sethi, and J.D. Ullman, Compilers: Principles, Techniques, and Tools, Addison-Wesley, Reading, Mass., 1986.

    Google Scholar 

  3. 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.

    Google Scholar 

  4. S. Arnborg, J. Lagergren, and D. Sesse, Easy problems for tree-decomposable graphs, J. Algorithms12 (1991) 308–340.

    Google Scholar 

  5. 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.

    Google Scholar 

  6. 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.

    Google Scholar 

  7. H.L. Bodlaender, A Tourist Guide Through Treewidth, Acta Cybernetica11 (1993) 1–23.

    Google Scholar 

  8. H.L. Bodlaender, A Linear Time Algorithm for Finding Tree-Decompositions of Small Treewidth, in “Proc. 25th STOC,” pp. 226–234, 1993.

    Google Scholar 

  9. H.L. Bodlaender, Complexity of Path Forming Games, Theor. Comp. Sc.110 (1993) 215–245.

    Google Scholar 

  10. 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.

    Google Scholar 

  11. 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.

    Google Scholar 

  12. P. Briggs, Register allocation via graph coloring, PhD Thesis, Rice University, 1992.

    Google Scholar 

  13. 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.

    Google Scholar 

  14. 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.

    Google Scholar 

  15. G.J. Chaitin, Register Allocation and Spilling via Graph Coloring, in “Proc. SIGPLAN'82 Symp. Compiler Construction,” pp. 98–105, 1982.

    Google Scholar 

  16. 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.

    Google Scholar 

  17. B. Courcelle and M. Mosbah, Monadic second-order evaluations on tree-decomposable graphs, 6 (1993) 49–82.

    Google Scholar 

  18. O.J. Dahl, E.W. Dijkstra, and C.A.R. Hoare, Structured Programming, Academic Press, London, 1972.

    Google Scholar 

  19. N. Dendris, L. Kirousis, and D. Thilkos, Fugitive-serach gamses on graphs and related parameters, Theor. Comp. Sc.172 (1997) 233–254.

    Google Scholar 

  20. E.W. Dijkstra, Go To Statement Considered Harmful, Comm. ACM11, 3 (1968) 147–148.

    Google Scholar 

  21. 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.

    Google Scholar 

  22. 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.

    Google Scholar 

  23. 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.

    Google Scholar 

  24. F. Gavril, The Intersection Graph of Subtrees in Trees Are Exactly the Chordal Graphs, J. Comb. Th. Ser. B16 (1974) 47–56.

    Google Scholar 

  25. 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.

    Google Scholar 

  26. M. M. Halldórsson, A Still Better Performance Guarantee for Approximate Graph Coloring, Inf. Proc. Lett.45 (1993) 19–23.

    Google Scholar 

  27. S. Kannan and T. Proebsting, Register Allocation in Structured Programs, in “Proc. 6th SODA,” pp. 360–368, 1995.

    Google Scholar 

  28. B.R. Kernighan and D.M. Ritchie, The C Programming Language, Prentice-Hall, New Jersey, 1978.

    Google Scholar 

  29. D.E. Knuth, Structured Programming with Go To Statements, ACM Computing Surveys6, 4 (1974) 261–301.

    Google Scholar 

  30. C. Lund and M. Yannakakis, On the Hardness of Approximating Minimization Problems, J. ACM41 (1994) 960–981.

    Google Scholar 

  31. P. Naur, Revised Report on the Algorithmic Language Algol 60, Comm. ACM6, 1 (1963) 1–17.

    Google Scholar 

  32. P. Naur, Go To Statements and Good Algol Style, BIT3, 3 (1963) 204–208.

    Google Scholar 

  33. 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.

    Google Scholar 

  34. 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.

    Google Scholar 

  35. N. Robertson and P.D. Seymour, Graph Minors 1: Excluding a Forest, J. Comb. Th. Ser. B35 (1983) 39–61.

    Google Scholar 

  36. N. Robertson and P.D. Seymour, Graph Minors XIII: The Disjoint Paths Problem. J. Comb. Th. Ser. B63 (1995) 65–110.

    Google Scholar 

  37. M. Thorup, Structured Programs have Small Tree-Width and Good Register Allocation, Latest full version: http,//www.diku.dk/≈mtharsap/PAPERS/register.ps.gz.

    Google Scholar 

  38. 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.

    Google Scholar 

  39. N. Wirth, The Programming Language PASCAL, Acta Informatics1 (1971), 35–63.

    Google Scholar 

  40. N. Wirth, Programming in Modula-2 (3rd corr. ed.), Springer-Verlag, Berlin, New York, 1985.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Rolf H. Möhring

Rights and permissions

Reprints 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

Publish with us

Policies and ethics