Andrew Kelley via llvm-dev
2018-Feb-28 22:34 UTC
[llvm-dev] coro transformations insert unreachable in destroy fn?
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, %CheckFree 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 !296 unreachable 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>
Andrew Kelley via llvm-dev
2018-Feb-28 23:18 UTC
[llvm-dev] coro transformations insert unreachable in destroy fn?
Found the problem. Instead of the Return block I needed to use the Suspend block, which has the llvm.coro.end in it. On Wed, Feb 28, 2018 at 5:34 PM, Andrew Kelley <superjoe30 at gmail.com> wrote:> 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, > %CheckFree > 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 > !296 > unreachable > > > 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/c2884d08/attachment.html>