From bece6b964890e6b6ef2523f436717605551e4d7a Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 4 Feb 2019 13:14:06 +0100 Subject: interp: remove init call when hitting 'unreachable' The interp package interprets calls in runtime.initAll and replaces these calls with non-interpretable instructions if needed. When hitting an unreachable instruction, this call should be removed, but it wasn't. This commit makes sure the call is removed even before trying to interpret the package init function. --- interp/interp.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interp/interp.go b/interp/interp.go index db7797c2d..7328170a0 100644 --- a/interp/interp.go +++ b/interp/interp.go @@ -63,14 +63,15 @@ func Run(mod llvm.Module, targetData llvm.TargetData, debug bool) error { return errors.New("expected all instructions in " + name + " to be *.init() calls") } pkgName := initName[:len(initName)-5] - _, err := e.Function(call.CalledValue(), []Value{&LocalValue{e, undefPtr}, &LocalValue{e, undefPtr}}, pkgName) + fn := call.CalledValue() + call.EraseFromParentAsInstruction() + _, err := e.Function(fn, []Value{&LocalValue{e, undefPtr}, &LocalValue{e, undefPtr}}, pkgName) if err == ErrUnreachable { break } if err != nil { return err } - call.EraseFromParentAsInstruction() } return nil -- cgit v1.2.3