A goto-elimination method and its implementation for the McCAT C compiler /

In designing optimizing and parallelizing compilers, it is often simpler and more efficient to deal with programs that have structured control flow. Although most programmers naturally program in a structured fashion, there remain many important programs and benchmarks that include some number of go...

Full description

Bibliographic Details
Main Author: Erosa, Ana Maria
Other Authors: Hendren, Laurie (advisor)
Format: Others
Language:en
Published: McGill University 1995
Subjects:
Online Access:http://digitool.Library.McGill.CA:80/R/?func=dbin-jump-full&object_id=55450
Description
Summary:In designing optimizing and parallelizing compilers, it is often simpler and more efficient to deal with programs that have structured control flow. Although most programmers naturally program in a structured fashion, there remain many important programs and benchmarks that include some number of goto statements, thus rendering the entire program unstructured. Such unstructured programs cannot be handled with compilers built with analyses and transformations for structured programs. === In this thesis we present a straight-forward algorithm to structure C programs by eliminating all goto statements. The method works directly on a high-level abstract syntax tree (AST) representation of the program and could easily be integrated into any compiler that uses an AST-based intermediate representation. The actual algorithm proceeds by eliminating each goto by first applying a sequence of goto-movement transformations followed by the appropriate goto-elimination transformation. === Our McCAT (McGill Compiler Architecture Testbed) optimizing/parallelizing C compiler is based on a compositional representation of the program, and hence does not support unrestricted use of gotos directly. We have implemented the method within the framework of the McCat compiler. We present some experimental results and study the cost of structuring. The results show that applying a small number of simple transformations eliminates all the goto statements, usually with a minimal effect on the execution speed. Thus, we can exploit structured representations for designing compilers, while paying a minimal penalty due to structuring.