Commit 6dc356a7 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile/internal/ssa: erase register copies deterministically

Fixes #17288.

Change-Id: I2ddd01d14667d5c6a2e19bd70489da8d9869d308
Reviewed-on: https://go-review.googlesource.com/30072
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent c1e06dcb
...@@ -1707,7 +1707,11 @@ sinking: ...@@ -1707,7 +1707,11 @@ sinking:
} }
} }
// Erase any copies we never used // Erase any copies we never used.
// Also, an unused copy might be the only use of another copy,
// so continue erasing until we reach a fixed point.
for {
progress := false
for c, used := range s.copies { for c, used := range s.copies {
if !used && c.Uses == 0 { if !used && c.Uses == 0 {
if s.f.pass.debug > regDebug { if s.f.pass.debug > regDebug {
...@@ -1715,6 +1719,12 @@ sinking: ...@@ -1715,6 +1719,12 @@ sinking:
} }
c.Args[0].Uses-- c.Args[0].Uses--
f.freeValue(c) f.freeValue(c)
delete(s.copies, c)
progress = true
}
}
if !progress {
break
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment