Is goto from inline asm supported in LLVM 2.8 ?
I am searching for something similar to what gcc 4.5 does:
which allows jumping from inline assembly to a label defined in C.
I want to jump from inline asm to a basic block in LLVM. As far as I know in
LLVM 2.7 this was not yet possible. Is it allowed a jump like this in LLVM
This is not directly representable in LLVM IR.
However, it *is* possible to "restructure" the inline asm so that it
returns either an int or a blockaddress for use with respectively a
switch or indirectbr occurring right after the inline asm. This can be
done by replacing the labels being jumped to with labels defined in
the inline asm (e.g. at the end), which then put the appropriate
values in a register (or memory location) being used as output. And of
course there should be code added to return the "default destination"
if no 'goto' is reached.
Obviously, this requires the frontend doing this to have special code
for each cpu architecture you want to support this on.
LDC (www.dsource.org/projects/ldc/) uses this technique.
I'm not sure if (and how) clang, dragonegg and llvm-gcc handle this.
In order to represent this directly in LLVM IR, there would need to be
a variant of inline asm calls that is a terminator instruction,
probably quite similar to 'indirectbr' (but with a default
destination, like 'switch'). Otherwise there would be no way to
properly keep PHI nodes of successors up to date, for instance.
I imagine this would be tricky to implement "properly" though.