interp: fix scanning declarations
Declarations would enter an infinite loop when trying to loop over basic blocks. That was probably an undefined operation, but still somehow didn't crash the compiler. Make sure that scanning declarations works as expected.
Этот коммит содержится в:
родитель
3b0ed63c29
коммит
feb2b4715b
3 изменённых файлов: 6 добавлений и 0 удалений
|
@ -57,6 +57,9 @@ func (e *Eval) hasSideEffects(fn llvm.Value) *sideEffectResult {
|
|||
case "llvm.dbg.value":
|
||||
return &sideEffectResult{severity: sideEffectNone}
|
||||
}
|
||||
if fn.IsDeclaration() {
|
||||
return &sideEffectResult{severity: sideEffectLimited}
|
||||
}
|
||||
if e.sideEffectFuncs == nil {
|
||||
e.sideEffectFuncs = make(map[llvm.Value]*sideEffectResult)
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ var scanTestTable = []struct {
|
|||
{"readCleanGlobal", sideEffectNone, []string{"cleanGlobalInt"}},
|
||||
{"readDirtyGlobal", sideEffectLimited, []string{"dirtyGlobalInt"}},
|
||||
{"callFunctionPointer", sideEffectAll, []string{"functionPointer"}},
|
||||
{"getDirtyPointer", sideEffectLimited, nil},
|
||||
}
|
||||
|
||||
func TestScan(t *testing.T) {
|
||||
|
|
2
interp/testdata/scan.ll
предоставленный
2
interp/testdata/scan.ll
предоставленный
|
@ -45,6 +45,8 @@ define i64 @readDirtyGlobal() {
|
|||
ret i64 %global
|
||||
}
|
||||
|
||||
declare i64* @getDirtyPointer()
|
||||
|
||||
@functionPointer = global i64()* null
|
||||
define i64 @callFunctionPointer() {
|
||||
%fp = load i64()*, i64()** @functionPointer
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче