Constraint systems for useless variable elimination

A useless variable is one whose value contributes nothing to the final outcome of a computation. Such variables are unlikely to occur in human-produced code, but may be introduced by various program transformations. We would like to eliminate useless parameters from procedures and eliminate the corresponding actual parameters from their call sites. This transformation is the extension to higher-order programming of a variety of dead-code elimination optimizations that are important in compilers for first-order imperative languages.Shivers has presented such a transformation. We reformulate the transformation and prove its correctness. We believe that this correctness proof can be a model for proofs of other analysis-based transformations. We proceed as follows: ¿We reformulate Shivers' analysis as a set of constraints; since the constraints are conditional inclusions, they can be solved using standard algorithms. ¿We prove that any solution to the constraints is sound: that two computations that differ only on variables marked as useless give the same answer up to useless variables, and hence the same answer when the answer is a constant. ¿We observe that this notion of soundness is too weak to support the transformation of the analyzed program. We add additional closure conditions to the analysis and show that any solution to the new set of constraints justifies the transformation. The proof is by tree surgery: we show that from any computation of the original program, we can construct a computation of the transformed program that yields an answer related to the original, and the same answer when the original answer is a constant.

[1]  Neil D. Jones,et al.  A flexible approach to interprocedural data flow analysis and programs with recursive data structures , 1982, POPL '82.

[2]  S. Jones,et al.  A Transformation-Based Optimiser for Haskell , 1998, Sci. Comput. Program..

[3]  Andrew W. Appel Modern Compiler Implementation in ML: Basic Techniques , 1997 .

[4]  Nevin Charles Heintze,et al.  Set based program analysis , 1992 .

[5]  Steven S. Muchnick,et al.  Advanced Compiler Design and Implementation , 1997 .

[6]  David W. Binkley,et al.  Program slicing , 2008, 2008 Frontiers of Software Maintenance.

[7]  Mitchell Wand,et al.  Set constraints for destructive array update optimization , 1998, Proceedings of the 1998 International Conference on Computer Languages (Cat. No.98CB36225).

[8]  Mitchell Wand,et al.  Lightweight closure conversion , 1997, TOPL.

[9]  Andrew W. Appel,et al.  Modern Compiler Implementation in ML , 1997 .

[10]  Analysis and caching of dependencies , 1996, ICFP '96.

[11]  Frank Tip,et al.  A study of dead data members in C++ applications , 1998, PLDI.

[12]  DONALD MICHIE,et al.  “Memo” Functions and Machine Learning , 1968, Nature.

[13]  Peter Sestoft,et al.  Replacing function parameters by global variables , 1989, FPCA.

[14]  Philip Wadler,et al.  The Glasgow Haskell Compiler: a technical overview , 1993 .

[15]  Neil D. Jones,et al.  Flow Analysis of Lambda Expressions (Preliminary Version) , 1981, ICALP.

[16]  Jens Palsberg,et al.  Object-oriented type systems , 1994, Wiley professional computing.

[17]  Mitchell Wand,et al.  Specifying the correctness of binding-time analysis , 1993, POPL '93.

[18]  Olin Shivers,et al.  Control-flow analysis of higher-order languages of taming lambda , 1991 .

[19]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[20]  Flemming Nielson,et al.  Infinitary control flow analysis: a collecting semantics for closure analysis , 1997, POPL '97.

[21]  James H. Morris,et al.  Subgoal induction , 1977, CACM.

[22]  N. Jones Flow Analysis of Lambda Expressions , 1981 .