mirror of
https://github.com/golang/go
synced 2024-11-18 21:05:02 -07:00
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>
This commit is contained in:
parent
53bd915109
commit
08a87938bb
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user