From: David Chase Date: Tue, 1 Oct 2019 15:10:22 +0000 (-0400) Subject: cmd/compile: attempt to preserve statements when prove removes code X-Git-Tag: go1.14beta1~855 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9a926911fea73017a25d6d38035946c59cf1b047;p=gostls13.git cmd/compile: attempt to preserve statements when prove removes code This was a cause of some statements being lost. Change-Id: I81c95dcf3df6ed8a03b7578a27f9b21d33b3cf39 Reviewed-on: https://go-review.googlesource.com/c/go/+/198484 Run-TryBot: David Chase Reviewed-by: Jeremy Faller --- diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index efa4453f75..4f9a4d53fb 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -5,6 +5,7 @@ package ssa import ( + "cmd/internal/src" "fmt" "math" ) @@ -1284,18 +1285,22 @@ func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) { } func removeBranch(b *Block, branch branch) { + c := b.Controls[0] if b.Func.pass.debug > 0 { verb := "Proved" if branch == positive { verb = "Disproved" } - c := b.Controls[0] if b.Func.pass.debug > 1 { b.Func.Warnl(b.Pos, "%s %s (%s)", verb, c.Op, c) } else { b.Func.Warnl(b.Pos, "%s %s", verb, c.Op) } } + if c != nil && c.Pos.IsStmt() == src.PosIsStmt && c.Pos.SameFileAndLine(b.Pos) { + // attempt to preserve statement marker. + b.Pos = b.Pos.WithIsStmt() + } b.Kind = BlockFirst b.ResetControls() if branch == positive {