<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 6, 2014 at 9:14 AM, XiaoGuang Wang <span dir="ltr"><<a href="mailto:xjtuwxg@gmail.com" target="_blank">xjtuwxg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks Tim,<div><br><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><br>
On 5 October 2014 13:47, XiaoGuang Wang <<a href="mailto:xjtuwxg@gmail.com" target="_blank">xjtuwxg@gmail.com</a>> wrote:<br>
> So what's going on with my test. Is there something I did wrong with<br>
> jumptable options? Or is the jumptable tried to address other problem, not<br>
> indirect call?<br>
<br>
</span>I think LLVM's jump table pass requires explicit function annotations<br>
in the IR for functions that should go via the table, which Clang<br>
doesn't create. Something like this in its simplest form:<br>
<br>
define void @foo() unnamed_addr jumptable {<br>
  ret void<br>
}<br>
<br>
define void @main() {<br>
  %var = alloca void()*<br>
  store void()* @foo, void()** %var<br>
  %func = load void()** %var<br>
  call void %func()<br>
  ret void<br>
}<br></blockquote><div><br></div></span><div> 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 (<a href="http://comments.gmane.org/gmane.comp.compilers.clang.scm/102395" target="_blank">http://comments.gmane.org/gmane.comp.compilers.clang.scm/102395</a>). And I tried it, it works with clang -ffcif test.c.</div></div></div></div></div></blockquote><div><br></div><div>Yes, that's the right patch to use.  You might also want to look at the test cases in, e.g., test/CodeGen/X86/jump_table*.ll to see the code that is generated by the annotations. I'd be happy to answer other questions you might have.</div><div><br></div></div></div></div>