llgo/ssa: Alloc bugfix (heap)
This commit is contained in:
@@ -410,11 +410,11 @@ func (b Builder) Alloc(t *types.Pointer, heap bool) (ret Expr) {
|
|||||||
prog := b.prog
|
prog := b.prog
|
||||||
telem := t.Elem()
|
telem := t.Elem()
|
||||||
if heap {
|
if heap {
|
||||||
ret.impl = llvm.CreateAlloca(b.impl, prog.Type(telem).ll)
|
|
||||||
} else {
|
|
||||||
pkg := b.fn.pkg
|
pkg := b.fn.pkg
|
||||||
size := unsafe.Sizeof(telem)
|
size := unsafe.Sizeof(telem)
|
||||||
ret = b.Call(pkg.rtFunc("Alloc"), prog.Val(size))
|
ret = b.Call(pkg.rtFunc("Alloc"), prog.Val(size))
|
||||||
|
} else {
|
||||||
|
ret.impl = llvm.CreateAlloca(b.impl, prog.Type(telem).ll)
|
||||||
}
|
}
|
||||||
// TODO(xsw): zero-initialize
|
// TODO(xsw): zero-initialize
|
||||||
ret.Type = prog.Type(t)
|
ret.Type = prog.Type(t)
|
||||||
|
|||||||
Reference in New Issue
Block a user