[LLVMdev] Eliminating gotos

Benedict Gaster benedict.gaster at amd.com
Mon Aug 11 14:02:11 PDT 2008


We would like to develop a code generator using LLVM for a target language
that does not support conditional branches and in fact only supports
structured control flow, eg. If and while. As far as I can tell that the
problem with doing this in LLVM today, is that it does not support these
high-level constructs and instead all control flow is implemented as
branches. 

It is ³fairly² straightforward to restructure a program written with
conditional/unconditional branches into to one that uses completely
high-level control flow structures, the algorithm I have in mind is
described in [1], the problem is how to best represent the resulting IL
within the LLVM framework:

1. Extend LLVM with news ops to support if/loop.
2. Implement this with the insertion of intrinsics to represent high-level
control-flow, introducing ³false² dependencies if necessary to allow
optimizations to be applied without changing the semantics.
3. Implement some structure of to the side that represents this high-level
flow.

Thoughts?

Ben

  [1] "Taming Control Flow: A structured approach to eliminating goto
    statements", A.M. Erosa and L.J. Hedren, ICCL 1994
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080811/562dc304/attachment.html>


More information about the llvm-dev mailing list