search for: coroutine

Displaying 20 results from an estimated 165 matches for "coroutine".

2016 Jul 21
2
RFC: LLVM Coroutine Representation, Round 2
...opposed to two-way. coro.elide and >> coro.delete >> renamed coro.alloc and coro.free. >> >> All the changes implemented and tested. Full document, (nicely formatted >> by >> github is at: >> >> https://github.com/GorNishanov/llvm/blob/coro-rfc/docs/Coroutines.rst >> >> Below is a summary of a proposal to add coroutine support to LLVM. >> The proposal is motivated primarily by the desire to support C++ >> Coroutines [1], >> however the llvm representation is language neutral and can be used >> to support coroutines in...
2016 Jun 09
6
Fwd: [RFC] LLVM Coroutines
Hi all: Below is a proposal to add experimental coroutine support to LLVM. Though this proposal is motivated primarily by the desire to support C++ Coroutines [1], the llvm representation is language neutral and can be used to support coroutines in other languages as well. Clang + llvm coroutines allows you to take this code: generator<int> rang...
2016 Jul 15
2
RFC: Coroutine Optimization Passes
Hi all: I've included below a brief description of coroutine related optimization passes and some questions/thoughts related to them. Looking forward to your feedback, comments and questions. Thank you! Roadmap: ======== 1) Get agreement on coroutine representation and overall direction. .. repeat 1) until happy http://lists.llvm.org/pipermail/llvm-de...
2011 Jul 28
4
[LLVMdev] [RFC] Coroutines
Hi llvmdev! I've been working on adding coroutines to LLVM. Mentioned below is the implementation plan I'm following, for suggestions, flames and other input. Using segmented stacks is a prerequisite. The idea is to associate every coroutine with a coroutine descriptor. A coroutine descriptor consists of four words: w0, w1, w2 and w3. w0 alw...
2011 Aug 04
0
[LLVMdev] [RFC] Coroutines
On 07/28/2011 05:31 PM, Sanjoy Das wrote: > Hi llvmdev! > > I've been working on adding coroutines to LLVM. Mentioned below is the > implementation plan I'm following, for suggestions, flames and other > input. Using segmented stacks is a prerequisite. I think my only comment is that, while this would probably work, implementing it in C with a bit of assembly for saving/restoring...
2016 Jun 12
2
[RFC] LLVM Coroutines
...in this return block? BTW, I am speaking of the return block as if it is one block, but, it could be a dominating block over all the blocks that together run the destructors, do return value conversion, etc. Clarification: ============== >> Also, if some non-C++ language wants to generate coroutines, >> it might not have to generate the return block at all. C++ coroutines are flexible. The semantic of a coroutine is defined via traits, so you may define a coroutine that returns void. It does not have to return coroutine handle or some struct that wraps the coroutine handle. For exampl...
2019 Dec 26
2
[RFC] Coroutines passes in the new pass manager
Hello all, It's been a month since my previous email on the topic, and since then I've done some initial work on porting the coroutines passes to the new pass manager. In total there are 6 patches -- that's a lot to review, so allow me to introduce the changes being made in each of them. # What's finished In these first 6 patches, I focused on lowering coroutine intrinsics correctly. With the patches applied, Clang is ab...
2016 Jun 15
2
[RFC] LLVM Coroutines
...lf_gas.S >> If so, I'd urge you to try to not rely on that kind of behavior. LLVM has >> unresolved issues around modeling setjmp like behavior Absolutely! This was just a thought experiment how one could implement the intrinsics in a library. One of the benefits of compiler based coroutines is that they allow to avoid all of that mess. Suspend is just a 'ret void', resume is simply a direct (or indirect) call and a coroutine state is tiny (assuming you don't use 64K arrays as local variables :-) ) >> DeleteBB: >> (*%t) = 15 ; // fine, copy of %t on...
2018 Jan 10
3
RFC: attribute synthetic("reason")
...LLVM to not attempt to propagate information about the function body outside of the function, including by changing the attributes of the function. The expectation is that some special pass will eventually remove the attribute and enable normal optimization. So, why should we add this? Problem: coroutine structure I've recently been working on implementing coroutines for Swift. This involves embracing and extending Gor's excellent work on LLVM coroutines with an alternate code-generation pattern and ABI. (*) LLVM doesn't natively support coroutines, which means that a pre-split corou...
2018 Jan 12
0
RFC: attribute synthetic("reason")
That all makes sense. I don't think the name "synthetic" is all that intuitive, though. Enum attributes are pretty cheap, maybe we should try to use a name closer to what we're trying to implement? For example, we could add a new "coroutine_foo" attribute for every coroutine style we implement. We would have analysis helper functions to answer questions like "is IPO through calls to this function legal" and "is IPO through calls in this function legal", and that's where we'd maintain the list of all co...
2016 Jul 15
4
RFC: Coroutine Optimization Passes
Hi David: >> How do you deal with basic blocks which appear to be used by multiple parts >> of the coroutine? We handled this in WinEHPrepare by cloning any BBs which >> were shared. I experimented with several approaches, but, cloning ended up being the simplest and most reliable. Suspend points express three different control flows that can happen at the suspend point: a suspension (default), res...
2018 Jan 10
0
RFC: attribute synthetic("reason")
(Forwarding response to llvm-dev with Dave's permission.) > On Jan 10, 2018, at 11:19 AM, David Blaikie <dblaikie at gmail.com> wrote: > Optnone stops these things, doesnt it? But then, as you say, you'd have to find some way to tunnels true optnone through to the coroutine expansion pass. > Right. More importantly, we definitely want to allow internal optimization of the coroutine function — mem2reg, GVN, etc. — prior to lowering. That should include inlining *into* it. The attribute should only block propagating information *out of* the function implementatio...
2018 Mar 19
2
Suggestions for how coroutines and UBSan codegen can play nice with one another?
Hello all! (+cc Vedant Kumar, who I've been told knows a lot about UBSan!) I am trying to fix an assert that occurs when the transforms in llvm/lib/Transforms/Coroutines are applied to LLVM IR that has been generated with UBSan enabled -- specifically, '-fsanitize=null'. You can see an example of the assert in this 26-line C++ file here: https://godbolt.org/g/Gw9UZq Note that without the '-fsanitize=null' option this compiles fine, but when that...
2016 Jun 12
2
[RFC] LLVM Coroutines
...>> switch i8 %0, label %resume1 [i8 1 %destroy1] ; or icmp + br i1 >> >> This doesn't look right: intuitively the suspend happens after the return >> block runs. Perhaps, but, that is not the intended semantics. The following two things are distinct concepts: * Coroutine is considered suspended * Coroutine returns control back to its caller (initial caller, resumer, or destroyer) Coroutine is considered suspended means that it is legal to use coro.done, coro.resume, coro.destroy intrinsics (either in this thread or in a different one). It may seem strange,...
2016 Jun 11
4
[RFC] LLVM Coroutines
On Fri, Jun 10, 2016 at 5:25 PM, Gor Nishanov <gornishanov at gmail.com> wrote: > Hi Eli: > > >> Naively, you would expect that it would be legal to hoist the store... > >> but that breaks your coroutine semantics because the global could be > mutated > >> between the first return and the resume. > > Hmmm... I don't see the problem. I think hoisting the store is perfectly > legal > transformation with all semantics preserved. > > Let's look at your example: &gt...
2018 Mar 19
0
Suggestions for how coroutines and UBSan codegen can play nice with one another?
> On Mar 19, 2018, at 3:44 PM, Brian Gesiak <modocache at gmail.com> wrote: > > Hello all! > (+cc Vedant Kumar, who I've been told knows a lot about UBSan!) > > I am trying to fix an assert that occurs when the transforms in llvm/lib/Transforms/Coroutines are applied to LLVM IR that has been generated with UBSan enabled -- specifically, '-fsanitize=null'. > > You can see an example of the assert in this 26-line C++ file here: https://godbolt.org/g/Gw9UZq <https://godbolt.org/g/Gw9UZq> > > Note that without the '-fsan...
2016 Jun 13
3
[RFC] LLVM Coroutines
...l: T coro() { %t = alloca %mem = malloc(...); (*%t) = 10 if (coro.fork()) { // switches to fiber at label Start ReturnBB: %val = *%t // will be 10, as fiber has its own copy return some_code_creating_T(%val); } Start: Body Of The Coroutine With Suspends and All The Fun DeleteBB: (*%t) = 15 ; // fine, copy of %t on a fiber stack updated free(%mem) (*%t) = 20 ; // undef: as the fiber memory is freed already coro.end(true) // switches back to the thread at ReturnBB UNREACHABLE // <== never...
2010 Apr 12
0
[LLVMdev] Proposal: stack/context switching within a thread
I'm very interested in seeing support for stack/context switching in LLVM, if only for prototyping language ideas. I'm particularly interested in mechanisms that would make it possible to implement full asymmetric coroutines as described in "Revisiting Coroutines" (Moura & Ierusalimschy, Feb 2009 TOPLAS). From skimming the thread and looking at the llvm-stack-switch wiki, it looks like you're headed more in the direction of symmetric coroutines. I've read that there is a Lua JIT based on LLVM, b...
2011 May 06
0
[LLVMdev] Requirements for the EH representation
...fferent solutions. I will dare a comment on this topic well over my head, so my answer will probably only reflect my ignorance on the deepness of the subject, however, in any case i hope to get some clarification of my concepts let me say more before i go into the idea on this post: I've used coroutines a lot in my c++ programming, and certainly when you work a lot of time with a hammer, everything starts looking like a nail. However, it has always seemed to me that exception handling (at least on c++) is just a particular syntax of a subset of coroutine semantics: void f() { throw 1; } void h(...
2016 Jun 12
2
[RFC] LLVM Coroutines
...turn block during optimizations. Let's make sure that there is only entry into the return block. In the original model, ReturnBB had two entries, one from coro.fork, another from fall-through from the delete block. T coro() { %mem = malloc(...); if (!coro.fork()) { Body Of The Coroutine With Suspends and All The Fun DeleteBB: free(%mem) coro.end() } ReturnBB: return some_code_creating_T(); } In the original model, coro.end is replaced with `no-op` in start, 'ret void' in clones (*) suspend is replaced with `br %return` in start, 're...