The D spec states that any labels in a function are accesible from inline asm, and also that any labels inside inline asm are valid target for goto.
LLVM does not support this. Below is the IRC log of my inquery on this matter in the LLVM IRC channel:
<lindquist> is there any way to force a basic block to emitted when generating code, even though it has no predecessors
<_sabre_> give it a predecessor?
<_sabre_> otherwise no
<_sabre_> why do you want that?
<lindquist> well I'm hacking around a bit.
<lindquist> the thing is D allows jumping out of an asm block, so I'm experimenting with it to see what actually works (even though that may be pure luck)
<aKor> lindquist: you can have pretty nasty issues then
<aKor> it's better to have some 'collector' block
<aKor> which will dispatch codeflow
<lindquist> I'm not sure I follow
<aKor> well
<aKor> give each bb, which can be reached from asm unique number
<aKor> and return this number out of asm block
<aKor> (in some local var)
<aKor> then, use this number as input to big switch
<aKor> (in the 'collector' block)
<aKor> which will do actual jumping
<aKor> you might also want another variable, which will tell you, whether exit form asm block was 'normal', or via such jump
<aKor> *from
<aKor> does this make sence?
<lindquist> yes
<aKor> this is pretty proven method for such insane branches :)
<lindquist> the only thing I've seen it used for in D is overflow checking etc, branching to somewhere that throws an exception
<lindquist> this could certainly be made to work with that scheme
<_sabre_> I would model that as having the asm return a value
<_sabre_> and then use an llvm branch to pick the destination
<aKor> _sabre_: yeah: <aKor> you might also want another variable, which will tell you, whether exit form asm block was 'normal', or via such jump
<_sabre_> :)
<lindquist> thanx for the hints :)
This does seem like a feasible way to implement this.