ssa: makeSlice both len/cap be non-nil

This commit is contained in:
visualfc
2024-06-26 06:49:48 +08:00
parent c90703dc13
commit dc4b933000
6 changed files with 30 additions and 33 deletions

View File

@@ -417,11 +417,7 @@ func (b Builder) MakeSlice(t Type, len, cap Expr) (ret Expr) {
}
prog := b.Prog
len = b.fitIntSize(len)
if cap.IsNil() {
cap = len
} else {
cap = b.fitIntSize(cap)
}
cap = b.fitIntSize(cap)
telem := prog.Index(t)
ret = b.InlineCall(b.Pkg.rtFunc("MakeSlice"), len, cap, prog.IntVal(prog.SizeOf(telem), prog.Int()))
ret.Type = t