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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
A. V. Aho, R. Sethi, and J. D. Ullman. Compilers, Principles, Techniques, and Tools. Addison-Wesley, Reading, Mass., 1986.
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.
K. Arnold and J. Golsing. The Java Programming Language. Addison-Wesley, Reading, Mass., 1996.
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.
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.
W.-N. Chin. Safe fusion of functional expressions. In [29], pages 11–20.
J. Cocke and K. Kennedy. An algorithm for reduction of operator strength. Commun. ACM, 20(11):850–856, Nov. 1977.
J. Cocke and J. T. Schwartz. Programming languages and their compilers; preliminary notes. Technical report, Courant Institute of Mathematical Sciences, New York University, 1970.
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.
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.
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.
N. Dershowitz and E. M. Reingold. Calendrical calculations. Software–Practice and Experience, 20(9):899–928, Sept. 1990.
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.
R. K. Dybvig. The Scheme Programming Language. Prentice-Hall, Englewood Cliffs, N.J., 1987.
Proceedings of the 4th International Conference on Functional Programming Languages and Computer Architecture. ACM, New York, Sept. 1989.
F. Gecseg and M. Steinb. Tree Automata. Akademiai Kiado, Budapest, 1984.
C. A. Gunter. Semantics of Programming Languages. The MIT Press, Cambridge, Mass., 1992.
N. Heintze. Set-Based Program Analysis. PhD thesis, Department of Computer Science, Carnegie Mellon University, Pittsburgh, Pennsylvania, Oct. 1992.
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.
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.
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.
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.
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.
S. B. Jones and D. Le Métayer. Compile-time garbage collection by sharing analysis. In [15], pages 54–74.
K. Kennedy. Use-definition chains with applications. J. Comput. Lang., 3(3):163–179, 1978.
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.
J. Launchbury. Projection Factorisations in Partial Evaluation. PhD thesis, Department of Computing, University of Glasgow, Glasgow, Scotland, 1989.
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.
Proceedings of the 1992 ACM Conference on LISP and Functional Programming. ACM, New York, June 1992.
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.
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.
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.
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.
Y. A. Liu and T. Teitelbaum. Systematic derivation of incremental programs. Sci. Comput. Program., 24(1):1–39, Feb. 1995.
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.
D. Melski and T. Reps. Interconvertibility of a class of set constraints and context-free language reachability. Theoret. Comput. Sci., 1999. Accepted.
R. Milner, M. Tofte, and R. Harper. The definition of Standard ML. The MIT Press, Cambridge, Mass., 1990.
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.
T. Mogensen. Separating binding times in language specifications. In [15], pages 12–25.
S. S. Muchnick and N. D. Jones, editors. Program Flow Analysis: Theory and Applications. Prentice-Hall, Englewood Cliffs, N.J., 1981.
R. Paige and S. Koenig. Finite differencing of computable expressions. ACM Trans. Program. Lang. Syst., 4(3):402–454, July 1982.
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.
W. Pugh and E. Rosser. Iteration space slicing and its application to communication optimization. In International Conference on Supercomputing, Vienna, Austria, July 1997.
T. Reps and T. Teitelbaum. The Synthesizer Generator: A System for Constructing Language-Based Editors. Springer-Verlag, New York, 1988.
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.
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.
The internet scheme repository. http://www.cs.indiana.edu/scheme-repository/.
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.
H. Seidl and M. H. Sørensen. Constraints to stop deforestation. Sci. Comput. Program., 32:73–107, 1998.
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.
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.
G. L. Steele. Common Lisp the Language. Digital Press, 1984.
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.
F. Tip. A survey of program slicing techniques. Journal of Programming Languages, 3(3):121–189, Sept. 1995.
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.
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.
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.
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.
E. Wang and P. M. Hilfinger. Analysis of recursive types in lisp-like languages. In [29], pages 216–225.
M. Weiser. Program slicing. IEEE Trans. Softw. Eng., SE-10(4):352–357, July 1984.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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