diff options
author | Ayke van Laethem <[email protected]> | 2021-03-25 00:42:04 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-03-25 13:05:09 +0100 |
commit | 6d3c11627c1288e5b865763070709e30a95013db (patch) | |
tree | 535ae5eb22a3decf794265213cdd6c8ea919b102 /compiler/interface.go | |
parent | f800f7507c95f2038bfe5943ca710bb7f87d8a82 (diff) | |
download | tinygo-6d3c11627c1288e5b865763070709e30a95013db.tar.gz tinygo-6d3c11627c1288e5b865763070709e30a95013db.zip |
compiler: fix use of global context: llvm.Int32Type()
This patch fixes a use of the global context. I've seen a few instances
of crashes in the llvm.ConstInt function when called from
makeStructTypeFields, which I believe are caused by this bug.
Diffstat (limited to 'compiler/interface.go')
-rw-r--r-- | compiler/interface.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/interface.go b/compiler/interface.go index 535e7650d..b4bf4cd0c 100644 --- a/compiler/interface.go +++ b/compiler/interface.go @@ -103,8 +103,8 @@ func (c *compilerContext) makeStructTypeFields(typ *types.Struct) llvm.Value { fieldName.SetLinkage(llvm.PrivateLinkage) fieldName.SetUnnamedAddr(true) fieldName = llvm.ConstGEP(fieldName, []llvm.Value{ - llvm.ConstInt(llvm.Int32Type(), 0, false), - llvm.ConstInt(llvm.Int32Type(), 0, false), + llvm.ConstInt(c.ctx.Int32Type(), 0, false), + llvm.ConstInt(c.ctx.Int32Type(), 0, false), }) fieldGlobalValue = llvm.ConstInsertValue(fieldGlobalValue, fieldName, []uint32{1}) if typ.Tag(i) != "" { @@ -112,8 +112,8 @@ func (c *compilerContext) makeStructTypeFields(typ *types.Struct) llvm.Value { fieldTag.SetLinkage(llvm.PrivateLinkage) fieldTag.SetUnnamedAddr(true) fieldTag = llvm.ConstGEP(fieldTag, []llvm.Value{ - llvm.ConstInt(llvm.Int32Type(), 0, false), - llvm.ConstInt(llvm.Int32Type(), 0, false), + llvm.ConstInt(c.ctx.Int32Type(), 0, false), + llvm.ConstInt(c.ctx.Int32Type(), 0, false), }) fieldGlobalValue = llvm.ConstInsertValue(fieldGlobalValue, fieldTag, []uint32{2}) } |