diff --git a/cl/_testdefer/loop/out.txt b/cl/_testdefer/loop/out.txt index e5dba5bf..ad86720d 100644 --- a/cl/_testdefer/loop/out.txt +++ b/cl/_testdefer/loop/out.txt @@ -1,7 +1,7 @@ 0: always 1: cond + 4: loop 2: loop 5: loop - 4: loop - 6: cond 3: cond + 6: cond diff --git a/cl/_testdefer/print/out.txt b/cl/_testdefer/print/out.txt index e69de29b..85787635 100644 --- a/cl/_testdefer/print/out.txt +++ b/cl/_testdefer/print/out.txt @@ -0,0 +1,18 @@ + 0: always + 1: cond + 3: cond + 4: cond + 5: cond + 7: loop + 6: loop +10: loop + 8: loop + 9: cond +13: loop +11: loop +12: cond +14: cond + 2: cond +17: loop +15: loop +16: always diff --git a/cl/blocks/block.go b/cl/blocks/block.go index afd112b9..21960751 100644 --- a/cl/blocks/block.go +++ b/cl/blocks/block.go @@ -26,8 +26,6 @@ type Info struct { Next int } -// var debug = false - // ----------------------------------------------------------------------------- type blockState struct { @@ -36,6 +34,7 @@ type blockState struct { succs []int loop bool always bool + reach bool fdel bool } @@ -65,7 +64,9 @@ func findLoop(states []*blockState, path []int, from, iblk int) []int { continue } if pos := find(path, succ); pos >= 0 { - path = path[pos:] + if pos > 0 { + continue + } for _, i := range path { s := states[i] s.loop = true @@ -129,12 +130,14 @@ retry: } if s.preds--; s.preds == 0 { order = append(order, succ) + } else { + s.reach = true } } } if pos < n { for iblk, state := range states { - if state.fdel { + if state.fdel || !state.reach { continue } if loop := findLoop(states, path, iblk, iblk); len(loop) > 0 { diff --git a/cl/blocks/block_test.go b/cl/blocks/block_test.go index d02c75a8..ba941fa7 100644 --- a/cl/blocks/block_test.go +++ b/cl/blocks/block_test.go @@ -38,7 +38,7 @@ import ( func TestTestdefer(t *testing.T) { // debug = true - fromDir(t, "print", "../_testdefer") + fromDir(t, "", "../_testdefer") } func fromDir(t *testing.T, sel, relDir string) {