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.
This commit is contained in:
Ayke van Laethem
2019-11-04 12:45:18 +01:00
committed by Ron Evans
parent 3b0ed63c29
commit feb2b4715b
3 changed files with 6 additions and 0 deletions
+3
View File
@@ -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)
}
+1
View File
@@ -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
View File
@@ -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