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.
Этот коммит содержится в:
родитель
553f00bdb8
коммит
bece6b9648
1 изменённых файлов: 3 добавлений и 2 удалений
|
@ -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
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче