findLoop: reach
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
0: always
|
||||
1: cond
|
||||
4: loop
|
||||
2: loop
|
||||
5: loop
|
||||
4: loop
|
||||
6: cond
|
||||
3: cond
|
||||
6: cond
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user