Master's Thesis:
Exception Analysis in MLton

This thesis examines the possibility of further optimizing the code generated by the industrial strength Standard ML compiler MLton. By studying the code generated by the compiler we identify dead code and propose two analyses that will detect and remove this dead code. The first improvement will remove general dead exceptions handlers and the second will remove overflow checks on integer arithmetic where overflow cannot happen. We extract a BNF of the Static Single-Assignment form used internally in MLton and use this BNF to formulate two analyses by use of constraint rules. The first analysis collects sets of exception constructors possibly represented by each variable and the second is a flow-sensitive integer interval analysis. Both analyses are implemented in Standard ML and integrated into the MLton compiler as additional optimization passes. Whereas the first analysis is unsuccessful in optimizing real-world programs, the second analysis is able to remove 22% of the overflow checks in the MLton benchmark suite. The binary size of the programs are decreased overall (0%-10%) and the run time of arithmetic heavy programs are decreased significantly - in some cases up to 27%