diff options
| author | David Chase <drchase@google.com> | 2019-09-30 11:10:36 -0400 |
|---|---|---|
| committer | David Chase <drchase@google.com> | 2019-10-03 21:10:26 +0000 |
| commit | 08a87938bb95ae8859600be20a998fbb4b904915 (patch) | |
| tree | 013e07b59cc87917bb0cbf75e9ea0d94af49e552 /src | |
| parent | 53bd9151099c54ffb4fee73d8b1771e311f6a271 (diff) | |
| download | go-08a87938bb95ae8859600be20a998fbb4b904915.tar.xz | |
cmd/compile: make nilcheck more careful about statement relocations
The earlier code was picking nodes that were "poor choices" and
thus sometimes losing statements altogether.
Change-Id: Ibe5ed800ffbd3c926c0ab1bc10c77d72d3042e45
Reviewed-on: https://go-review.googlesource.com/c/go/+/198478
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/ssa/nilcheck.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/nilcheck.go b/src/cmd/compile/internal/ssa/nilcheck.go index 009c68afa1..9516d58a6e 100644 --- a/src/cmd/compile/internal/ssa/nilcheck.go +++ b/src/cmd/compile/internal/ssa/nilcheck.go @@ -153,12 +153,20 @@ func nilcheckelim(f *Func) { work = append(work, bp{op: ClearPtr, ptr: ptr}) fallthrough // a non-eliminated nil check might be a good place for a statement boundary. default: - if pendingLines.contains(v.Pos) && v.Pos.IsStmt() != src.PosNotStmt { + if v.Pos.IsStmt() != src.PosNotStmt && !isPoorStatementOp(v.Op) && pendingLines.contains(v.Pos) { v.Pos = v.Pos.WithIsStmt() pendingLines.remove(v.Pos) } } } + // This reduces the lost statement count in "go" by 5 (out of 500 total). + for j := 0; j < i; j++ { // is this an ordering problem? + v := b.Values[j] + if v.Pos.IsStmt() != src.PosNotStmt && !isPoorStatementOp(v.Op) && pendingLines.contains(v.Pos) { + v.Pos = v.Pos.WithIsStmt() + pendingLines.remove(v.Pos) + } + } if pendingLines.contains(b.Pos) { b.Pos = b.Pos.WithIsStmt() pendingLines.remove(b.Pos) |
