[LLVMdev] Question about jumptable and indirect function call.

XiaoGuang Wang xjtuwxg at gmail.com
Sun Oct 5 13:47:31 PDT 2014


Hi all,

I'm a beginner in LLVM. I read a paper recently, and I'm trying to use LLVM
jumptable in 3.5. When I compile the .bc file into .s file, I tried to use
the different jumptable type: all, single, ...

e.g.
clang -c -emit-llvm test.c
llc test.bc -jump-table-type=full -o test-full.s
llc test.bc -jump-table-type=single -o test-single.s

The tested C source code is like:
void foo() {
printf("foo...\n");
}

void bar() {
printf("bar...\n");
}

void foo1(int arg) {
printf("foo1... %d..\n", arg);
}

void bar1(int arg) {
printf("bar1... %d..\n", arg);
}

// function pointer
void (*fp)() = 0;
void (*fp1)(int) = 0;

int main(int argc, char* argv[])
{
int input = 0;

printf("Hello\n");
fp = foo;
fp();
fp = bar;
fp();
fp1 = foo1;
fp1(1);
fp1 = bar1;
fp1(2);
}

However, they produced the same .s assembly (test-full.s, test-single.s). I
think the llc will produce difference .s files, since I choose the
jumptable options. And according to my understanding, the jumptable
contains the destination address of each indirect function call.
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?

Thanks!

Sincerely,
Xiaoguang Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141005/94ee35c2/attachment.html>


More information about the llvm-dev mailing list