Skip to content

Commit 8000b20

Browse files
committed
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.
1 parent ba29a27 commit 8000b20

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261
1818
golang.org/x/tools v0.1.11
1919
gopkg.in/yaml.v2 v2.4.0
20-
tinygo.org/x/go-llvm v0.0.0-20220921144624-dabbe3f30634
20+
tinygo.org/x/go-llvm v0.0.0-20220922113433-4b5ad7ff76ec
2121
)
2222

2323
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
6464
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
6565
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
6666
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
67-
tinygo.org/x/go-llvm v0.0.0-20220921144624-dabbe3f30634 h1:hihbmHkJjalV4kGshoCF03P/G4IjoXcNAbzLblXLa/M=
68-
tinygo.org/x/go-llvm v0.0.0-20220921144624-dabbe3f30634/go.mod h1:GFbusT2VTA4I+l4j80b17KFK+6whv69Wtny5U+T8RR0=
67+
tinygo.org/x/go-llvm v0.0.0-20220922113433-4b5ad7ff76ec h1:FYtAFrw/YQPc644uNN65dW50FrEuVNaPBf70x23ApY4=
68+
tinygo.org/x/go-llvm v0.0.0-20220922113433-4b5ad7ff76ec/go.mod h1:GFbusT2VTA4I+l4j80b17KFK+6whv69Wtny5U+T8RR0=

interp/interpreter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
637637
// Create the new object.
638638
size := operands[0].(literalValue).value.(uint64)
639639
alloca := object{
640-
llvmType: inst.llvmInst.Type(),
640+
llvmType: inst.llvmInst.AllocatedType(),
641641
globalName: r.pkgName + "$alloca",
642642
buffer: newRawValue(uint32(size)),
643643
size: uint32(size),

interp/memory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
// ability to roll back interpreting a function.
3838
type object struct {
3939
llvmGlobal llvm.Value
40-
llvmType llvm.Type // must match llvmGlobal.Type() if both are set, may be unset if llvmGlobal is set
40+
llvmType llvm.Type // must match llvmGlobal.GlobalValueType() if both are set, may be unset if llvmGlobal is set
4141
llvmLayoutType llvm.Type // LLVM type based on runtime.alloc layout parameter, if available
4242
globalName string // name, if not yet created (not guaranteed to be the final name)
4343
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
594594
var globalType llvm.Type
595595
if !obj.llvmType.IsNil() {
596596
// The exact type is known.
597-
globalType = obj.llvmType.ElementType()
597+
globalType = obj.llvmType
598598
} else { // !obj.llvmLayoutType.IsNil()
599599
// The exact type isn't known, but the object layout is known.
600600
globalType = obj.llvmLayoutType

0 commit comments

Comments
 (0)