[LLVMdev] building a jump table in LLVM IR

Tom Roeder tmroeder at google.com
Mon Jan 7 08:51:32 PST 2013


AFAIK, this won't work: the way I want to use a jump table requires me
to get a pointer into the table that I can use as a function pointer
to call the original function in a normal call instruction. If I just
add a new basic block in some containing function with a call
instruction and somehow get a pointer to that instruction, then this
does satisfy the goal of putting the new instructions somewhere, but a
call through that pointer will not do the right thing, since it will
be calling into the middle of the containing function, then calling
the original function (whereas I want it to just jump to the original
function directly so it doesn't mess up the call stack). The
fundamental stumbling block is that it seems to be impossible (by
design) to jump in this manner in LLVM IR.

Thanks,

Tom

On Sun, Jan 6, 2013 at 8:06 PM, Zonr Chang <zonr.xchg at gmail.com> wrote:
> How about creating a new basic block in the current function and placing a
> "call" instruction to the desired function call inside it?



More information about the llvm-dev mailing list