mirror of
https://github.com/golang/go.git
synced 2026-02-06 09:50:02 +00:00
cmd/compile: use block starting position for phi line number
Fixes #75615 Change-Id: I2c7f0ea1203e8a97749c9f780c29a66050f0159d Reviewed-on: https://go-review.googlesource.com/c/go/+/710355 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
5b29875c8e
commit
61d1ff61ad
3 changed files with 22 additions and 7 deletions
|
|
@ -137,17 +137,17 @@ func TestStmtLines(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
var m int
|
||||
var m float64
|
||||
if runtime.GOARCH == "amd64" {
|
||||
m = 1 // > 99% obtained on amd64, no backsliding
|
||||
m = 0.011 // > 98.9% obtained on amd64, no backsliding
|
||||
} else if runtime.GOARCH == "riscv64" {
|
||||
m = 3 // XXX temporary update threshold to 97% for regabi
|
||||
m = 0.03 // XXX temporary update threshold to 97% for regabi
|
||||
} else {
|
||||
m = 2 // expect 98% elsewhere.
|
||||
m = 0.02 // expect 98% elsewhere.
|
||||
}
|
||||
|
||||
if len(nonStmtLines)*100 > m*len(lines) {
|
||||
t.Errorf("Saw too many (%s, > %d%%) lines without statement marks, total=%d, nostmt=%d ('-run TestStmtLines -v' lists failing lines)\n", runtime.GOARCH, m, len(lines), len(nonStmtLines))
|
||||
if float64(len(nonStmtLines)) > m*float64(len(lines)) {
|
||||
t.Errorf("Saw too many (%s, > %.1f%%) lines without statement marks, total=%d, nostmt=%d ('-run TestStmtLines -v' lists failing lines)\n", runtime.GOARCH, m*100, len(lines), len(nonStmtLines))
|
||||
}
|
||||
t.Logf("Saw %d out of %d lines without statement marks", len(nonStmtLines), len(lines))
|
||||
if testing.Verbose() {
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ func (s *phiState) insertVarPhis(n int, var_ ir.Node, defs []*ssa.Block, typ *ty
|
|||
}
|
||||
// Add a phi to block c for variable n.
|
||||
hasPhi.add(c.ID)
|
||||
v := c.NewValue0I(currentRoot.Pos, ssa.OpPhi, typ, int64(n)) // TODO: line number right?
|
||||
v := c.NewValue0I(s.s.blockStarts[b.ID], ssa.OpPhi, typ, int64(n))
|
||||
// Note: we store the variable number in the phi's AuxInt field. Used temporarily by phi building.
|
||||
if var_.Op() == ir.ONAME {
|
||||
s.s.addNamedValue(var_.(*ir.Name), v)
|
||||
|
|
@ -513,6 +513,7 @@ loop:
|
|||
v.Op = ssa.OpPhi
|
||||
v.AddArgs(args...)
|
||||
v.Aux = nil
|
||||
v.Pos = s.s.blockStarts[b.ID]
|
||||
continue loop
|
||||
}
|
||||
w = a // save witness
|
||||
|
|
|
|||
|
|
@ -1088,6 +1088,9 @@ type state struct {
|
|||
|
||||
// First argument of append calls that could be stack allocated.
|
||||
appendTargets map[ir.Node]bool
|
||||
|
||||
// Block starting position, indexed by block id.
|
||||
blockStarts []src.XPos
|
||||
}
|
||||
|
||||
type funcLine struct {
|
||||
|
|
@ -1146,6 +1149,9 @@ func (s *state) startBlock(b *ssa.Block) {
|
|||
s.curBlock = b
|
||||
s.vars = map[ir.Node]*ssa.Value{}
|
||||
clear(s.fwdVars)
|
||||
for len(s.blockStarts) <= int(b.ID) {
|
||||
s.blockStarts = append(s.blockStarts, src.NoXPos)
|
||||
}
|
||||
}
|
||||
|
||||
// endBlock marks the end of generating code for the current block.
|
||||
|
|
@ -1172,6 +1178,9 @@ func (s *state) endBlock() *ssa.Block {
|
|||
b.Pos = src.NoXPos
|
||||
} else {
|
||||
b.Pos = s.lastPos
|
||||
if s.blockStarts[b.ID] == src.NoXPos {
|
||||
s.blockStarts[b.ID] = s.lastPos
|
||||
}
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
|
@ -1188,6 +1197,11 @@ func (s *state) pushLine(line src.XPos) {
|
|||
} else {
|
||||
s.lastPos = line
|
||||
}
|
||||
// The first position we see for a new block is its starting position
|
||||
// (the line number for its phis, if any).
|
||||
if b := s.curBlock; b != nil && s.blockStarts[b.ID] == src.NoXPos {
|
||||
s.blockStarts[b.ID] = line
|
||||
}
|
||||
|
||||
s.line = append(s.line, line)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue