[LLVMdev] CallTargets Analysis Incorrect

Andrew Lenharth andrewl at lenharth.org
Tue Sep 30 08:31:26 PDT 2008


On Thu, Sep 25, 2008 at 5:04 PM, Thomas B. Jablin
<tjablin at cs.princeton.edu> wrote:
> Hi,
> The call target pass in the poolalloc suite yields an incorrect output for the following short test program:

The DSA results are now (r56847) correct for this test case.  The call
is marked incomplete.  Doing better is actually a pathological case in
DSA which is hard to fix without expotential growth problems, but I
have some ideas (and happen to have to be working on DSA for something
anyway, so you are in luck).

Andrew

> #include <stdio.h>
>
> struct OP {
>  void (*func)(struct OP*);
> };
>
> void bar(struct OP *op);
>
> void foo(struct OP *op) {
>  printf("Foo\n");
>  op->func = bar;
> }
>
> void bar(struct OP *op) {
>  printf("Bar\n");
>  op->func = foo;
> }
>
> int main(int argc, char **argv) {
>  int i;
>  struct OP op;
>  op.func = foo;
>  for(i = 0; i < 10; ++i) {
>    op.func(&op);
>  }
>  return 0;
> }
>
> Specifically, pass indicates that indirect function call in the main function may call the foo method and that the the list of callees is complete. In fact, the indirect function call can target both the foo and bar methods, so the list should be marked incomplete, or should include the other callees. Thanks.
> Tom
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



More information about the llvm-dev mailing list