Title :
Taming control flow: a structured approach to eliminating goto statements
Author :
Erosa, Ana M. ; Hendren, Laurie J.
Author_Institution :
Sch. of Comput. Sci., McGill Univ., Montreal, Que., Canada
Abstract :
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 paper 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. We have implemented the method in the McCAT (McGill Compiler Architecture Testbed) optimizing/parallelizing C compiler and we present experimental results that demonstrate that the method is both efficient and effective
Keywords :
C language; parallel programming; program compilers; AST representation; C programs; McCAT; McGill Compiler Architecture Testbed; control flow; goto statements; goto-elimination; goto-movement transformations; high-level abstract syntax tree; intermediate representation; optimizing compilers; parallelizing compilers; Computer science; Design optimization; Flow graphs; Information analysis; Optimizing compilers; Program processors; Programming profession; Software engineering; Software testing; Switches;
Conference_Titel :
Computer Languages, 1994., Proceedings of the 1994 International Conference on
Conference_Location :
Toulouse
Print_ISBN :
0-8186-5640-X
DOI :
10.1109/ICCL.1994.288377