Page MenuHomePhabricator

[coroutines] Add support for allocation elision
ClosedPublic

Authored by GorNishanov on Apr 2 2017, 12:31 PM.

Details

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)

Event Timeline

GorNishanov created this revision.Apr 2 2017, 12:31 PM

It is a simple change. If there is no objections, I'll commit it tomorrow.

This revision was automatically updated to reflect the committed changes.