package gc
import (
+ "cmd/compile/internal/ssa"
"cmd/compile/internal/types"
"cmd/internal/obj"
"cmd/internal/objabi"
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()
// 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.
package ssa
import (
+ "cmd/internal/obj"
"cmd/internal/src"
"math"
)
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