diff options
author | Ayke van Laethem <[email protected]> | 2021-04-05 14:46:08 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-04-08 11:40:59 +0200 |
commit | 61243f6c57b4158c28666ebadc6344e143ca02f1 (patch) | |
tree | 1be50b83b9cbcbe7b7928eefe739bc116c628a14 /interp | |
parent | 49ec3eb58e3ae2fd373b1c65883dcd05c588357a (diff) | |
download | tinygo-61243f6c57b4158c28666ebadc6344e143ca02f1.tar.gz tinygo-61243f6c57b4158c28666ebadc6344e143ca02f1.zip |
transform: don't rely on struct name of runtime.typecodeID
Sometimes, LLVM may rename named structs when merging modules.
Therefore, we can't rely on typecodeID structs to retain their struct
names.
This commit changes the interface lowering pass to not rely on these
names. The interp package does however still rely on this name, but I
hope to fix that in the future.
Diffstat (limited to 'interp')
-rw-r--r-- | interp/interpreter.go | 2 | ||||
-rw-r--r-- | interp/testdata/interface.ll | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/interp/interpreter.go b/interp/interpreter.go index 3bbf9e5f9..c0dc45d93 100644 --- a/interp/interpreter.go +++ b/interp/interpreter.go @@ -328,7 +328,7 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent return nil, mem, r.errorAt(inst, err) } actualType := actualTypePtrToInt.Operand(0) - if actualType.Name()+"$id" == assertedType.Name() { + if strings.TrimPrefix(actualType.Name(), "reflect/types.type:") == strings.TrimPrefix(assertedType.Name(), "reflect/types.typeid:") { locals[inst.localIndex] = literalValue{uint8(1)} } else { locals[inst.localIndex] = literalValue{uint8(0)} diff --git a/interp/testdata/interface.ll b/interp/testdata/interface.ll index 8031632f7..060256d22 100644 --- a/interp/testdata/interface.ll +++ b/interp/testdata/interface.ll @@ -6,7 +6,7 @@ target triple = "x86_64--linux" @main.v1 = global i1 0 @"reflect/types.type:named:main.foo" = private constant %runtime.typecodeID { %runtime.typecodeID* @"reflect/types.type:basic:int", i64 0, %runtime.interfaceMethodInfo* null } -@"reflect/types.type:named:main.foo$id" = external constant i8 +@"reflect/types.typeid:named:main.foo" = external constant i8 @"reflect/types.type:basic:int" = external constant %runtime.typecodeID @@ -21,7 +21,7 @@ entry: define internal void @main.init() unnamed_addr { entry: ; Test type asserts. - %typecode = call i1 @runtime.typeAssert(i64 ptrtoint (%runtime.typecodeID* @"reflect/types.type:named:main.foo" to i64), i8* @"reflect/types.type:named:main.foo$id", i8* undef, i8* null) + %typecode = call i1 @runtime.typeAssert(i64 ptrtoint (%runtime.typecodeID* @"reflect/types.type:named:main.foo" to i64), i8* @"reflect/types.typeid:named:main.foo", i8* undef, i8* null) store i1 %typecode, i1* @main.v1 ret void } |