Skip to main content

Eliminating Dead Code on Recursive Data

  • Conference paper
  • First Online:
Static Analysis (SAS 1999)

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

Included in the following conference series:

  • 524 Accesses

Abstract

This paper describes a general and powerful method for dead code analysis and elimination in the presence of recursive data constructions. We represent partially dead recursive data using liveness patterns based on general regular tree grammars extended with the notion of live and dead, and we formulate the analysis as computing liveness patterns at all program points based on program semantics. This analysis yields a most precise liveness pattern for the data at each program point, which is significantly more precise than results from previous methods. The analysis algorithm takes cubic time in terms of the size of the program in the worst case but is very efficient in practice, as shown by our prototype implementation. The analysis results are used to identify and eliminate dead code. The general framework for representing and analyzing properties of recursive data structures using general regular tree grammars applies to other analyses as well.

The authors gratefully acknowledge the support of NSF under grant CCR-9711253 and ONR under grants N00014-99-1-0132 and N00014-99-1-0358.

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

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

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

    Google Scholar 

  2. A. Aiken and B. R. Murphy. Static type inference in a dynamically typed language. In Conference Record of the 18th Annual ACM Symposium on Principles of Programming Languages. ACM, New York, Jan. 1991.

    Google Scholar 

  3. K. Arnold and J. Golsing. The Java Programming Language. Addison-Wesley, Reading, Mass., 1996.

    MATH  Google Scholar 

  4. B. Blanchet. Escape analysis: correctness proof, implementation and experimental results. In Conference Record of the 25th Annual ACM Symposium on Principles of Programming Languages, pages 25–37. ACM, New York, Jan. 1998.

    Google Scholar 

  5. R. Bodík and R. Gupta. Partial dead code elimination using slicing transformations. In Proceedings of the ACM SIGPLAN’ 97 Conference on Programming Language Design and Implementation, pages 159–170. ACM, New York, June 1997.

    Chapter  Google Scholar 

  6. W.-N. Chin. Safe fusion of functional expressions. In [29], pages 11–20.

    Google Scholar 

  7. J. Cocke and K. Kennedy. An algorithm for reduction of operator strength. Commun. ACM, 20(11):850–856, Nov. 1977.

    Article  MATH  Google Scholar 

  8. J. Cocke and J. T. Schwartz. Programming languages and their compilers; preliminary notes. Technical report, Courant Institute of Mathematical Sciences, New York University, 1970.

    Google Scholar 

  9. P. Cousot and R. Cousot. Formal language, grammar and set-constraint-based program analysis by abstract interpretation. In Proceedings of the 7th International Conference on Functional Programming Languages and Computer Architecture, pages 170–181. ACM, New York, June 1995.

    Chapter  Google Scholar 

  10. R. Cytron, J. Ferrante, B. K. Rosen, M. M. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Trans. Program. Lang. Syst., 13(4):451–490, Oct. 1991.

    Article  Google Scholar 

  11. A. De Niel, E. Bevers, and K. De Vlaminck. Program bifurcation for a polymorphically typed functional language. In Proceedings of the Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 142–153. ACM, New York, June 1991.

    Google Scholar 

  12. N. Dershowitz and E. M. Reingold. Calendrical calculations. Software–Practice and Experience, 20(9):899–928, Sept. 1990.

    Article  Google Scholar 

  13. A. Deutsch. On the complexity of escape analysis. In Conference Record of the 24th Annual ACM Symposium on Principles of Programming Languages, pages 358–371. ACM, New York, Jan. 1997.

    Google Scholar 

  14. R. K. Dybvig. The Scheme Programming Language. Prentice-Hall, Englewood Cliffs, N.J., 1987.

    Google Scholar 

  15. Proceedings of the 4th International Conference on Functional Programming Languages and Computer Architecture. ACM, New York, Sept. 1989.

    Google Scholar 

  16. F. Gecseg and M. Steinb. Tree Automata. Akademiai Kiado, Budapest, 1984.

    MATH  Google Scholar 

  17. C. A. Gunter. Semantics of Programming Languages. The MIT Press, Cambridge, Mass., 1992.

    MATH  Google Scholar 

  18. N. Heintze. Set-Based Program Analysis. PhD thesis, Department of Computer Science, Carnegie Mellon University, Pittsburgh, Pennsylvania, Oct. 1992.

    Google Scholar 

  19. N. Heintze. Set-based analysis of ML programs. In Proceedings of the 1994 ACM Conference on LISP and Functional Programming, pages 306–317. ACM, New York, June 1994.

    Chapter  Google Scholar 

  20. F. Henglein. Efficient type inference for higher-order binding-time analysis. In Proceedings of the 5th International Conference on Functional Programming Languages and Computer Architecture, volume 523 of Lecture Notes in Computer Science, pages 448–472. Springer-Verlag, Berlin, Aug. 1991.

    Google Scholar 

  21. J. Hughes. Compile-time analysis of functional programs. In D. Turner, editor, Research Topics in Functional Programming, pages 117–153. Addison-Wesley, Reading, Mass., 1990.

    Google Scholar 

  22. N. D. Jones and S. S. Muchnick. Flow analysis and optimization of LISP-like structures. In Conference Record of the 6th Annual ACM Symposium on Principles of Programming Languages, pages 244–256. ACM, New York, Jan. 1979.

    Google Scholar 

  23. N. D. Jones and S. S. Muchnick. Flow analysis and optimization of LISP-like structures. In S. S. Muchnick and N. D. Jones, editors, Program Flow Analysis, pages 102–131. Prentice-Hall, Englewood Cliffs, N.J., 1981.

    Google Scholar 

  24. S. B. Jones and D. Le Métayer. Compile-time garbage collection by sharing analysis. In [15], pages 54–74.

    Google Scholar 

  25. K. Kennedy. Use-definition chains with applications. J. Comput. Lang., 3(3):163–179, 1978.

    Article  MATH  Google Scholar 

  26. J. Knoop, O. Rüthing, and B. Steffen. Partial dead code elimination. In Proceedings of the ACM SIGPLAN’ 94 Conference on Programming Language Design and Implementation, pages 147–158. ACM, New York, June 1994.

    Chapter  Google Scholar 

  27. J. Launchbury. Projection Factorisations in Partial Evaluation. PhD thesis, Department of Computing, University of Glasgow, Glasgow, Scotland, 1989.

    Google Scholar 

  28. J. Launchbury. Strictness and binding-time analysis: Two for the price of one. In Proceedings of the ACM SIGPLAN’ 91 Conference on Programming Language Design and Implementation, pages 80–91. ACM, New York, June 1991.

    Chapter  Google Scholar 

  29. Proceedings of the 1992 ACM Conference on LISP and Functional Programming. ACM, New York, June 1992.

    Google Scholar 

  30. Y. A. Liu. Dependence analysis for recursive data. In Proceedings of the IEEE 1998 International Conference on Computer Languages, pages 206–215. IEEE CS Press, Los Alamitos, Calif., May 1998.

    Google Scholar 

  31. Y. A. Liu and S. D. Stoller. Dynamic programming via static incrementalization. In Proceedings of the 8th European Symposium on Programming, volume 1576 of Lecture Notes in Computer Science, pages 288–305. Springer-Verlag, Berlin, Mar. 1999.

    Google Scholar 

  32. Y. A. Liu, S. D. Stoller, and T. Teitelbaum. Discovering auxiliary information for incremental computation. In Conference Record of the 23rd Annual ACM Symposium on Principles of Programming Languages, pages 157–170. ACM, New York, Jan. 1996.

    Google Scholar 

  33. Y. A. Liu, S. D. Stoller, and T. Teitelbaum. Static caching for incremental computation. ACM Trans. Program. Lang. Syst., 20(3):546–585, May 1998.

    Article  Google Scholar 

  34. Y. A. Liu and T. Teitelbaum. Systematic derivation of incremental programs. Sci. Comput. Program., 24(1):1–39, Feb. 1995.

    Article  MATH  Google Scholar 

  35. D. Melski and T. Reps. Interconvertibility of set constraints and conext-free language reachability. In Proceedings of the 1997 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation. ACM, New York, June 1997.

    Google Scholar 

  36. D. Melski and T. Reps. Interconvertibility of a class of set constraints and context-free language reachability. Theoret. Comput. Sci., 1999. Accepted.

    Google Scholar 

  37. R. Milner, M. Tofte, and R. Harper. The definition of Standard ML. The MIT Press, Cambridge, Mass., 1990.

    Google Scholar 

  38. P. Mishra and U. Reddy. Declaration-free type checking. In Conference Record of the 12th Annual ACM Symposium on POPL, pages 7–21. ACM, New York, Jan. 1985.

    Google Scholar 

  39. T. Mogensen. Separating binding times in language specifications. In [15], pages 12–25.

    Google Scholar 

  40. S. S. Muchnick and N. D. Jones, editors. Program Flow Analysis: Theory and Applications. Prentice-Hall, Englewood Cliffs, N.J., 1981.

    MATH  Google Scholar 

  41. R. Paige and S. Koenig. Finite differencing of computable expressions. ACM Trans. Program. Lang. Syst., 4(3):402–454, July 1982.

    Article  MATH  Google Scholar 

  42. Y. G. Park and B. Goldberg. Escape analysis on lists. In Proceedings of the ACM SIGPLAN’ 92 Conference on Programming Language Design and Implementation, pages 116–127. ACM, New York, June 1992.

    Chapter  Google Scholar 

  43. W. Pugh and E. Rosser. Iteration space slicing and its application to communication optimization. In International Conference on Supercomputing, Vienna, Austria, July 1997.

    Google Scholar 

  44. T. Reps and T. Teitelbaum. The Synthesizer Generator: A System for Constructing Language-Based Editors. Springer-Verlag, New York, 1988.

    Google Scholar 

  45. T. Reps and T. Turnidge. Program specialization via program slicing. In O. Danvy, R. Glück, and P. Thiemann, editors, Proceedings of the Dagstuhl Seminar on Partial Evaluation, volume 1110 of Lecture Notes in Computer Science, pages 409–429. Springer-Verlag, Berlin, 1996.

    Google Scholar 

  46. M. Sagiv, T. Reps, and R. Wilhelm. Solving shape-analysis problems in languages with destructive updating. ACM Trans. Program. Lang. Syst., 20(1):1–50, Jan. 1998.

    Article  Google Scholar 

  47. The internet scheme repository. http://www.cs.indiana.edu/scheme-repository/.

  48. D. S. Scott. Lectures on a mathematical theory of computation. In M. Broy and G. Schmidt, editors, Theoretical Foundations of Programming Methodology, pages 145–292. D. Reidel Publishing Company, 1982.

    Google Scholar 

  49. H. Seidl and M. H. Sørensen. Constraints to stop deforestation. Sci. Comput. Program., 32:73–107, 1998.

    Article  MATH  Google Scholar 

  50. O. Shivers. Control ow analysis in scheme. In Proceedings of the ACM SIGPLAN’ 88 Conference on Programming Language Design and Implementation. ACM, New York, June 1988.

    Google Scholar 

  51. M. H. Sørensen. A grammar-based data-flow analysis to stop deforestation. In S. Tison, editor, CAAP’94: Proceedings of the 19th International Colloquium on Trees in Algebra and Programming, volume 787 of Lecture Notes in Computer Science, pages 335–351. Springer-Verlag, Berlin, Apr. 1994.

    Chapter  Google Scholar 

  52. G. L. Steele. Common Lisp the Language. Digital Press, 1984.

    Google Scholar 

  53. P. F. Sweeney and F. Tip. A study of dead data members in c++ applications. In Proceedings of the ACM SIGPLAN’ 98 Conference on Programming Language Design and Implementation, pages 324–332. ACM, New York, June 1998.

    Chapter  Google Scholar 

  54. F. Tip. A survey of program slicing techniques. Journal of Programming Languages, 3(3):121–189, Sept. 1995.

    Google Scholar 

  55. P. Wadler. Deforestation: Transforming programs to eliminate trees. Theoret. Comput. Sci., 73:231–248, 1990. Special issue of selected papers from the 2nd European Symposium on Programming.

    Article  MATH  MathSciNet  Google Scholar 

  56. P. Wadler and R. J. M. Hughes. Projections for strictness analysis. In Proceedings of the 3rd International Conference on Functional Programming Languages and Computer Architecture, volume 274 of Lecture Notes in Computer Science, pages 385–407. Springer-Verlag, Berlin, Sept. 1987.

    Google Scholar 

  57. M. Wand and W. D. Clinger. Set constraints for destructive array update optimization. In Proceedings of the IEEE 1998 International Conference on Computer Languages, pages 184–193. IEEE CS Press, Los Alamitos, Calif., May 1998.

    Google Scholar 

  58. M. Wand and I. Siveroni. Constraint systems for useless variable elimination. In Conference Record of the 26th Annual ACM Symposium on Principles of Programming Languages, pages 291–302. ACM, New York, Jan. 1999.

    Google Scholar 

  59. E. Wang and P. M. Hilfinger. Analysis of recursive types in lisp-like languages. In [29], pages 216–225.

    Google Scholar 

  60. M. Weiser. Program slicing. IEEE Trans. Softw. Eng., SE-10(4):352–357, July 1984.

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 1999 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Liu, Y.A., Stoller, S.D. (1999). Eliminating Dead Code on Recursive Data. In: Cortesi, A., Filé, G. (eds) Static Analysis. SAS 1999. Lecture Notes in Computer Science, vol 1694. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-48294-6_14

Download citation

  • DOI: https://doi.org/10.1007/3-540-48294-6_14

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-66459-8

  • Online ISBN: 978-3-540-48294-9

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics