aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp/memory.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-09-22 13:33:00 +0200
committerRon Evans <[email protected]>2022-10-19 22:23:19 +0200
commit62df1d7490ccf495dc08837ec72ee1d6042bc374 (patch)
tree379a9e4e5f46dc8293beeb3ba1f386f08bdf53c9 /interp/memory.go
parent229746b71ef8c6ab095f0e97aa722959c6f07268 (diff)
downloadtinygo-62df1d7490ccf495dc08837ec72ee1d6042bc374.tar.gz
tinygo-62df1d7490ccf495dc08837ec72ee1d6042bc374.zip
all: remove pointer ElementType calls
This is needed for opaque pointers, which are enabled by default in LLVM 15.
Diffstat (limited to 'interp/memory.go')
-rw-r--r--interp/memory.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/interp/memory.go b/interp/memory.go
index 6a537bad8..82ab716d4 100644
--- a/interp/memory.go
+++ b/interp/memory.go
@@ -808,14 +808,17 @@ func (v rawValue) rawLLVMValue(mem *memoryView) (llvm.Value, error) {
if err != nil {
return llvm.Value{}, err
}
- elementType := field.Type().ElementType()
- if elementType.TypeKind() == llvm.StructTypeKind {
- // There are some special pointer types that should be used as a
- // ptrtoint, so that they can be used in certain optimizations.
- name := elementType.StructName()
- if name == "runtime.typecodeID" || name == "runtime.funcValueWithSignature" {
- uintptrType := ctx.IntType(int(mem.r.pointerSize) * 8)
- field = llvm.ConstPtrToInt(field, uintptrType)
+ if !field.IsAGlobalVariable().IsNil() {
+ elementType := field.GlobalValueType()
+ if elementType.TypeKind() == llvm.StructTypeKind {
+ // There are some special pointer types that should be used
+ // as a ptrtoint, so that they can be used in certain
+ // optimizations.
+ name := elementType.StructName()
+ if name == "runtime.typecodeID" || name == "runtime.funcValueWithSignature" {
+ uintptrType := ctx.IntType(int(mem.r.pointerSize) * 8)
+ field = llvm.ConstPtrToInt(field, uintptrType)
+ }
}
}
structFields = append(structFields, field)
@@ -998,7 +1001,7 @@ func (v *rawValue) set(llvmValue llvm.Value, r *runner) {
ptr := llvmValue.Operand(0)
index := llvmValue.Operand(1)
numOperands := llvmValue.OperandsCount()
- elementType := ptr.Type().ElementType()
+ elementType := llvmValue.GEPSourceElementType()
totalOffset := r.targetData.TypeAllocSize(elementType) * index.ZExtValue()
for i := 2; i < numOperands; i++ {
indexValue := llvmValue.Operand(i)
@@ -1173,7 +1176,7 @@ func (r *runner) getValue(llvmValue llvm.Value) value {
r.globals[llvmValue] = index
r.objects = append(r.objects, obj)
if !llvmValue.IsAGlobalVariable().IsNil() {
- obj.size = uint32(r.targetData.TypeAllocSize(llvmValue.Type().ElementType()))
+ obj.size = uint32(r.targetData.TypeAllocSize(llvmValue.GlobalValueType()))
if initializer := llvmValue.Initializer(); !initializer.IsNil() {
obj.buffer = r.getValue(initializer)
obj.constant = llvmValue.IsGlobalConstant()