]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: handle OpCopy loops in rewrite
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 17 Jul 2015 16:45:48 +0000 (10:45 -0600)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 20 Jul 2015 17:35:08 +0000 (17:35 +0000)
Change-Id: Icbaad6e5cbfc5430a651538fe90c0a9ee664faf4
Reviewed-on: https://go-review.googlesource.com/12360
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/rewrite.go

index 306fe1274ee31cd0bafae0a78b2924e5177ba294..60368784e838a5afff69ff1a1582268e8c468468 100644 (file)
@@ -42,7 +42,10 @@ func applyRewrite(f *Func, rb func(*Block) bool, rv func(*Value, *Config) bool)
                                        if a.Op != OpCopy {
                                                continue
                                        }
-                                       for a.Op == OpCopy {
+                                       // Rewriting can generate OpCopy loops.
+                                       // They are harmless (see removePredecessor),
+                                       // but take care not to loop forever.
+                                       for a.Op == OpCopy && a != a.Args[0] {
                                                a = a.Args[0]
                                        }
                                        v.Args[i] = a