Skip to content

Commit 8ad8d7d

Browse files
committed
cmd/compile: Use pre-regalloc value ID in lateSpillUse
The cached copy's ID is sometimes outside the bounds of the orig array. There's no reason to start at the cached copy and work backwards to the original value. We already have the original value ID at all the callsites. Fixes noopt build Change-Id: I313508a1917e838a87e8cc83b2ef3c2e4a8db304 Reviewed-on: https://go-review.googlesource.com/22355 Run-TryBot: Keith Randall <[email protected]> Reviewed-by: David Chase <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 40f1d0c commit 8ad8d7d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/cmd/compile/internal/ssa/regalloc.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,9 +1540,9 @@ func (s *regAllocState) isLoopSpillCandidate(loop *loop, v *Value) bool {
15401540
return s.values[v.ID].needReg && !s.values[v.ID].spillUsed && s.loopnest.b2l[v.Block.ID] == loop
15411541
}
15421542

1543-
// lateSpillUse notes a late (after stack allocation) use of spill c
1543+
// lateSpillUse notes a late (after stack allocation) use of the spill of value with ID vid.
15441544
// This will inhibit spill sinking.
1545-
func (s *regAllocState) lateSpillUse(c *Value) {
1545+
func (s *regAllocState) lateSpillUse(vid ID) {
15461546
// TODO investigate why this is necessary.
15471547
// It appears that an outside-the-loop use of
15481548
// an otherwise sinkable spill makes the spill
@@ -1551,10 +1551,7 @@ func (s *regAllocState) lateSpillUse(c *Value) {
15511551
// true when isLoopSpillCandidate was called, yet
15521552
// it was shuffled). Such shuffling cuts the amount
15531553
// of spill sinking by more than half (in make.bash)
1554-
v := s.orig[c.ID]
1555-
if v != nil {
1556-
s.values[v.ID].spillUsedShuffle = true
1557-
}
1554+
s.values[vid].spillUsedShuffle = true
15581555
}
15591556

15601557
// shuffle fixes up all the merge edges (those going into blocks of indegree > 1).
@@ -1729,7 +1726,7 @@ func (e *edgeState) process() {
17291726
if _, isReg := loc.(*Register); isReg {
17301727
c = e.p.NewValue1(c.Line, OpCopy, c.Type, c)
17311728
} else {
1732-
e.s.lateSpillUse(c)
1729+
e.s.lateSpillUse(vid)
17331730
c = e.p.NewValue1(c.Line, OpLoadReg, c.Type, c)
17341731
}
17351732
e.set(r, vid, c, false)
@@ -1818,7 +1815,7 @@ func (e *edgeState) processDest(loc Location, vid ID, splice **Value) bool {
18181815
}
18191816
} else {
18201817
if dstReg {
1821-
e.s.lateSpillUse(c)
1818+
e.s.lateSpillUse(vid)
18221819
x = e.p.NewValue1(c.Line, OpLoadReg, c.Type, c)
18231820
} else {
18241821
// mem->mem. Use temp register.
@@ -1836,7 +1833,7 @@ func (e *edgeState) processDest(loc Location, vid ID, splice **Value) bool {
18361833
e.erase(loc)
18371834

18381835
r := e.findRegFor(c.Type)
1839-
e.s.lateSpillUse(c)
1836+
e.s.lateSpillUse(vid)
18401837
t := e.p.NewValue1(c.Line, OpLoadReg, c.Type, c)
18411838
e.set(r, vid, t, false)
18421839
x = e.p.NewValue1(c.Line, OpStoreReg, loc.(LocalSlot).Type, t)

0 commit comments

Comments
 (0)