aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-09-22 01:06:40 +0200
committerRon Evans <[email protected]>2022-10-19 22:23:19 +0200
commit229746b71ef8c6ab095f0e97aa722959c6f07268 (patch)
treee0270085fdb27908533b27708bf8c5f8da704e60 /interp
parent09ec846c9f3204837ae0695077f6e1359c545fe9 (diff)
downloadtinygo-229746b71ef8c6ab095f0e97aa722959c6f07268.tar.gz
tinygo-229746b71ef8c6ab095f0e97aa722959c6f07268.zip
interp: change object.llvmType to the initializer type
Previously it was a pointer type, which won't work with opaque pointers. Instead, use the global initializer type instead.
Diffstat (limited to 'interp')
-rw-r--r--interp/interpreter.go2
-rw-r--r--interp/memory.go4
2 files changed, 3 insertions, 3 deletions
diff --git a/interp/interpreter.go b/interp/interpreter.go
index d029aa333..8c783a706 100644
--- a/interp/interpreter.go
+++ b/interp/interpreter.go
@@ -637,7 +637,7 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
// Create the new object.
size := operands[0].(literalValue).value.(uint64)
alloca := object{
- llvmType: inst.llvmInst.Type(),
+ llvmType: inst.llvmInst.AllocatedType(),
globalName: r.pkgName + "$alloca",
buffer: newRawValue(uint32(size)),
size: uint32(size),
diff --git a/interp/memory.go b/interp/memory.go
index 583f9355f..6a537bad8 100644
--- a/interp/memory.go
+++ b/interp/memory.go
@@ -37,7 +37,7 @@ import (
// ability to roll back interpreting a function.
type object struct {
llvmGlobal llvm.Value
- llvmType llvm.Type // must match llvmGlobal.Type() if both are set, may be unset if llvmGlobal is set
+ llvmType llvm.Type // must match llvmGlobal.GlobalValueType() if both are set, may be unset if llvmGlobal is set
llvmLayoutType llvm.Type // LLVM type based on runtime.alloc layout parameter, if available
globalName string // name, if not yet created (not guaranteed to be the final name)
buffer value // buffer with value as given by interp, nil if external
@@ -594,7 +594,7 @@ func (v pointerValue) toLLVMValue(llvmType llvm.Type, mem *memoryView) (llvm.Val
var globalType llvm.Type
if !obj.llvmType.IsNil() {
// The exact type is known.
- globalType = obj.llvmType.ElementType()
+ globalType = obj.llvmType
} else { // !obj.llvmLayoutType.IsNil()
// The exact type isn't known, but the object layout is known.
globalType = obj.llvmLayoutType