llvm.coro.id.async lowering: Parameterize how-to restore the current's continutation...
authorArnold Schwaighofer <aschwaighofer@apple.com>
Mon, 2 Nov 2020 17:37:15 +0000 (09:37 -0800)
committerArnold Schwaighofer <aschwaighofer@apple.com>
Fri, 6 Nov 2020 14:22:46 +0000 (06:22 -0800)
commitc6543cc6b8f107b58e7205d8fc64865a508bacba
treea5167799893a8fb0ee99eae78afea15a3b89ecc4
parenteed768b70094b55b9d34cd7e1c8c0788d1e8935c
llvm.coro.id.async lowering: Parameterize how-to restore the current's continutation context and restart the pipeline after splitting

The `llvm.coro.suspend.async` intrinsic takes a function pointer as its
argument that describes how-to restore the current continuation's
context from the context argument of the continuation function. Before
we assumed that the current context can be restored by loading from the
context arguments first pointer field (`first_arg->caller_context`).

This allows for defining suspension points that reuse the current
context for example.

Also:

llvm.coro.id.async lowering: Add llvm.coro.preprare.async intrinsic

Blocks inlining until after the async coroutine was split.

Also, change the async function pointer's context size position

   struct async_function_pointer {
     uint32_t relative_function_pointer_to_async_impl;
     uint32_t context_size;
   }

And make the position of the `async context` argument configurable. The
position is specified by the `llvm.coro.id.async` intrinsic.

rdar://70097093

Differential Revision: https://reviews.llvm.org/D90783
llvm/docs/Coroutines.rst
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/Transforms/Coroutines/CoroElide.cpp
llvm/lib/Transforms/Coroutines/CoroInstr.h
llvm/lib/Transforms/Coroutines/CoroInternal.h
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/lib/Transforms/Coroutines/Coroutines.cpp
llvm/test/Transforms/Coroutines/coro-async.ll