mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 11:13:27 +00:00
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:
committed by
Ron Evans
parent
7e68980c39
commit
1681ed02d3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user