summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCoroutines
Commit message (Collapse)AuthorAgeFilesLines
* [coroutines] Allow co_await and co_yield expressions that return an lvalue ↵Eric Fiselier2017-06-151-1/+49
| | | | | | | | | | | | | | | | | | to compile Summary: The title says it all. Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Subscribers: rjmccall, cfe-commits Differential Revision: https://reviews.llvm.org/D34194 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305496 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix rebuilding of dependent coroutine parametersEric Fiselier2017-06-031-0/+34
| | | | | | | | | | | | | | | | Summary: We were not handling correctly rebuilding of parameter and were not creating copies for them. Now we will always rebuild parameter moves in TreeTransform's TransformCoroutineBodyStmt. Reviewers: rsmith, GorNishanov Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33797 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304620 91177308-0d34-0410-b5e6-96231b3b80d8
* CGCleanup: (NFC) add another test for r304335 - Don't try to spill static ↵Gor Nishanov2017-06-011-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | allocas Summary: Coroutine related test that used to trigger broken IR prior to r304335. ``` %x = alloca i32, align 4 store i32* %x, i32** %tmp.exprcleanup, align 4 ; <===== HERE %ref.tmp3 = alloca %struct.A, align 1 %agg.tmp5 = alloca %"struct.std::experimental::coroutines_v1::coroutine_handle.0", align 4 %tmp.exprcleanup = alloca i32*, align 4 %allocapt = bitcast i32 undef to i32 store i32 %0, i32* %.addr, align 4 ``` Fixed with r304335 Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33750 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304380 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add support for coroutines with non-scalar parametersGor Nishanov2017-05-241-0/+95
| | | | | | | | | | | | | | Summary: Simple types like int are handled by LLVM Coroutines just fine. But for non-scalar parameters we need to create copies of those parameters in the coroutine frame and make all uses of those parameters to refer to parameter copies. Reviewers: rsmith, EricWF, GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33507 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303803 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Make generic lambda coroutines workGor Nishanov2017-05-241-0/+58
| | | | | | | | | | | | | | | | Summary: 1. Coroutine cannot be constexpr (added a check in SemaLambda.cpp not to mark coroutine as constexpr) 2. TransformCoroutineBodyStmt should transform ResultDecl and ReturnStmt Reviewers: rsmith, GorNishanov Reviewed By: GorNishanov Subscribers: EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D33498 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303764 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] [NFC] Add tests for return_void, unhandled_exception and ↵Gor Nishanov2017-05-244-0/+238
| | | | | | | | | | | | | | | | | | | promise dtor Summary: * Test that coroutine promise destructor is called. * Test that we call return_void on fallthrough * Test that we call unhandled exception in a try catch surrounding the body Reviewers: EricWF, GorNishanov Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33479 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303748 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Implement correct GRO lifetimeGor Nishanov2017-05-241-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Sema creates a declaration for gro variable as: auto $gro = $promise.get_return_object(); However, gro variable has to outlive coroutine frame and coroutine promise, but, it can only be initialized after the coroutine promise was created, thus, we split its emission in two parts: EmitGroAlloca emits an alloca and sets up the cleanups. Later when the coroutine promise is available we initialize the gro and set the flag that the cleanup is now active. Duplicate of: https://reviews.llvm.org/D31670 (which arc patch refuses to apply for some reason) Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Subscribers: EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D33477 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303716 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Skip over passthrough operator co_awaitGor Nishanov2017-05-231-0/+7
| | | | | | https://reviews.llvm.org/D31627 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303605 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add emission of initial and final suspendsGor Nishanov2017-05-232-9/+52
| | | | | | https://reviews.llvm.org/D31608 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303603 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add support for deallocation elisionGor Nishanov2017-05-231-0/+8
| | | | | | | | | | Wrap deallocation code with: if (auto *mem = coro.free()) Deallocate When backend decides to elide allocations it will replace coro.free with nullptr to suppress deallocation code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303599 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Replace all coro.frame builtins with an SSA value of coro.beginGor Nishanov2017-05-233-22/+15
| | | | | | | | SemaCoroutine forms expressions referring to the coroutine frame of the enclosing coroutine using coro.frame builtin. During codegen, we emit llvm.coro.begin intrinsic that returns the address of the coroutine frame. When coro.frame is emitted, we replace it with SSA value of coro.begin. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303598 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add support for allocation elisionGor Nishanov2017-05-231-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We wrap allocation code so that backend can elide it if necessary. llvm.coro.alloc intrinsic returns true, when allocation is needed and false otherwise. ``` %NeedAlloc = call i1 @llvm.coro.alloc(token %2) br i1 %NeedAlloc, label %AllocBB, label %InitBB AllocBB: %5 = call i64 @llvm.coro.size.i64() %call = call i8* @_Znwm(i64 %5) ; operator new br label %InitBB InitBB: %Phi = phi i8* [ null, %0 ], [ %call, %4 ] call i8* @llvm.coro.begin(token %2, i8* %Phi) ``` Reviewers: majnemer, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31584 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303596 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix coro-eh-cleanup.cpp testGor Nishanov2017-05-221-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303584 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Wrap the body of the coroutine in try-catchGor Nishanov2017-05-222-20/+55
| | | | | | | | | | | | | | | | | | | | | | Summary: If unhandled_exception member function is present in the coroutine promise, wrap the body of the coroutine in: ``` try { body } catch(...) { promise.unhandled_exception(); } ``` Reviewers: EricWF, rnk, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31692 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303583 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Build GRO declaration and return GRO statementGor Nishanov2017-05-221-2/+12
| | | | | | | | | | | | | | | | | | Summary: 1. build declaration of the gro local variable that keeps the result of get_return_object. 2. build return statement returning the gro variable 3. emit them during CodeGen 4. sema and CodeGen tests updated Reviewers: EricWF, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31646 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303573 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix building of new/delete expressions when ↵Eric Fiselier2017-04-181-3/+14
| | | | | | | | | | | | | | | | | | | | | | get_return_object_on_allocation_failure() is present. Summary: This patch implements [dcl.fct.def.coroutine]p8: > The unqualified-id get_return_object_on_allocation_failure is looked up in the scope of > class P by class member access lookup (3.4.5). If a declaration is found, ..., and if a > global allocation function is selected, the ::operator new(size_t, nothrow_t) form shall be used. > [...] > The allocation function used in this case must have a non-throwing noexcept-specification. Reviewers: GorNishanov, rsmith, majnemer, aaron.ballman Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31562 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300524 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename coroutine warning when unhandled_exception() is missingEric Fiselier2017-04-171-2/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300513 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r300504 - [coroutines] Fix rebuilding of implicit and dependent ↵Eric Fiselier2017-04-171-14/+3
| | | | | | | | | coroutine statements. I have no idea what's happening here. The tests that fail on all of the bots pass on my machine. Further investigation needed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300511 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix rebuilding of implicit and dependent coroutine statements.Eric Fiselier2017-04-171-3/+14
| | | | | | | | | | | | | | | | | | | Summary: Certain implicitly generated coroutine statements, such as the calls to 'return_value()' or `return_void()` or `get_return_object_on_allocation_failure()`, cannot be built until the promise type is no longer dependent. This means they are not built until after the coroutine body statement has been transformed. This patch fixes an issue where these statements would never be built for coroutine templates. It also fixes a small issue where diagnostics about `get_return_object_on_allocation_failure()` were incorrectly suppressed. Reviewers: rsmith, majnemer, GorNishanov, aaron.ballman Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31487 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300504 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r300420 - [coroutines] Fix building of new/delete expressions when ↵Eric Fiselier2017-04-161-14/+3
| | | | | | get_return_object_on_allocation_failure() is present git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300421 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Fix building of new/delete expressions when ↵Eric Fiselier2017-04-161-3/+14
| | | | | | | | | | | | | | | | | | | | | | get_return_object_on_allocation_failure() is present. Summary: This patch implements [dcl.fct.def.coroutine]p8: > The unqualified-id get_return_object_on_allocation_failure is looked up in the scope of > class P by class member access lookup (3.4.5). If a declaration is found, ..., and if a > global allocation function is selected, the ::operator new(size_t, nothrow_t) form shall be used. > [...] > The allocation function used in this case must have a non-throwing noexcept-specification. Reviewers: GorNishanov, rsmith, majnemer, aaron.ballman Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31562 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300420 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add coro.end handlingGor Nishanov2017-04-051-0/+74
| | | | | | | | | | | | | | | | | | 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 Reviewers: majnemer Reviewed By: majnemer Subscribers: EricWF, cfe-commits, rsmith, mehdi_amini Differential Revision: https://reviews.llvm.org/D25444 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299510 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add cleanup for compiler injected objects/allocations in ↵Gor Nishanov2017-04-012-14/+80
| | | | | | | | | | | | | | | | | | coroutine body Summary: * Use pushCleanup to emit freeing coroutine memory on normal and EH exits. * Surround emitted code with CodeGenFunction::RunCleanupsScope. Reviewers: rsmith, rnk, EricWF Reviewed By: rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31460 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299281 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Handle get_return_object_on_allocation_failureGor Nishanov2017-03-271-3/+30
| | | | | | | | | | | | | | | | | Summary: If promise_type has get_return_object_on_allocation_failure defined, check if an allocation function returns nullptr, and if so, return the result of get_return_object_on_allocation_failure(). Reviewers: rsmith, EricWF Reviewed By: EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D31399 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298891 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add codegen for await and yield expressionsGor Nishanov2017-03-261-0/+230
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Details: Emit suspend expression which roughly looks like: auto && x = CommonExpr(); if (!x.await_ready()) { llvm_coro_save(); x.await_suspend(...); (*) llvm_coro_suspend(); (**) } x.await_resume(); where the result of the entire expression is the result of x.await_resume() (*) If x.await_suspend return type is bool, it allows to veto a suspend: if (x.await_suspend(...)) llvm_coro_suspend(); (**) llvm_coro_suspend() encodes three possible continuations as a switch instruction: %where-to = call i8 @llvm.coro.suspend(...) switch i8 %where-to, label %coro.ret [ ; jump to epilogue to suspend i8 0, label %yield.ready ; go here when resumed i8 1, label %yield.cleanup ; go here when destroyed ] git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298784 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Build and pass coroutine_handle to await_suspendGor Nishanov2017-03-092-2/+32
| | | | | | | | | | | | | | | | Summary: This patch adds passing a coroutine_handle object to await_suspend calls. It builds the coroutine_handle using coroutine_handle<PromiseType>::from_address(__builtin_coro_frame()). (a revision of https://reviews.llvm.org/D26316 that for some reason refuses to apply via arc patch) Reviewers: GorNishanov Subscribers: mehdi_amini, cfe-commits, EricWF Differential Revision: https://reviews.llvm.org/D30769 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297356 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] update coro_end builtin to match llvmGor Nishanov2017-03-071-1/+1
| | | | | | | | | | | | | | Summary: llvm.coro.end intrinsic now returns bool. Updating clang to match it. Reviewers: GorNishanov, rsmith Reviewed By: rsmith Subscribers: mehdi_amini, cfe-commits, EricWF Differential Revision: https://reviews.llvm.org/D30711 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297224 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add co_return statement emissionGor Nishanov2017-03-062-5/+57
| | | | | | | | | | | | | | | | | Summary: Added co_return statement emission. Tweaked coro-alloc.cpp test to use co_return to trigger coroutine processing instead of co_await, since this change starts emitting the body of the coroutine and await expression handling has not been upstreamed yet. Reviewers: rsmith, majnemer, EricWF, aaron.ballman Reviewed By: rsmith Subscribers: majnemer, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D29979 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297076 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Add allocation and deallocation substatements.Gor Nishanov2016-10-271-0/+114
| | | | | | | | | | | | | | Summary: SemaCoroutine: Add allocation / deallocation substatements. CGCoroutine/Test: Emit allocation and deallocation + test. Reviewers: rsmith Subscribers: ABataev, EricWF, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D25879 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285306 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Adding builtins for coroutine intrinsics and backendutil support.Gor Nishanov2016-10-032-0/+66
| | | | | | | | | | | | | Summary: With this commit simple coroutines can be created in plain C using coroutine builtins. Reviewers: rnk, EricWF, rsmith Subscribers: modocache, mgorny, mehdi_amini, beanz, cfe-commits Differential Revision: https://reviews.llvm.org/D24373 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283155 91177308-0d34-0410-b5e6-96231b3b80d8
* [coroutines] Rename driver flag -fcoroutines to -fcoroutines-tsGor Nishanov2016-10-021-1/+1
| | | | | | | | | | | | | | | Summary: Also makes -fcoroutines_ts to be both a Driver and CC1 flag. Patch mostly by EricWF. Reviewers: rnk, cfe-commits, rsmith, EricWF Subscribers: mehdi_amini Differential Revision: https://reviews.llvm.org/D25130 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283064 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coroutines] Add proper mangling for operator co_await for MicrosoftABIGor Nishanov2016-09-281-0/+25
Reviewers: rnk, rsmith Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25045 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282645 91177308-0d34-0410-b5e6-96231b3b80d8