summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCoroutine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix parameter name comments using clang-tidy. NFC.Rui Ueyama2019-07-161-1/+1
| | | | | | | | | | | | | | | | | | | | | This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
* Delete dead storesFangrui Song2019-07-121-1/+0
| | | | llvm-svn: 365901
* [opaque pointer types] Trivial changes towards CallInst requiringJames Y Knight2019-02-031-1/+1
| | | | | | explicit function types. llvm-svn: 353009
* Factor out duplication between ExprIterator and ConstExprIterator.Richard Smith2019-02-011-1/+1
| | | | | | | This also exposes a more general iterator cast mechanism suitable for use in http://reviews.llvm.org/D56571. llvm-svn: 352925
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-7/+7
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* [Coroutines] Less IR for noexcept await_resumeBrian Gesiak2018-06-231-8/+31
| | | | | | | | | | | | | | | | | | | | Summary: In his review of https://reviews.llvm.org/D45860, @GorNishanov suggested avoiding generating additional exception-handling IR in the case that the resume function was marked as 'noexcept', and exceptions could not occur. This implements that suggestion. Test Plan: `check-clang` Reviewers: GorNishanov, EricWF Reviewed By: GorNishanov Subscribers: cfe-commits, GorNishanov Differential Revision: https://reviews.llvm.org/D47673 llvm-svn: 335422
* [Coroutines] Catch exceptions in await_resumeBrian Gesiak2018-05-041-3/+45
| | | | | | | | | | | | | | | | | | | | | Summary: http://wg21.link/P0664r2 section "Evolution/Core Issues 24" describes a proposed change to Coroutines TS that would have any exceptions thrown after the initial suspend point of a coroutine be caught by the handler specified by the promise type's 'unhandled_exception' member function. This commit provides a sample implementation of the specified behavior. Test Plan: `check-clang` Reviewers: GorNishanov, EricWF Reviewed By: GorNishanov Subscribers: cfe-commits, lewissbaker, eric_niebler Differential Revision: https://reviews.llvm.org/D45860 llvm-svn: 331519
* Remove redundant casts. NFCGeorge Burgess IV2018-03-011-1/+1
| | | | | | | | | | | | | | | | | | | So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and `dyn_cast`s for fun. This is a portion of what it found for clang; I plan to do similar cleanups in LLVM and other subprojects when I find time. Because of the volume of changes, I explicitly avoided making any change that wasn't highly local and obviously correct to me (e.g. we still have a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading is a thing and the cast<Bar> did actually change the type -- just up the class hierarchy). I also tried to leave the types we were cast<>ing to somewhere nearby, in cases where it wasn't locally obvious what we were dealing with before. llvm-svn: 326416
* [coroutines] Support coroutine-handle returning await-suspend (i.e symmetric ↵Gor Nishanov2017-08-251-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | control transfer) Summary: If await_suspend returns a coroutine_handle, as in the example below: ``` coroutine_handle<> await_suspend(coroutine_handle<> h) { coro.promise().waiter = h; return coro; } ``` suspensionExpression processing will resume the coroutine pointed at by that handle. Related LLVM change rL311751 makes resume calls of this kind `musttail` at any optimization level. This enables unlimited symmetric control transfer from coroutine to coroutine without blowing up the stack. Reviewers: GorNishanov Reviewed By: GorNishanov Subscribers: rsmith, EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D37131 llvm-svn: 311762
* [coroutines] Evaluate the operand of void `co_return` expressions.Eric Fiselier2017-07-311-0/+7
| | | | | | | | | | | | | | | | | Summary: Previously Clang incorrectly ignored the expression of a void `co_return`. This patch addresses that bug. I'm not quite sure if I got the code-gen right, but this patch is at least a start. Reviewers: rsmith, GorNishanov Reviewed By: rsmith, GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36070 llvm-svn: 309545
* [coroutines] Remove pass-through operator co_await; Replace it with the ↵Eric Fiselier2017-06-151-13/+0
| | | | | | | | | | | | input expression Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Differential Revision: https://reviews.llvm.org/D34216 llvm-svn: 305498
* [coroutines] Allow co_await and co_yield expressions that return an lvalue ↵Eric Fiselier2017-06-151-5/+48
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 305496
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-031-0/+1
| | | | llvm-svn: 304649
* CGCoroutine.cpp: (NFC) clang-format misplaced braceGor Nishanov2017-05-291-2/+1
| | | | llvm-svn: 304176
* [coroutines] Add support for coroutines with non-scalar parametersGor Nishanov2017-05-241-6/+85
| | | | | | | | | | | | | | 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 llvm-svn: 303803
* [coroutines] Implement correct GRO lifetimeGor Nishanov2017-05-241-1/+72
| | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 303716
* [coroutines] Fix leak in CGCoroutine.cppGor Nishanov2017-05-241-0/+4
| | | | | | FinalBB need to be emitted even when unused to make sure it is deleted llvm-svn: 303714
* [coroutines] Skip over passthrough operator co_awaitGor Nishanov2017-05-231-0/+14
| | | | | | https://reviews.llvm.org/D31627 llvm-svn: 303605
* [coroutines] Add emission of initial and final suspendsGor Nishanov2017-05-231-2/+6
| | | | | | https://reviews.llvm.org/D31608 llvm-svn: 303603
* [coroutines] Add support for deallocation elisionGor Nishanov2017-05-231-8/+50
| | | | | | | | | | 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. llvm-svn: 303599
* [coroutines] Replace all coro.frame builtins with an SSA value of coro.beginGor Nishanov2017-05-231-1/+24
| | | | | | | | 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. llvm-svn: 303598
* [coroutines] Add support for allocation elisionGor Nishanov2017-05-231-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 303596
* [coroutines] Wrap the body of the coroutine in try-catchGor Nishanov2017-05-221-1/+22
| | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 303583
* [coroutines] Build GRO declaration and return GRO statementGor Nishanov2017-05-221-1/+5
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 303573
* [coroutines] Add coro.end handlingGor Nishanov2017-04-051-0/+41
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 299510
* [coroutines] Add cleanup for compiler injected objects/allocations in ↵Gor Nishanov2017-04-011-14/+34
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 299281
* [coroutines] Handle get_return_object_on_allocation_failureGor Nishanov2017-03-271-1/+18
| | | | | | | | | | | | | | | | | 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 llvm-svn: 298891
* [coroutines] Add codegen for await and yield expressionsGor Nishanov2017-03-261-8/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ] llvm-svn: 298784
* [coroutines] Add co_return statement emissionGor Nishanov2017-03-061-1/+35
| | | | | | | | | | | | | | | | | 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 llvm-svn: 297076
* [coroutines] Add allocation and deallocation substatements.Gor Nishanov2016-10-271-4/+20
| | | | | | | | | | | | | | 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 llvm-svn: 285306
* [coroutines] Adding builtins for coroutine intrinsics and backendutil support.Gor Nishanov2016-10-031-0/+100
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 llvm-svn: 283155
OpenPOWER on IntegriCloud