[RFC] LLVM Coroutines

(Dropped llvm-dev by accident. Putting it back)

HI Eli:

coro.barrier() doesn't work: if the address of the alloca doesn't escape,
alias analysis will assume the barrier can't read or write the value of
the alloca, so the barrier doesn't actually block code movement.

Got it. I am new to this and learning a lot over the course
of this thread. Thank you for being patient with me.

Two questions and one clarification:

Q1: Do we have to have a load here?

Hi Gor,

How will you handle (potentially variably sized) alloca instructions
that cannot be elided by promotion to SSA? E.g.

void cor() {
  int a = 0;
  escape(&a);
  for (;:wink: yield(a++);
}

-- Sanjoy

Hi Sanjoy:

How will you handle (potentially variably sized) alloca instructions
that cannot be elided by promotion to SSA? E.g.

  void cor() {
    int a = 0;
    escape(&a);
    for (;:wink: yield(a++);
  }

Any escaped allocas go to the coroutine frame. It is an important
use case with async coroutines:

  task<void> f() {
    char buf[N];
    ... fill buff with stuff
    await async_send(buf); // <suspend-point>
    ... do more
  }

Even though an alloca is not mentioned after suspend point, it is still
need to go to the coroutine frame, as async_send will be referencing it
while coroutine is suspended (and its stack frame gone).

CoroSplit pass is doing two interesting things.
  1) Creates the coroutine frame.
  2) Chops up the coroutine into pieces

Here is a brief description: