aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ppc64
diff options
context:
space:
mode:
authorKeith Randall <khr@google.com>2019-02-06 14:12:36 -0800
committerKeith Randall <khr@golang.org>2019-03-18 17:33:38 +0000
commit2c423f063b137781a97a6a56998a2e3abffc4051 (patch)
treea77e1513516b655f90c6a9fb12fbc07c9f1e7af1 /src/cmd/compile/internal/ppc64
parentb48bda9c6f57ca9a940eac95700485b9640a62e9 (diff)
downloadgo-2c423f063b137781a97a6a56998a2e3abffc4051.tar.gz
go-2c423f063b137781a97a6a56998a2e3abffc4051.zip
cmd/compile,runtime: provide index information on bounds check failure
A few examples (for accessing a slice of length 3): s[-1] runtime error: index out of range [-1] s[3] runtime error: index out of range [3] with length 3 s[-1:0] runtime error: slice bounds out of range [-1:] s[3:0] runtime error: slice bounds out of range [3:0] s[3:-1] runtime error: slice bounds out of range [:-1] s[3:4] runtime error: slice bounds out of range [:4] with capacity 3 s[0:3:4] runtime error: slice bounds out of range [::4] with capacity 3 Note that in cases where there are multiple things wrong with the indexes (e.g. s[3:-1]), we report one of those errors kind of arbitrarily, currently the rightmost one. An exhaustive set of examples is in issue30116[u].out in the CL. The message text has the same prefix as the old message text. That leads to slightly awkward phrasing but hopefully minimizes the chance that code depending on the error text will break. Increases the size of the go binary by 0.5% (amd64). The panic functions take arguments in registers in order to keep the size of the compiled code as small as possible. Fixes #30116 Change-Id: Idb99a827b7888822ca34c240eca87b7e44a04fdd Reviewed-on: https://go-review.googlesource.com/c/go/+/161477 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ppc64')
-rw-r--r--src/cmd/compile/internal/ppc64/ssa.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ppc64/ssa.go b/src/cmd/compile/internal/ppc64/ssa.go
index 3b37c797a9..4cccbecbb3 100644
--- a/src/cmd/compile/internal/ppc64/ssa.go
+++ b/src/cmd/compile/internal/ppc64/ssa.go
@@ -1183,6 +1183,13 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p.To.Name = obj.NAME_EXTERN
p.To.Sym = v.Aux.(*obj.LSym)
+ case ssa.OpPPC64LoweredPanicBoundsA, ssa.OpPPC64LoweredPanicBoundsB, ssa.OpPPC64LoweredPanicBoundsC:
+ p := s.Prog(obj.ACALL)
+ p.To.Type = obj.TYPE_MEM
+ p.To.Name = obj.NAME_EXTERN
+ p.To.Sym = gc.BoundsCheckFunc[v.AuxInt]
+ s.UseArgs(16) // space used in callee args area by assembly stubs
+
case ssa.OpPPC64LoweredNilCheck:
if objabi.GOOS == "aix" {
// CMP Rarg0, R0