Skip to content

Commit

Permalink
Rename WalkDown() to WalkBlock().
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Nov 1, 2024
1 parent b279e59 commit 85a20c8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions config/staticconfig/internal/ssax/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion config/staticconfig/internal/ssax/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/staticconfig/varargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 85a20c8

Please sign in to comment.