This is an archive of the discontinued LLVM Phabricator instance.

CoroSplit: Fix coroutine splitting for retcon and retcon once
ClosedPublic

Authored by aschwaighofer on Jun 2 2020, 12:02 PM.

Details

Summary

For retcon and retcon.once coroutines we assume that all uses of spills
can be sunk past coro.begin. This simplifies handling of instructions
that escape the address of an alloca.

The current implementation would have issues if the address of the
alloca is escaped before coro.begin. (It also have issues with casts
before the coro.begin and uses of those casts after the coro.begin)

%alloca_addr = alloca ...
%escape  = ptrtoint %alloca_addr
coro.begin
store %escape to %alloca_addr

rdar://60272809

Diff Detail

Event Timeline

aschwaighofer created this revision.Jun 2 2020, 12:02 PM

I continue to find the presence of non-coroutine stuff in a coroutine function unnerving, but this seems to be a reasonable fix for it.

llvm/lib/Transforms/Coroutines/CoroFrame.cpp
903

retcon.once

1511

precede

1540

precede

1542

This can use array_pod_sort, I think.

llvm/test/Transforms/Coroutines/coro-retcon-frame.ll
40

lose

aschwaighofer marked 5 inline comments as done.

Address review comments.

llvm/lib/Transforms/Coroutines/CoroFrame.cpp
1542

array_pod_sort does not do closures that capture stuff.

Attempt to sooth clang-tidy

More clang-tidy soothing. I wish I would see its output ...

rjmccall added inline comments.Jun 3 2020, 10:39 AM
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
1542

Ah, I keep forgetting that. We should really add a variant that uses qsort_r when available.

rjmccall accepted this revision.Jun 3 2020, 10:39 AM
This revision is now accepted and ready to land.Jun 3 2020, 10:39 AM
This revision was automatically updated to reflect the committed changes.