For constant-index, variable length situations.
Inadvertant shadowing of the yVal variable. Oops.
Fixes #75327
Change-Id: I3403066fc39b7664222a3098cf0f22b5761ea66a
Reviewed-on: https://go-review.googlesource.com/c/go/+/702015
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
}
case ssa.OpAMD64LoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - x86.REG_AX)
+ yVal = int(v.Args[0].Reg() - x86.REG_AX)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.OpARMLoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - arm.REG_R0)
+ yVal = int(v.Args[0].Reg() - arm.REG_R0)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.OpARM64LoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - arm64.REG_R0)
+ yVal = int(v.Args[0].Reg() - arm64.REG_R0)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.OpLOONG64LoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - loong64.REG_R4)
+ yVal = int(v.Args[0].Reg() - loong64.REG_R4)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.OpMIPSLoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - mips.REG_R1)
+ yVal = int(v.Args[0].Reg() - mips.REG_R1)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.OpMIPS64LoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - mips.REG_R1)
+ yVal = int(v.Args[0].Reg() - mips.REG_R1)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.OpPPC64LoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - ppc64.REG_R3)
+ yVal = int(v.Args[0].Reg() - ppc64.REG_R3)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.OpRISCV64LoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - riscv.REG_X5)
+ yVal = int(v.Args[0].Reg() - riscv.REG_X5)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.OpS390XLoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - s390x.REG_R0)
+ yVal = int(v.Args[0].Reg() - s390x.REG_R0)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
}
case ssa.Op386LoweredPanicBoundsCR:
yIsReg = true
- yVal := int(v.Args[0].Reg() - x86.REG_AX)
+ yVal = int(v.Args[0].Reg() - x86.REG_AX)
c := v.Aux.(ssa.PanicBoundsC).C
if c >= 0 && c <= abi.BoundsMaxConst {
xVal = int(c)
--- /dev/null
+// run
+
+package main
+
+import (
+ "fmt"
+ "strings"
+)
+
+func main() {
+ defer func() {
+ err := recover()
+ txt := fmt.Sprintf("%s", err)
+ if !strings.HasSuffix(txt, "with length 1") {
+ panic("bad error: " + txt)
+ }
+ }()
+ foo([]uint64{0})
+}
+
+//go:noinline
+func foo(haystack []uint64) {
+ for n := range len(haystack) {
+ _ = n
+ _ = haystack[1]
+ }
+
+ xxx := haystack[0:len(haystack)]
+ sink(xxx)
+}
+
+//go:noinline
+func sink([]uint64) {}