This is an archive of the discontinued LLVM Phabricator instance.

[coroutines] Add coro.end handling
ClosedPublic

Authored by GorNishanov on Oct 10 2016, 12:13 PM.

Details

Summary

For WinEH, We add a funclet bundle to a coro.end call, so that CoroSplit in LLVM can replace it with cleanup ret and cut the rest out.
For landing pad, we add a branch to resume block if coro.end returns true.

LLVM Part: https://reviews.llvm.org/D25445

Diff Detail

Repository
rL LLVM

Event Timeline

GorNishanov retitled this revision from to [coroutines] Hybrid (bundle + bool returning coro.end approach).
GorNishanov updated this object.
GorNishanov added a reviewer: majnemer.
majnemer edited edge metadata.Oct 11 2016, 12:01 AM

Can we have a test for this?

lib/CodeGen/CGCoroutine.cpp
436 ↗(On Diff #74158)

auto *

440 ↗(On Diff #74158)

You could just do CGF.Builder.getTrue()

GorNishanov edited edge metadata.
GorNishanov added a subscriber: rsmith.

Added a dedicated test, addressed comments in CGCoroutine.cpp

(This does not go into clang branch yet, there are many more patches to filter through @rsmith :) .)

GorNishanov marked 2 inline comments as done.Oct 12 2016, 12:25 PM

LLVM-commits wasn't added on creation of this revision.

LLVM-commits wasn't added on creation of this revision.

I was mostly looking for a sanity check of the this direction. Over the weekend, David and I discussed several alternatives how we can handle the exceptional cleanup paths and trim unneeded ones with coro.end.

This CR is an attempt to show how a particular way of solving the problem might look. This is not meant to be checked-in to clang trunk yet, hence, no llvm-commit tag. When the time comes, I will create a dedicated commit for it with llvm-commits added during creation.

OK, all is well then :)

OK, all is well then :)

:)

The problem was that one approach (bundles) worked really well for WinEH, another, explicit control flow and bool returning coro.end with explicit control flow doing a jump to ehresume block worked great for landingpad EH model.

After a few unsuccessful attempts to have a grand unified model, I ended up with aesthetically unsatisfying, but, codewise quite simple hybrid approach where I do bundles for WinEH and explicit control flow for landing pad model.

majnemer accepted this revision.Oct 12 2016, 1:29 PM
majnemer edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 12 2016, 1:29 PM
GorNishanov retitled this revision from [coroutines] Hybrid (bundle + bool returning coro.end approach) to [coroutines] Add coro.end handling.
GorNishanov edited the summary of this revision. (Show Details)
GorNishanov added a subscriber: cfe-commits.

Preparing to land

This revision was automatically updated to reflect the committed changes.