[llvm-dev] [RFC] LLVM Coroutines

Gor Nishanov via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 9 14:33:46 PDT 2016


On Thu, Jun 9, 2016 at 1:49 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
>> Right... but that doesn't mean the call to the suspend intrinsic has to be
>> the last non-terminator instruction in the basic block before you run
>> CoroSplit.  You can split the basic block in CoroSplit so any instructions
>> after the suspend call are part of a different basic block.  Then resume and
>> destroy both branch to the continuation of the basic block (and run different
>> codepaths based on the boolean).

I love it!!! it is so much simpler. Indeed, we absolutely don't need to care
about the resume and cleanup branches. Let me restate the model as
I understand it.

Lowering of coro.suspend number X:

1) split block at coro.suspend, new block becomes jump point for resumption X
2) RAUW coro.suspend with i1 true in resume clone i1 false in destroy clone
3) replace coro.suspend with br %return.block in 'f', 'ret void' in clones

Scratch the proposed corosuspend instruction. I think the intrinsic will work
just fine!

Gor


More information about the llvm-dev mailing list