]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: reject some rare looping CFGs in shortcircuit
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 22 Feb 2021 19:55:14 +0000 (11:55 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 22 Feb 2021 20:27:09 +0000 (20:27 +0000)
commit04903476fe6a1bba4ed751f5e234bccb5a651a9b
tree14b5810689891c9b32c901277a066be00312562e
parent87e984ab2988afccdb75a4c235b318ec6be46e6a
cmd/compile: reject some rare looping CFGs in shortcircuit

One CFGs that shortcircuit looks for is:

p   q
 \ /
  b
 / \
t   u

The test case creates a CFG like that in which p == t.
That caused the compiler to generate a (short-lived) invalid phi value.

Fix this with a relatively big hammer: Disallow single-length loops entirely.
This is probably overkill, but it such loops are very rare.
This doesn't change the generated code for anything in std.

It generates worse code for the test case:
It no longer compiles the entire function away.

Fixes #44465

Change-Id: Ib8cdcd6cc9d7f48b4dab253652038ace24eae152
Reviewed-on: https://go-review.googlesource.com/c/go/+/295130
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/shortcircuit.go
test/fixedbugs/issue44465.go [new file with mode: 0644]