Skip to content

Commit

Permalink
fix malloc(i64) function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
douyixuan committed Aug 12, 2024
1 parent 64baa7c commit 59d2b33
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/compiler/types/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ func (s Slice) SliceZero(block *ir.Block, mallocFunc llvmValue.Named, initLen, i
block.NewStore(constant.NewInt(types.I32, 0), offset)

size := block.NewMul(initCap32, constant.NewInt(types.I32, s.Type.Size()))
mallocatedSpaceRaw := block.NewCall(mallocFunc, size)
size64 := llvmValue.Value(size)
if size64.Type() != types.I64 {
size64 = block.NewSExt(size64, types.I64)
}
mallocatedSpaceRaw := block.NewCall(mallocFunc, size64)
mallocatedSpaceRaw.SetName(name.Var("slicezero"))
bitcasted := block.NewBitCast(mallocatedSpaceRaw, types.NewPointer(s.Type.LLVM()))
block.NewStore(bitcasted, backingArray)
Expand Down

0 comments on commit 59d2b33

Please sign in to comment.