From 2fb5174910fd9cd38d592226e4660c99ca276ebb Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 25 Nov 2021 18:11:07 +0100 Subject: [PATCH] compiler: fix basic block context llvm.AddBasicBlock should never be used. Instead, we should use the AddBasicBlock method of the current LLVM context. This didn't lead to any bugs... yet. But probably would, eventually. --- compiler/alias.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/alias.go b/compiler/alias.go index ee51c5e52..7ca7f57cc 100644 --- a/compiler/alias.go +++ b/compiler/alias.go @@ -86,7 +86,7 @@ func (b *builder) createAlias(alias llvm.Value) { pos := b.program.Fset.Position(b.fn.Pos()) b.SetCurrentDebugLocation(uint(pos.Line), uint(pos.Column), b.difunc, llvm.Metadata{}) } - entryBlock := llvm.AddBasicBlock(b.llvmFn, "entry") + entryBlock := b.ctx.AddBasicBlock(b.llvmFn, "entry") b.SetInsertPointAtEnd(entryBlock) if b.llvmFn.Type() != alias.Type() { b.addError(b.fn.Pos(), "alias function should have the same type as aliasee "+alias.Name())