diff options
author | David Chase <drchase@google.com> | 2021-04-12 20:53:03 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2021-04-14 18:46:08 +0000 |
commit | 4df3d0e4df734283911cf3c428d9638c9dc5af4e (patch) | |
tree | 65a4040cb386e4309172a234259139792eb7537b /src/cmd/compile/internal/ssa/expand_calls.go | |
parent | 4480c822ba37ea3795fa4dbb56d13578d7961d88 (diff) | |
download | go-4df3d0e4df734283911cf3c428d9638c9dc5af4e.tar.gz go-4df3d0e4df734283911cf3c428d9638c9dc5af4e.zip |
cmd/compile: rescue stmt boundaries from OpArgXXXReg and OpSelectN.
Fixes this failure:
go test cmd/compile/internal/ssa -run TestStmtLines -v
=== RUN TestStmtLines
stmtlines_test.go:115: Saw too many (amd64, > 1%) lines without
statement marks, total=88263, nostmt=1930
('-run TestStmtLines -v' lists failing lines)
The failure has two causes.
One is that the first-line adjuster in code generation was relocating
"first lines" to instructions that would either not have any code generated,
or would have the statment marker removed by a different believed-good heuristic.
The other was that statement boundaries were getting attached to register
values (that with the old ABI were loads from the stack, hence real instructions).
The register values disappear at code generation.
The fixes are to (1) note that certain instructions are not good choices for
"first value" and skip them, and (2) in an expandCalls post-pass, look for
register valued instructions and under appropriate conditions move their
statement marker to a compatible use.
Also updates TestStmtLines to always log the score, for easier comparison of
minor compiler changes.
Updates #40724.
Change-Id: I485573ce900e292d7c44574adb7629cdb4695c3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/309649
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/expand_calls.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/expand_calls.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go index d947443cb2..b2b2b5d877 100644 --- a/src/cmd/compile/internal/ssa/expand_calls.go +++ b/src/cmd/compile/internal/ssa/expand_calls.go @@ -1478,6 +1478,31 @@ func expandCalls(f *Func) { } } } + + // Rewriting can attach lines to values that are unlikely to survive code generation, so move them to a use. + for _, b := range f.Blocks { + for _, v := range b.Values { + for _, a := range v.Args { + if a.Pos.IsStmt() != src.PosIsStmt { + continue + } + if a.Type.IsMemory() { + continue + } + if a.Pos.Line() != v.Pos.Line() { + continue + } + if !a.Pos.SameFile(v.Pos) { + continue + } + switch a.Op { + case OpArgIntReg, OpArgFloatReg, OpSelectN: + v.Pos = v.Pos.WithIsStmt() + a.Pos = a.Pos.WithDefaultStmt() + } + } + } + } } // rewriteArgToMemOrRegs converts OpArg v in-place into the register version of v, |