[LLVMdev] Question about jumptable and indirect function call.

XiaoGuang Wang xjtuwxg at gmail.com
Mon Oct 6 09:14:41 PDT 2014

Thanks Tim,

> On 5 October 2014 13:47, XiaoGuang Wang <xjtuwxg at gmail.com> wrote:
> > So what's going on with my test. Is there something I did wrong with
> > jumptable options? Or is the jumptable tried to address other problem,
> not
> > indirect call?
> I think LLVM's jump table pass requires explicit function annotations
> in the IR for functions that should go via the table, which Clang
> doesn't create. Something like this in its simplest form:
> define void @foo() unnamed_addr jumptable {
>   ret void
> }
> define void @main() {
>   %var = alloca void()*
>   store void()* @foo, void()** %var
>   %func = load void()** %var
>   call void %func()
>   ret void
> }

 You're right. It seems we need to manually annotate the IR function in
this case. I just found a clang patch which Tom Roeder provided (
http://comments.gmane.org/gmane.comp.compilers.clang.scm/102395). And I
tried it, it works with clang -ffcif test.c.

I'm trying to read source code to see how jump table pass works.

Thanks again!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141006/7ffbd778/attachment.html>

More information about the llvm-dev mailing list