]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: correct sparseSet probes in regalloc to avoid index error
authorDavid Chase <drchase@google.com>
Sat, 7 May 2016 00:05:02 +0000 (17:05 -0700)
committerDavid Chase <drchase@google.com>
Mon, 9 May 2016 18:35:44 +0000 (18:35 +0000)
commit3c090019172afd4517360606efc50750d3e278fa
tree38383087293c0dc1bb186204410a13a76c22a136
parent149ac34893ad1cc5023ae2fbabd0d553f21b0313
cmd/compile: correct sparseSet probes in regalloc to avoid index error

In regalloc, a sparse map is preallocated for later use by
spill-in-loop sinking.  However, variables (spills) are added
during register allocation before spill sinking, and a map
query involving any of these new variables will index out of
bounds in the map.

To fix:
1) fix the queries to use s.orig[v.ID].ID instead, to ensure
proper indexing.  Note that s.orig will be nil for values
that are not eligible for spilling (like memory and flags).

2) add a test.

Fixes #15585.

Change-Id: I8f2caa93b132a0f2a9161d2178320d5550583075
Reviewed-on: https://go-review.googlesource.com/22911
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/ssa/regalloc.go
test/fixedbugs/issue15585.go [new file with mode: 0644]