[PATCH] D25377: [coroutines] Store an address of destroy OR cleanup part in the coroutine frame.

Gor Nishanov via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 12:36:51 PDT 2016


GorNishanov created this revision.
GorNishanov added a reviewer: majnemer.
GorNishanov added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.

If heap allocation of a coroutine is elided, we need to make sure that we will update an address stored in the coroutine frame from f.destroy to f.cleanup.
Before this change, CoroSplit synthesized these stores after coro.begin:

store void (%f.Frame*)* @f.resume, void (%f.Frame*)** %resume.addr
store void (%f.Frame*)* @f.destroy, void (%f.Frame*)** %destroy.addr

In those cases where we did heap elision, but were not able to devirtualize all indirect calls, destroy call will attempt to "free" the coroutine frame stored on the stack. Oops.

Now we use select to put an appropriate coroutine subfunction in the destroy slot. As bellow:

store void (%f.Frame*)* @f.resume, void (%f.Frame*)** %resume.addr
%0 = select i1 %need.alloc, void (%f.Frame*)* @f.destroy, void (%f.Frame*)* @f.cleanup
store void (%f.Frame*)* %0, void (%f.Frame*)** %destroy.addr


https://reviews.llvm.org/D25377

Files:
  lib/Transforms/Coroutines/CoroInstr.h
  lib/Transforms/Coroutines/CoroSplit.cpp
  test/Transforms/Coroutines/coro-split-00.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25377.73968.patch
Type: text/x-patch
Size: 6289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/afb6d815/attachment.bin>


More information about the llvm-commits mailing list