[LLVMdev] Eliminating gotos

Owen Anderson resistor at mac.com
Mon Aug 11 19:14:55 PDT 2008


On Aug 11, 2008, at 2:02 PM, Benedict Gaster wrote:

> 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.

What's the difference between an "if" and a conditional branch?

> 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:
>
> Extend LLVM with news ops to support if/loop.
> 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.
> Implement some structure of to the side that represents this high- 
> level flow.
>
> Thoughts?

One downside of this is that it means eliminating all instances of  
irreducible control flow, which can lead to an exponential increase in  
code size.

--Owen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080811/4ccf9104/attachment.html>


More information about the llvm-dev mailing list