]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/ssa: erase register copies deterministically
authorMatthew Dempsky <mdempsky@google.com>
Thu, 29 Sep 2016 22:08:37 +0000 (15:08 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 29 Sep 2016 22:22:36 +0000 (22:22 +0000)
Fixes #17288.

Change-Id: I2ddd01d14667d5c6a2e19bd70489da8d9869d308
Reviewed-on: https://go-review.googlesource.com/30072
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

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

index 61d8ddab45988685757cf81378d44a0d82b2e20a..3b9f49d9dffb412a2451f4e684c292f75c7993bc 100644 (file)
@@ -1707,14 +1707,24 @@ sinking:
                }
        }
 
-       // Erase any copies we never used
-       for c, used := range s.copies {
-               if !used && c.Uses == 0 {
-                       if s.f.pass.debug > regDebug {
-                               fmt.Printf("delete copied value %s\n", c.LongString())
+       // 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 {
+                       if !used && c.Uses == 0 {
+                               if s.f.pass.debug > regDebug {
+                                       fmt.Printf("delete copied value %s\n", c.LongString())
+                               }
+                               c.Args[0].Uses--
+                               f.freeValue(c)
+                               delete(s.copies, c)
+                               progress = true
                        }
-                       c.Args[0].Uses--
-                       f.freeValue(c)
+               }
+               if !progress {
+                       break
                }
        }