[PATCH] D54498: AbstractCallSite -- A unified interface for (in)direct and callback calls
Siddharth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 14 10:35:59 PST 2018
bollu added a comment.
Thanks for the answer! That clears up a lot.
So, I believe the main difference between the `pthread` example and the one that I have is that of mutual recursion: I will often have mutual recursion between the `trampoline` and the `f_i`, which usually complicates inter-procedural analysis (as far as I understand?)
An extreme example of such messy code could be something like this:
// computes if 9 is odd by calling two mutually recursive functions is_odd and is_even,
// which in turn recurse through the trampoline
entrypoint:
push_int(9);
push_call(IS_ODD);
trampoline();
// is_odd :: Int -> Int
is_odd:
i = pop_int();
if (i == 0) { push_int(0); trampoline(); }
if (i == 1) { push_int(1); trampoline(); }
push_int(i - 1);
push_call(IS_EVEN_LABEL);
trampoline();
// is_even Int -> Int
is_even:
i = pop_int();
if (i == 0) { push_int(1); trampoline(); }
if (i == 1) { push_int(0); trampoline(); }
push_int(i - 1);
push_call(IS_ODD_LABEL);
trampoline();
trampoline:
tag = pop_call();
switch (tag) {
case IS_EVEN_LABEL:
is_even();
case IS_ODD_LABEL:
is_odd();
case ENTRYPOINT:
entrypoint();
}
Repository:
rL LLVM
https://reviews.llvm.org/D54498
More information about the llvm-commits
mailing list