]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: refactor and cleanup of common code/workaround
authorDavid Chase <drchase@google.com>
Fri, 18 May 2018 19:11:30 +0000 (15:11 -0400)
committerDavid Chase <drchase@google.com>
Fri, 18 May 2018 21:00:56 +0000 (21:00 +0000)
There's a glitch in how attributes from procs that do not
generate code are combined, and the workaround for this
glitch appeared in two places.

"One big pile is better than two little ones."

Updates #25426.

Change-Id: I252f9adc5b77591720a61fa22e6f9dda33d95350
Reviewed-on: https://go-review.googlesource.com/113717
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/gsubr.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/numberlines.go

index 29994afb8cf23596154b81babb3583d2532d51a7..55b16792f97d10ea46804d25dc8c81b514f5b12f 100644 (file)
@@ -31,6 +31,7 @@
 package gc
 
 import (
+       "cmd/compile/internal/ssa"
        "cmd/compile/internal/types"
        "cmd/internal/obj"
        "cmd/internal/objabi"
@@ -114,12 +115,8 @@ func (pp *Progs) Prog(as obj.As) *obj.Prog {
        p.As = as
        p.Pos = pp.pos
        if pp.pos.IsStmt() == src.PosIsStmt {
-               // Clear IsStmt for later Progs at this pos provided that as generates executable code.
-               switch as {
-               // TODO: this is an artifact of how funcpctab combines information for instructions at a single PC.
-               // Should try to fix it there.  There is a similar workaround in *SSAGenState.Prog in gc/ssa.go.
-               case obj.APCDATA, obj.AFUNCDATA:
-                       // is_stmt does not work for these; it DOES for ANOP
+               // Clear IsStmt for later Progs at this pos provided that as can be marked as a stmt
+               if ssa.LosesStmtMark(as) {
                        return p
                }
                pp.pos = pp.pos.WithNotStmt()
index 32003843e0d57583f2f8af35d15a4172765755dd..7d879395a6ba5af6e7258b545b97241000c78460 100644 (file)
@@ -4706,9 +4706,7 @@ type SSAGenState struct {
 // Prog appends a new Prog.
 func (s *SSAGenState) Prog(as obj.As) *obj.Prog {
        p := s.pp.Prog(as)
-       switch as {
-       case obj.APCDATA, obj.AFUNCDATA:
-               // is_stmt does not work for these; it DOES for ANOP
+       if ssa.LosesStmtMark(as) {
                return p
        }
        // Float a statement start to the beginning of any same-line run.
index 14eceec77fded45d6c6468ce4f0b0b2aa5300279..997b05c3a2c6c4ea7e513593db8e134e3289325c 100644 (file)
@@ -5,6 +5,7 @@
 package ssa
 
 import (
+       "cmd/internal/obj"
        "cmd/internal/src"
        "math"
 )
@@ -19,6 +20,15 @@ func isPoorStatementOp(op Op) bool {
        return false
 }
 
+// LosesStmtMark returns whether a prog with op as loses its statement mark on the way to DWARF.
+// The attributes from some opcodes are lost in translation.
+// TODO: this is an artifact of how funcpctab combines information for instructions at a single PC.
+// Should try to fix it there.
+func LosesStmtMark(as obj.As) bool {
+       // is_stmt does not work for these; it DOES for ANOP even though that generates no code.
+       return as == obj.APCDATA || as == obj.AFUNCDATA
+}
+
 // nextGoodStatementIndex returns an index at i or later that is believed
 // to be a good place to start the statement for b.  This decision is
 // based on v's Op, the possibility of a better later operation, and