1
0
mirror of https://github.com/golang/go synced 2024-11-24 20:40:23 -07:00

[dev.ssa] cmd/compile: reduce line number churn in generated code

In regalloc, make LoadReg instructions use the line number
of their *use*, not their *source*.  This reduces the
tendency of debugger stepping to "jump around" the program.

Change-Id: I59e2eeac4dca9168d8af3a93effbc5bdacac2881
Reviewed-on: https://go-review.googlesource.com/19836
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
David Chase 2016-02-23 21:09:39 -05:00
parent b96189d1a0
commit 288817b05a
2 changed files with 6 additions and 6 deletions

View File

@ -396,7 +396,7 @@ func (s *regAllocState) allocReg(v *Value, mask regMask) register {
// allocated register is marked nospill so the assignment cannot be // allocated register is marked nospill so the assignment cannot be
// undone until the caller allows it by clearing nospill. Returns a // undone until the caller allows it by clearing nospill. Returns a
// *Value which is either v or a copy of v allocated to the chosen register. // *Value which is either v or a copy of v allocated to the chosen register.
func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool) *Value { func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool, line int32) *Value {
vi := &s.values[v.ID] vi := &s.values[v.ID]
// Check if v is already in a requested register. // Check if v is already in a requested register.
@ -430,7 +430,7 @@ func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool) *Val
if s.regs[r2].v != v { if s.regs[r2].v != v {
panic("bad register state") panic("bad register state")
} }
c = s.curBlock.NewValue1(v.Line, OpCopy, v.Type, s.regs[r2].c) c = s.curBlock.NewValue1(line, OpCopy, v.Type, s.regs[r2].c)
} else if v.rematerializeable() { } else if v.rematerializeable() {
// Rematerialize instead of loading from the spill location. // Rematerialize instead of loading from the spill location.
c = v.copyInto(s.curBlock) c = v.copyInto(s.curBlock)
@ -441,7 +441,7 @@ func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool) *Val
if logSpills { if logSpills {
fmt.Println("regalloc: load spill") fmt.Println("regalloc: load spill")
} }
c = s.curBlock.NewValue1(v.Line, OpLoadReg, v.Type, vi.spill) c = s.curBlock.NewValue1(line, OpLoadReg, v.Type, vi.spill)
vi.spillUsed = true vi.spillUsed = true
default: default:
s.f.Fatalf("attempt to load unspilled value %v", v.LongString()) s.f.Fatalf("attempt to load unspilled value %v", v.LongString())
@ -894,7 +894,7 @@ func (s *regAllocState) regalloc(f *Func) {
// TODO: remove flag input from regspec.inputs. // TODO: remove flag input from regspec.inputs.
continue continue
} }
args[i.idx] = s.allocValToReg(v.Args[i.idx], i.regs, true) args[i.idx] = s.allocValToReg(v.Args[i.idx], i.regs, true, v.Line)
} }
// Now that all args are in regs, we're ready to issue the value itself. // Now that all args are in regs, we're ready to issue the value itself.
@ -951,7 +951,7 @@ func (s *regAllocState) regalloc(f *Func) {
// Load control value into reg. // Load control value into reg.
// TODO: regspec for block control values, instead of using // TODO: regspec for block control values, instead of using
// register set from the control op's output. // register set from the control op's output.
s.allocValToReg(v, opcodeTable[v.Op].reg.outputs[0], false) s.allocValToReg(v, opcodeTable[v.Op].reg.outputs[0], false, b.Line)
// Remove this use from the uses list. // Remove this use from the uses list.
vi := &s.values[v.ID] vi := &s.values[v.ID]
u := vi.uses u := vi.uses

View File

@ -16,7 +16,7 @@ package ssa
// Figure out when that will be an improvement. // Figure out when that will be an improvement.
func tighten(f *Func) { func tighten(f *Func) {
// For each value, the number of blocks in which it is used. // For each value, the number of blocks in which it is used.
uses := make([]int, f.NumValues()) uses := make([]int32, f.NumValues())
// For each value, whether that value is ever an arg to a phi value. // For each value, whether that value is ever an arg to a phi value.
phi := make([]bool, f.NumValues()) phi := make([]bool, f.NumValues())