[LLVMdev] DSA / poolalloc: incorrect callgraph for indirect call

Victor van der Veen vvdveen at gmail.com
Fri May 15 08:54:38 PDT 2015


Hello,

I am trying to apply DSA (from the poolalloc project - I'm on LLVM 3.2)
on the following C program and found that the generated callgraph
over-approximates the callees for the simple indirect call.

#include <stdio.h>
__attribute__((noinline)) static int f1(int arg1, int arg2) {
    return arg1 + arg2;
}
__attribute__((noinline)) static int run_func(int (*fptr)(int, int), int
arg1, int arg2) {
    return (*fptr)(arg1, arg2);
}
__attribute__((noinline)) static int foo() {
    return run_func(&f1, 1, 2);
}
int main(int argc, char *argv[]) {
    printf("Main: %p\n", &main);
    printf("Sum:  %d\n", foo());
}

Using the TDDataStructures, I would expect that the callgraph of above
program shows that run_func can only call f1. However, it seems that DSA
is falling back to an address-taken approach and tells us it can also
call main.

I attached the bitcode of above C program, as well as the LLVM pass that
generates a callgraph. I'd be grateful for any clues you can provide.

Thanks,
Victor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.ll
Type: application/octet-stream
Size: 2249 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150515/627bea0b/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HelloPass.cpp
Type: text/x-c++src
Size: 3998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150515/627bea0b/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150515/627bea0b/attachment.sig>


More information about the llvm-dev mailing list