diff --git a/config/staticconfig/internal/ssax/flow.go b/config/staticconfig/internal/ssax/flow.go index 6eb81a7..41fbf6a 100644 --- a/config/staticconfig/internal/ssax/flow.go +++ b/config/staticconfig/internal/ssax/flow.go @@ -8,18 +8,23 @@ import ( // WalkFunc recursively yields all reachable blocks in the given function. func WalkFunc(fn *ssa.Function) iter.Seq[*ssa.BasicBlock] { - if len(fn.Blocks) == 0 { - return func(func(*ssa.BasicBlock) bool) {} + return func(yield func(*ssa.BasicBlock) bool) { + if len(fn.Blocks) != 0 { + for b := range WalkBlock(fn.Blocks[0]) { + if !yield(b) { + return + } + } + } } - return WalkDown(fn.Blocks[0]) } -// WalkDown recursively yields b and all reachable successor blocks of b. +// WalkBlock recursively yields b and all reachable successor blocks of b. // // A block is considered reachable if there is a control flow path from b to // that block that does not depend on a condition that is known to be false at // compile-time. -func WalkDown(b *ssa.BasicBlock) iter.Seq[*ssa.BasicBlock] { +func WalkBlock(b *ssa.BasicBlock) iter.Seq[*ssa.BasicBlock] { return walk(b, DirectSuccessors) } @@ -59,7 +64,7 @@ func PathExists(from, to *ssa.BasicBlock) bool { panic("blocks are not in the same function") } - for b := range WalkDown(from) { + for b := range WalkBlock(from) { if b == to { return true } diff --git a/config/staticconfig/internal/ssax/value.go b/config/staticconfig/internal/ssax/value.go index 2923c97..6cdf4cd 100644 --- a/config/staticconfig/internal/ssax/value.go +++ b/config/staticconfig/internal/ssax/value.go @@ -88,7 +88,7 @@ func staticValuesFromCall( outputs := make([]optional.Optional[ssa.Value], n) conflicting := make([]bool, n) - for b := range WalkDown(fn.Blocks[0]) { + for b := range WalkBlock(fn.Blocks[0]) { ret, ok := Terminator[*ssa.Return](b).TryGet() if !ok { continue diff --git a/config/staticconfig/varargs.go b/config/staticconfig/varargs.go index 72568f4..0f0ea06 100644 --- a/config/staticconfig/varargs.go +++ b/config/staticconfig/varargs.go @@ -61,7 +61,7 @@ func resolveVariadic( return } - for b := range ssax.WalkDown(array.Block()) { + for b := range ssax.WalkBlock(array.Block()) { if !ssax.PathExists(b, inst.Block()) { continue }