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.
Этот коммит содержится в:
Ayke van Laethem 2019-02-04 13:14:06 +01:00 коммит произвёл Ron Evans
родитель 553f00bdb8
коммит bece6b9648

Просмотреть файл

@ -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") return errors.New("expected all instructions in " + name + " to be *.init() calls")
} }
pkgName := initName[:len(initName)-5] 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 { if err == ErrUnreachable {
break break
} }
if err != nil { if err != nil {
return err return err
} }
call.EraseFromParentAsInstruction()
} }
return nil return nil