From: Keith Randall Date: Wed, 13 Aug 2025 21:01:30 +0000 (-0700) Subject: cmd/compile: during regalloc, fixedreg values are always available X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9bbea0f21a4539ea365d4804131b17d3b963c4f7;p=gostls13.git cmd/compile: during regalloc, fixedreg values are always available It is ok to clobber registers that have a copy of a fixedreg value, as that value is always available in its original location later if we need it. (See 14 lines below the change.) This CL will fix the regalloc infinite loop that CL 678620 introduced. That CL requests that the stack pointer value be materialized in a non-stack-pointer register, which is atypical. That condition triggered the infinite loop that this CL fixes. The infinite loop is the compiler trying to reuse that non-stack-pointer register for something else, but then refusing to give it up because it thought that non-stack-pointer register held the last copy of the original SP value. Change-Id: Id604d0937fb9d3753ee273bf1917753d3ef2d5d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/696035 Reviewed-by: David Chase Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index c0881c7a45..45506d5b33 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -2476,7 +2476,7 @@ func (e *edgeState) processDest(loc Location, vid ID, splice **Value, pos src.XP } // Check if we're allowed to clobber the destination location. - if len(e.cache[occupant.vid]) == 1 && !e.s.values[occupant.vid].rematerializeable { + if len(e.cache[occupant.vid]) == 1 && !e.s.values[occupant.vid].rematerializeable && !opcodeTable[e.s.orig[occupant.vid].Op].fixedReg { // We can't overwrite the last copy // of a value that needs to survive. return false