diff options
author | Ayke van Laethem <[email protected]> | 2022-09-20 23:26:49 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-10-19 22:23:19 +0200 |
commit | 09ec846c9f3204837ae0695077f6e1359c545fe9 (patch) | |
tree | 127038e48ef68270bc4bafbc16c700328a13d8c0 /interp | |
parent | f57cffce2d47f7c2b3c9ec1ddd1f077f0830d435 (diff) | |
download | tinygo-09ec846c9f3204837ae0695077f6e1359c545fe9.tar.gz tinygo-09ec846c9f3204837ae0695077f6e1359c545fe9.zip |
all: replace llvm.Const* calls with builder.Create* calls
A number of llvm.Const* functions (in particular extractvalue and
insertvalue) were removed in LLVM 15, so we have to use a builder
instead. This builder will create the same constant values, it simply
uses a different API.
Diffstat (limited to 'interp')
-rw-r--r-- | interp/interpreter.go | 13 | ||||
-rw-r--r-- | interp/memory.go | 8 |
2 files changed, 11 insertions, 10 deletions
diff --git a/interp/interpreter.go b/interp/interpreter.go index 2c7fd8c30..d029aa333 100644 --- a/interp/interpreter.go +++ b/interp/interpreter.go @@ -408,7 +408,7 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent // Elem() is only valid for certain type classes. switch class { case "chan", "pointer", "slice", "array": - elementType := llvm.ConstExtractValue(typecodeID.Initializer(), []uint32{0}) + elementType := r.builder.CreateExtractValue(typecodeID.Initializer(), 0, "") uintptrType := r.mod.Context().IntType(int(mem.r.pointerSize) * 8) locals[inst.localIndex] = r.getValue(llvm.ConstPtrToInt(elementType, uintptrType)) default: @@ -461,8 +461,8 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent // easier checking in the next step. concreteTypeMethods := map[string]struct{}{} for i := 0; i < methodSet.Type().ArrayLength(); i++ { - methodInfo := llvm.ConstExtractValue(methodSet, []uint32{uint32(i)}) - name := llvm.ConstExtractValue(methodInfo, []uint32{0}).Name() + methodInfo := r.builder.CreateExtractValue(methodSet, i, "") + name := r.builder.CreateExtractValue(methodInfo, 0, "").Name() concreteTypeMethods[name] = struct{}{} } @@ -496,7 +496,7 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent typecodeID := typecodeIDBitCast.Operand(0).Initializer() // Load the method set, which is part of the typecodeID object. - methodSet := llvm.ConstExtractValue(typecodeID, []uint32{2}).Operand(0).Initializer() + methodSet := r.builder.CreateExtractValue(typecodeID, 2, "").Operand(0).Initializer() // We don't need to load the interface method set. @@ -511,9 +511,10 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent numMethods := methodSet.Type().ArrayLength() var method llvm.Value for i := 0; i < numMethods; i++ { - methodSignature := llvm.ConstExtractValue(methodSet, []uint32{uint32(i), 0}) + methodSignatureAgg := r.builder.CreateExtractValue(methodSet, i, "") + methodSignature := r.builder.CreateExtractValue(methodSignatureAgg, 0, "") if methodSignature == signature { - method = llvm.ConstExtractValue(methodSet, []uint32{uint32(i), 1}).Operand(0) + method = r.builder.CreateExtractValue(methodSignatureAgg, 1, "").Operand(0) } } if method.IsNil() { diff --git a/interp/memory.go b/interp/memory.go index 2fa6f5cbc..583f9355f 100644 --- a/interp/memory.go +++ b/interp/memory.go @@ -215,7 +215,7 @@ func (mv *memoryView) markExternal(llvmValue llvm.Value, mark uint8) error { case llvm.StructTypeKind: numElements := llvmType.StructElementTypesCount() for i := 0; i < numElements; i++ { - element := llvm.ConstExtractValue(llvmValue, []uint32{uint32(i)}) + element := mv.r.builder.CreateExtractValue(llvmValue, i, "") err := mv.markExternal(element, mark) if err != nil { return err @@ -224,7 +224,7 @@ func (mv *memoryView) markExternal(llvmValue llvm.Value, mark uint8) error { case llvm.ArrayTypeKind: numElements := llvmType.ArrayLength() for i := 0; i < numElements; i++ { - element := llvm.ConstExtractValue(llvmValue, []uint32{uint32(i)}) + element := mv.r.builder.CreateExtractValue(llvmValue, i, "") err := mv.markExternal(element, mark) if err != nil { return err @@ -1074,7 +1074,7 @@ func (v *rawValue) set(llvmValue llvm.Value, r *runner) { field := rawValue{ buf: v.buf[offset:], } - field.set(llvm.ConstExtractValue(llvmValue, []uint32{uint32(i)}), r) + field.set(r.builder.CreateExtractValue(llvmValue, i, ""), r) } case llvm.ArrayTypeKind: numElements := llvmType.ArrayLength() @@ -1085,7 +1085,7 @@ func (v *rawValue) set(llvmValue llvm.Value, r *runner) { field := rawValue{ buf: v.buf[offset:], } - field.set(llvm.ConstExtractValue(llvmValue, []uint32{uint32(i)}), r) + field.set(r.builder.CreateExtractValue(llvmValue, i, ""), r) } case llvm.DoubleTypeKind: f, _ := llvmValue.DoubleValue() |