]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: use sparsetree in checkFunc
authorTodd Neal <todd@tneal.org>
Thu, 4 Feb 2016 02:06:21 +0000 (21:06 -0500)
committerTodd Neal <todd@tneal.org>
Thu, 4 Feb 2016 12:03:33 +0000 (12:03 +0000)
Modify the simple domCheck to use the sparse tree code.  This
speeds up compilation of one of the generated test cases from
1m48s to 17s.

Change-Id: If577410ee77b54918147a66917a8e3721297ee0a
Reviewed-on: https://go-review.googlesource.com/19187
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/check.go

index 220877242cd8272772522419191a15a253c9351b..796d899f7cf1fcea8c597c33123a8e5daeed60ac 100644 (file)
@@ -253,6 +253,7 @@ func checkFunc(f *Func) {
                // Note: regalloc introduces non-dominating args.
                // See TODO in regalloc.go.
                idom := dominators(f)
+               sdom := newSparseTree(f, idom)
                for _, b := range f.Blocks {
                        for _, v := range b.Values {
                                for i, arg := range v.Args {
@@ -261,12 +262,12 @@ func checkFunc(f *Func) {
                                        if v.Op == OpPhi {
                                                y = b.Preds[i]
                                        }
-                                       if !domCheck(f, idom, x, y) {
+                                       if !domCheck(f, sdom, x, y) {
                                                f.Fatalf("arg %d of value %s does not dominate, arg=%s", i, v.LongString(), arg.LongString())
                                        }
                                }
                        }
-                       if b.Control != nil && !domCheck(f, idom, b.Control.Block, b) {
+                       if b.Control != nil && !domCheck(f, sdom, b.Control.Block, b) {
                                f.Fatalf("control value %s for %s doesn't dominate", b.Control, b)
                        }
                }
@@ -274,18 +275,10 @@ func checkFunc(f *Func) {
 }
 
 // domCheck reports whether x dominates y (including x==y).
-func domCheck(f *Func, idom []*Block, x, y *Block) bool {
-       if y != f.Entry && idom[y.ID] == nil {
+func domCheck(f *Func, sdom sparseTree, x, y *Block) bool {
+       if !sdom.isAncestorEq(y, f.Entry) {
                // unreachable - ignore
                return true
        }
-       for {
-               if x == y {
-                       return true
-               }
-               y = idom[y.ID]
-               if y == nil {
-                       return false
-               }
-       }
+       return sdom.isAncestorEq(x, y)
 }