[LLVMdev] building a jump table in LLVM IR
tmroeder at google.com
Wed Jan 2 09:05:06 PST 2013
I'm currently writing an opt module for fast indirect call checks
using a table of allowed indirect call targets. The code replaces
function pointers with offsets into the table then masks the offset
for the table size and restores the function pointer before the call.
I have some ways of dealing with some kinds of external code that are
sufficient for my use case but not for more general use.
I'd like to generalize the table to be a table of jump instructions (a
classic jump table) rather than just a table of function pointers,
since this would solve some of my problems for the more general cases.
I know how to do this using inline assembly in LLVM, but this ties the
module to a particular architecture or set of architectures.
Is there a way to build a table of jump instructions like this in pure
LLVM IR? My limited understanding of LLVM says no, and I haven't been
able to find a way to do this, but I would appreciate any pointers you
can give me.
More information about the llvm-dev