[LLVMdev] Emit code for 'unreachable'
David Blaikie
dblaikie at gmail.com
Mon Apr 14 08:26:41 PDT 2014
On Mon, Apr 14, 2014 at 2:46 AM, Vadim Chugunov <vadimcn at gmail.com> wrote:
> Hi,
> Is it somehow possible to have LLVM emit machine code for the 'unreachable'
> IR instruction, which would assert that it indeed never gets reached?
Take a look at LLVM's implementation of an "llvm_unreachable" macro to
see how the LLVM project does this.
Essentially lllvm's unreachable IR instruction is /not/ an assert or
check, it's a compiler hint. So at -O0, LLVM's llvm_unreachable
compiles to a check/assert, at higher optimization levels it compiles
to an intrinsic that is lowered to an unreachable IR instruction and
is used to assist optimization.
- David
More information about the llvm-dev
mailing list