Loading…
This event has ended. View the official site or create your own event → Check it out
This event has ended. Create your own
View analytic
Thursday, November 3 • 11:15am - 12:00pm
LLVM Coroutines: Bringing resumable functions to LLVM

Sign up or log in to save this to your schedule and see who's attending!

Though invented long time ago in 1957, coroutines are getting popular in this century. More and more languages adopt them to deal with lazily produced sequences and to simplify asynchronous programming. However, until recently, coroutines in high level languages were distinctly not a zero-overhead abstraction. We are rectifying that by adding coroutine support to LLVM that allows, finally, for high-level language to have efficient coroutines

In this talk, we will look at coroutine examples in C++ and LLVM IR, at optimization passes that deal with coroutines and at LLVM coroutine representation that C++ and other frontend can use to describe coroutines to LLVM.

LLVM coroutines are functions that can suspend their execution and return control back to their callers. Suspended coroutines can be resumed to continue execution when desired. 

Though coroutine support in LLVM is motivated primarily by the desire to support C++ Coroutines, the LLVM coroutine 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> range(int from, int to) { 
for(int i = from; i < to; ++i) 
co_yield i; 

int main() { 
int sum = 0; 
for (auto v: range(1,100)) 
sum += v; 
return sum; 


And translate it down to this: 

define i32 @main() #5 { 
entry: 
ret i32 4950 


You can't get any better than that!

Speakers
avatar for Gor Nishanov

Gor Nishanov

Principal Software Engineer, Microsoft
Gor Nishanov is a Principal Software Design Engineer on the Microsoft C++ team. He works on design and standardization of C++ Coroutines, and on asynchronous programming models. Prior to joining C++ team, Gor was working on distributed systems in Windows Clustering team.


Thursday November 3, 2016 11:15am - 12:00pm
1 - General Session (Rm LL20ABC)

Attendees (45)