Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions compiler/asserts.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// slice. This is required by the Go language spec: an index out of bounds must
// cause a panic.
func (c *Compiler) emitLookupBoundsCheck(frame *Frame, arrayLen, index llvm.Value, indexType types.Type) {
if frame.fn.IsNoBounds() {
if frame.info.nobounds {
// The //go:nobounds pragma was added to the function to avoid bounds
// checking.
return
Expand All @@ -32,8 +32,8 @@ func (c *Compiler) emitLookupBoundsCheck(frame *Frame, arrayLen, index llvm.Valu
arrayLen = c.builder.CreateZExt(arrayLen, index.Type(), "")
}

faultBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, "lookup.outofbounds")
nextBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, "lookup.next")
faultBlock := c.ctx.AddBasicBlock(frame.llvmFn, "lookup.outofbounds")
nextBlock := c.ctx.AddBasicBlock(frame.llvmFn, "lookup.next")
frame.blockExits[frame.currentBlock] = nextBlock // adjust outgoing block for phi nodes

// Now do the bounds check: index >= arrayLen
Expand All @@ -57,7 +57,7 @@ func (c *Compiler) emitLookupBoundsCheck(frame *Frame, arrayLen, index llvm.Valu
// biggest possible slice capacity, 'low' means len and 'high' means cap. The
// logic is the same in both cases.
func (c *Compiler) emitSliceBoundsCheck(frame *Frame, capacity, low, high, max llvm.Value, lowType, highType, maxType *types.Basic) {
if frame.fn.IsNoBounds() {
if frame.info.nobounds {
// The //go:nobounds pragma was added to the function to avoid bounds
// checking.
return
Expand Down Expand Up @@ -101,8 +101,8 @@ func (c *Compiler) emitSliceBoundsCheck(frame *Frame, capacity, low, high, max l
}
}

faultBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, "slice.outofbounds")
nextBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, "slice.next")
faultBlock := c.ctx.AddBasicBlock(frame.llvmFn, "slice.outofbounds")
nextBlock := c.ctx.AddBasicBlock(frame.llvmFn, "slice.next")
frame.blockExits[frame.currentBlock] = nextBlock // adjust outgoing block for phi nodes

// Now do the bounds check: low > high || high > capacity
Expand Down Expand Up @@ -132,8 +132,8 @@ func (c *Compiler) emitNilCheck(frame *Frame, ptr llvm.Value, blockPrefix string
}

// Check whether this is a nil pointer.
faultBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, blockPrefix+".nil")
nextBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, blockPrefix+".next")
faultBlock := c.ctx.AddBasicBlock(frame.llvmFn, blockPrefix+".nil")
nextBlock := c.ctx.AddBasicBlock(frame.llvmFn, blockPrefix+".next")
frame.blockExits[frame.currentBlock] = nextBlock // adjust outgoing block for phi nodes

// Compare against nil.
Expand Down
6 changes: 3 additions & 3 deletions compiler/calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func (c *Compiler) createRuntimeCall(fnName string, args []llvm.Value, name stri
if member == nil {
panic("trying to call runtime." + fnName)
}
fn := c.ir.GetFunction(member.(*ssa.Function))
if !fn.IsExported() {
fn := member.(*ssa.Function)
if !c.getFunctionInfo(fn).exported {
args = append(args, llvm.Undef(c.i8ptrType)) // unused context parameter
args = append(args, llvm.ConstPointerNull(c.i8ptrType)) // coroutine handle
}
return c.createCall(fn.LLVMFn, args, name)
return c.createCall(c.getFunction(fn), args, name)
}

// Create a call to the given function with the arguments possibly expanded.
Expand Down
Loading