[LLVMdev] Basic Blocks: Bytecode -> Native Code

Chris Lattner sabre at nondot.org
Tue Jan 27 15:28:03 PST 2004

> Yes, this is true for the Sparc back-end.  In fact, it is a fundamental
> assumption that is relied on by the runtime tracing framework for dynamic
> optimization (not part of 1.1 yet).  I believe it is also true for x86 but I
> am not sure.

This is also true for the X86 backend, at least as much as the sparc:

> 	<code for bb>
> 	conditional branch to label 1
> 	nop    ;; delay slot
> 	unconditional branch to label 2   ;; may be eliminated if fall-through
> 	nop    ;; delay slot
> Technically this is 2 basic blocks, but it is not difficult to recognize and
> treat as as special case (and safe).

The exact same thing can happen on X86 as well, if neither destination of
the conditional branch is a fall-through.

Note that in the not-too-distant future, I plan to relax this constraint
in the X86 backend.  In particular, there will be a one-to-several mapping
from LLVM basic blocks to machine basic blocks.  This is required for
adding more efficient switch statement support, and for implementing some
operations on the X86 (e.g. 64-bit shifts: the current implementation uses
conditional moves to work around this, but obviously that won't work on
systems without cmovs :)

In the meantime, there is a 1-1 mapping, but if you can design your stuff
to be easily extensible in the future, it might make forward porting it



More information about the llvm-dev mailing list