Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is a lattice used by a compiler

In my graduate class on compiler construction we've been introduced to the concept of a lattice. Three lectures have been devoted to lattices and so far it seems like an interesting tangent, but the dilemma is that it doesn't really help explain how a compiler uses a lattice to solve a concrete problem.

We have already covered parsing and typechecking. We're about to start liveness analysis and register allocation.

Note, I'm not looking for resources on building compilers. The following list of links have that covered pretty well. What I'm looking for is an explanation on the relationship between compilers and lattices, bonus points for the most examples.

Learning Resources on Parsers, Interpreters, and Compilers
How much of the compiler should we know?
Learning to write a compiler

like image 784
Kelly S. French Avatar asked Apr 12 '10 20:04

Kelly S. French


1 Answers

Lattices are a very useful structure to represent state while doing static analysis on the program being compiled - eg. for removing dead code detected by liveness analysis, available/very busy expressions, reaching definitions, sign analysis and constant propagation.

Here is a very good read if you want the details: Lecture Notes on Static Analysis

like image 55
Jørn Schou-Rode Avatar answered Sep 30 '22 04:09

Jørn Schou-Rode