interp: take care of constant globals

Constant globals can't have been modified, even if a pointer is passed
externally. Therefore, don't treat it as such in hasExternalStore.

In addition, it doesn't make sense to update values of constant globals
after the interp pass is finished. So don't do this.

TODO: track whether objects are actually modified and only update the
globals if this is the case.
This commit is contained in:
Ayke van Laethem
2021-11-11 02:41:29 +01:00
committed by Ron Evans
parent 7e68980c39
commit 1681ed02d3
4 changed files with 25 additions and 1 deletions
+6
View File
@@ -145,6 +145,9 @@ func Run(mod llvm.Module, debug bool) error {
if obj.buffer == nil {
continue
}
if obj.constant {
continue // constant buffers can't have been modified
}
initializer, err := obj.buffer.toLLVMValue(obj.llvmGlobal.Type().ElementType(), &mem)
if err == errInvalidPtrToIntSize {
// This can happen when a previous interp run did not have the
@@ -248,6 +251,9 @@ func RunFunc(fn llvm.Value, debug bool) error {
if obj.buffer == nil {
continue
}
if obj.constant {
continue // constant, so can't have been modified
}
initializer, err := obj.buffer.toLLVMValue(obj.llvmGlobal.Type().ElementType(), &mem)
if err != nil {
return err