]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix tuple selector bug in CSE pass
authorMichael Munday <mike.munday@ibm.com>
Wed, 13 May 2020 15:46:16 +0000 (16:46 +0100)
committerMichael Munday <mike.munday@ibm.com>
Thu, 14 May 2020 08:07:52 +0000 (08:07 +0000)
commitf073395b73e2e5926a7bb996094a3e49ebc1d4dc
tree944699812596490cd4ed2b00a4973b39f94cf969
parente3ccf406231ece59975d999f18f37d1615112aaf
cmd/compile: fix tuple selector bug in CSE pass

When tuple generators and selectors are eliminated as part of the
CSE pass we may end up with tuple selectors that are in different
blocks to the tuple generators that they correspond to. This breaks
the invariant that tuple generators and their corresponding
selectors must be in the same block. Therefore after CSE this
situation must be corrected.

Unfortunately the fixup code did not take into account that selectors
could be eliminated by CSE. It assumed that only the tuple generators
could be eliminated. In some situations this meant that it got into
a state where it was replacing references to selectors with references
to dead selectors in the wrong block.

To fix this we move the fixup code after the CSE rewrites have been
applied. This removes any difficult-to-reason-about interactions
with the CSE rewriter.

Fixes #38916.

Change-Id: I2211982dcdba399d03299f0a819945b3eb93b291
Reviewed-on: https://go-review.googlesource.com/c/go/+/233857
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/cse.go
test/fixedbugs/issue38916.go [new file with mode: 0644]