From b5ecd9cab0e9a64e7e9289b2d459c4f9dc641091 Mon Sep 17 00:00:00 2001 From: Jaden Weiss Date: Wed, 25 Sep 2019 09:22:07 -0400 Subject: [PATCH] fix LLVM assertions from improved blocking --- compiler/goroutine-lowering.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/goroutine-lowering.go b/compiler/goroutine-lowering.go index aa69f072..45465b2f 100644 --- a/compiler/goroutine-lowering.go +++ b/compiler/goroutine-lowering.go @@ -483,7 +483,9 @@ func (c *Compiler) markAsyncFunctions() (needsScheduler bool, err error) { // delete everything after return for next := llvm.NextInstruction(retInst); !next.IsNil(); next = llvm.NextInstruction(retInst) { - next.ReplaceAllUsesWith(llvm.Undef(retInst.Type())) + if next.Type().TypeKind() != llvm.VoidTypeKind { + next.ReplaceAllUsesWith(llvm.Undef(next.Type())) + } next.EraseFromParentAsInstruction() } @@ -729,16 +731,20 @@ func (c *Compiler) markAsyncFunctions() (needsScheduler bool, err error) { if len(yieldCalls) == 0 { // no yields - we do not have to LLVM-ify this coroDebugPrintln("skipping", f.Name()) + deleteQueue := []llvm.Value{} for bb := f.EntryBasicBlock(); !bb.IsNil(); bb = llvm.NextBasicBlock(bb) { for inst := bb.FirstInstruction(); !inst.IsNil(); inst = llvm.NextInstruction(inst) { if !inst.IsACallInst().IsNil() && inst.CalledValue() == getCoroutine { // no seperate local task - replace getCoroutine with getParentHandle c.builder.SetInsertPointBefore(inst) inst.ReplaceAllUsesWith(c.createRuntimeCall("getParentHandle", []llvm.Value{}, "")) - inst.EraseFromParentAsInstruction() + deleteQueue = append(deleteQueue, inst) } } } + for _, v := range deleteQueue { + v.EraseFromParentAsInstruction() + } continue }