aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler/channel.go
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/channel.go')
-rw-r--r--compiler/channel.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/channel.go b/compiler/channel.go
index ac16510c6..de7b12e29 100644
--- a/compiler/channel.go
+++ b/compiler/channel.go
@@ -15,6 +15,12 @@ func (c *Compiler) emitMakeChan(frame *Frame, expr *ssa.MakeChan) llvm.Value {
elementSize := c.targetData.TypeAllocSize(c.getLLVMType(expr.Type().(*types.Chan).Elem()))
elementSizeValue := llvm.ConstInt(c.uintptrType, elementSize, false)
bufSize := c.getValue(frame, expr.Size)
+ c.emitChanBoundsCheck(frame, elementSize, bufSize, expr.Size.Type().Underlying().(*types.Basic), expr.Pos())
+ if bufSize.Type().IntTypeWidth() < c.uintptrType.IntTypeWidth() {
+ bufSize = c.builder.CreateZExt(bufSize, c.uintptrType, "")
+ } else if bufSize.Type().IntTypeWidth() > c.uintptrType.IntTypeWidth() {
+ bufSize = c.builder.CreateTrunc(bufSize, c.uintptrType, "")
+ }
return c.createRuntimeCall("chanMake", []llvm.Value{elementSizeValue, bufSize}, "")
}