]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: reduce line number churn in generated code
authorDavid Chase <drchase@google.com>
Wed, 24 Feb 2016 02:09:39 +0000 (21:09 -0500)
committerDavid Chase <drchase@google.com>
Wed, 24 Feb 2016 16:57:36 +0000 (16:57 +0000)
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>
src/cmd/compile/internal/ssa/regalloc.go
src/cmd/compile/internal/ssa/tighten.go

index a55f81d4ac715dc6ade4b2114bf46613e60af10e..e900a3cfb82464221ff777539264bc06c5712b4e 100644 (file)
@@ -396,7 +396,7 @@ func (s *regAllocState) allocReg(v *Value, mask regMask) register {
 // allocated register is marked nospill so the assignment cannot be
 // 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.
-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]
 
        // 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 {
                        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() {
                // Rematerialize instead of loading from the spill location.
                c = v.copyInto(s.curBlock)
@@ -441,7 +441,7 @@ func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool) *Val
                        if logSpills {
                                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
                default:
                        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.
                                        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.
@@ -951,7 +951,7 @@ func (s *regAllocState) regalloc(f *Func) {
                        // Load control value into reg.
                        // TODO: regspec for block control values, instead of using
                        // 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.
                        vi := &s.values[v.ID]
                        u := vi.uses
index 6726c06e76a1e5cdcdadf136ceb0fd6085b3a646..ecb43c101d201f283982a1383d5dd707e75f473f 100644 (file)
@@ -16,7 +16,7 @@ package ssa
 // Figure out when that will be an improvement.
 func tighten(f *Func) {
        // 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.
        phi := make([]bool, f.NumValues())