• David Chase's avatar
    cmd/compile: correct sparseSet probes in regalloc to avoid index error · 3c090019
    David Chase authored
    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/22911Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    Run-TryBot: David Chase <drchase@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    3c090019
issue15585.go 829 Bytes