ssa: fix slice high

This commit is contained in:
visualfc
2024-06-26 20:09:38 +08:00
parent 8aed4d634b
commit 887ee0fd41
2 changed files with 69 additions and 1 deletions

View File

@@ -333,6 +333,7 @@ func (b Builder) Slice(x, low, high, max Expr) (ret Expr) {
if debugInstr {
log.Printf("Slice %v, %v, %v\n", x.impl, low.impl, high.impl)
}
prog := b.Prog
var nCap Expr
var nEltSize Expr
@@ -356,7 +357,7 @@ func (b Builder) Slice(x, low, high, max Expr) (ret Expr) {
nEltSize = SizeOf(prog, prog.Index(x.Type))
nCap = b.SliceCap(x)
if high.IsNil() {
high = b.SliceCap(x)
high = b.SliceLen(x)
}
ret.Type = x.Type
base = b.SliceData(x)