[llvm-dev] coro transformations insert unreachable in destroy fn?

Andrew Kelley via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 28 14:34:08 PST 2018

I have this input IR in the final cleanup block of my coroutine:

// call the free function
  call fastcc void %22(%Allocator* %20, %"[]u8"* byval %4), !dbg !244

// based on whether this is an early return or a normal return, we want to
// either return to the caller, or resume the handle of the awaiter
  br i1 %19, label %Resume, label %Return, !dbg !244

Resume:                                           ; preds = %CheckFree
  %31 = load i8*, i8** %14, align 8, !dbg !244
  call void @llvm.coro.resume(i8* %31), !dbg !244

// after resuming the awaiter, we return to the caller
  br label %Return, !dbg !244

Return:                                           ; preds = %Resume,
  ret i8* undef, !dbg !244

When CoroSplit creates the destroy function for this coroutine, it
generates this:

  call fastcc void %2(%Allocator* %0, %"[]u8"* byval %.reload.addr4), !dbg

How did that unreachable get there? What happened to my code above to
resume or return to the caller?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180228/c7ff15bb/attachment.html>

More information about the llvm-dev mailing list