This commit is contained in:
xushiwei
2025-04-26 22:23:36 +08:00
parent 10d84a6a6b
commit e2e2cb38be
4 changed files with 955 additions and 1 deletions

View File

@@ -60,11 +60,14 @@ func findLoop(states []*blockState, path []int, from, iblk int) []int {
path = append(path, iblk)
self := states[iblk]
for _, succ := range self.succs {
if states[succ].fdel {
if s := states[succ]; s.fdel || s.loop {
continue
}
if pos := find(path, succ); pos >= 0 {
if pos > 0 {
for _, i := range path[pos:] { // mark inner loop
states[i].loop = true
}
continue
}
for _, i := range path {
@@ -72,6 +75,11 @@ func findLoop(states []*blockState, path []int, from, iblk int) []int {
s.loop = true
s.fdel = true
}
for _, s := range states { // clear inner loop mark
if !s.fdel {
s.loop = false
}
}
return path
}
if ret := findLoop(states, path, from, succ); len(ret) > 0 {

View File

@@ -44,6 +44,9 @@ func TestTestdefer(t *testing.T) {
if strings.HasPrefix(name, "firstloop") {
return "Loop"
}
if strings.HasPrefix(name, "gobuild") {
return "Import"
}
return "main"
})
}