File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed
Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,23 @@ import (
88
99// WalkFunc recursively yields all reachable blocks in the given function.
1010func WalkFunc (fn * ssa.Function ) iter.Seq [* ssa.BasicBlock ] {
11- if len (fn .Blocks ) == 0 {
12- return func (func (* ssa.BasicBlock ) bool ) {}
11+ return func (yield func (* ssa.BasicBlock ) bool ) {
12+ if len (fn .Blocks ) != 0 {
13+ for b := range WalkBlock (fn .Blocks [0 ]) {
14+ if ! yield (b ) {
15+ return
16+ }
17+ }
18+ }
1319 }
14- return WalkDown (fn .Blocks [0 ])
1520}
1621
17- // WalkDown recursively yields b and all reachable successor blocks of b.
22+ // WalkBlock recursively yields b and all reachable successor blocks of b.
1823//
1924// A block is considered reachable if there is a control flow path from b to
2025// that block that does not depend on a condition that is known to be false at
2126// compile-time.
22- func WalkDown (b * ssa.BasicBlock ) iter.Seq [* ssa.BasicBlock ] {
27+ func WalkBlock (b * ssa.BasicBlock ) iter.Seq [* ssa.BasicBlock ] {
2328 return walk (b , DirectSuccessors )
2429}
2530
@@ -59,7 +64,7 @@ func PathExists(from, to *ssa.BasicBlock) bool {
5964 panic ("blocks are not in the same function" )
6065 }
6166
62- for b := range WalkDown (from ) {
67+ for b := range WalkBlock (from ) {
6368 if b == to {
6469 return true
6570 }
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ func staticValuesFromCall(
8888 outputs := make ([]optional.Optional [ssa.Value ], n )
8989 conflicting := make ([]bool , n )
9090
91- for b := range WalkDown (fn .Blocks [0 ]) {
91+ for b := range WalkBlock (fn .Blocks [0 ]) {
9292 ret , ok := Terminator [* ssa.Return ](b ).TryGet ()
9393 if ! ok {
9494 continue
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ func resolveVariadic(
6161 return
6262 }
6363
64- for b := range ssax .WalkDown (array .Block ()) {
64+ for b := range ssax .WalkBlock (array .Block ()) {
6565 if ! ssax .PathExists (b , inst .Block ()) {
6666 continue
6767 }
You can’t perform that action at this time.
0 commit comments