Page MenuHomePhabricator

[Coroutines] Part 10: Add coroutine promise support.

Authored by GorNishanov on Aug 29 2016, 7:49 AM.


  1. CoroEarly now lowers llvm.coro.promise intrinsic that allows to obtain

a coroutine promise pointer from a coroutine frame and vice versa.

  1. CoroFrame now interprets Promise argument of llvm.coro.begin to

place CoroutinPromise alloca at a deterministic offset from the coroutine frame.

Now, the coroutine promise example from docs\Coroutines.rst compiles and produces expected result (see test/Transform/Coroutines/ex4.ll).

Diff Detail

Event Timeline

GorNishanov retitled this revision from to [Coroutines] Part 10: Add coroutine promise support..
GorNishanov updated this object.
GorNishanov added a reviewer: majnemer.
GorNishanov added a subscriber: llvm-commits.
majnemer added inline comments.Aug 29 2016, 8:18 PM

Builder->getInt8Ty() is a little shorter.


auto *


This is weird. There can be ptrtoint/inttoptr pairs, etc. Why do you have this restriction?


auto *


The alignment is signed?

Addressed review feedback.

GorNishanov marked 6 inline comments as done.Aug 29 2016, 9:13 PM
GorNishanov added inline comments.

Mostly I wanted to observe what else could be used to convert alloca %promise-type into void* parameter, so that I can correctly move them after coro.begin (in case when they are used by something other than coro.begin).

coro.begin marks the point where we know the address of the coroutine frame, so anything touching the coroutine frame should appear after it. Since promise alloca always goes to coroutine frame.

I'd like to keep it for now and revisit it in patch 12 where I add code to deal with various instructions that may appear before coro.begin that would need be moved after it. That will give us more tools to deal with ptrtoint/inttoptr possibility.

majnemer accepted this revision.Aug 30 2016, 11:52 AM
majnemer edited edge metadata.


This revision is now accepted and ready to land.Aug 30 2016, 11:52 AM
This revision was automatically updated to reflect the committed changes.
GorNishanov marked an inline comment as done.