From 5b3ef2c02f51919fc76315904a831396c8099304 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 13 Sep 2018 20:48:23 +0200 Subject: [PATCH] compiler: fix unreachable type assert The unreachable instruction is actually a block terminator so may only be inserted at the end of a basic block. This is not always the case for type asserts, so don't insert this instruction. LLVM will hopefully optimize it anyway when it realizes anything after the panic() call is unreachable. --- compiler.go | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler.go b/compiler.go index c92f5509..58d2f3d9 100644 --- a/compiler.go +++ b/compiler.go @@ -2345,7 +2345,6 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) { } else { fn := c.mod.NamedFunction("runtime.interfaceTypeAssert") c.builder.CreateCall(fn, []llvm.Value{commaOk}, "") - c.builder.CreateUnreachable() return undef, nil } }