| 1 | // Copyright 2026 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package flowscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/ |
| 6 | |
| 7 | import ( |
| 8 | "container/heapscip-go gomod github.com/golang/go/src go1.25.0 `container/heap`/" |
| 9 | "logscip-go gomod github.com/golang/go/src go1.25.0 log/" |
| 10 | "slicesscip-go gomod github.com/golang/go/src go1.25.0 slices/" |
| 11 | |
| 12 | "golang.org/x/tools/internal/graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/" |
| 13 | ) |
| 14 | |
| 15 | // Forward performs a forward monotone analysis over a control flow graph. |
| 16 | // |
| 17 | // The entry map provides initial state for entry blocks (blocks with zero |
| 18 | // predecessors). For each edge, it calls transfer(fact, edge), where fact is |
| 19 | // the analysis state on entry to edge.Pred. The transfer function must return |
| 20 | // the outgoing analysis state of the edge (which may be fact, if the edge has |
| 21 | // no effect on the analysis state). |
| 22 | func Forwardscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Forward().[L Semilatticescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#[Factscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Fact#], Fact any, NodeID comparable](g graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/.Graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#[NodeID], entry map[NodeID]Fact, transfer func(from, to NodeID, fact Fact) Fact) *Analysisscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#[Fact, NodeID] { |
| 23 | cg, nodeMap := graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/.Compactscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Compact().(g) |
| 24 | |
| 25 | nNodes := cg.NumNodesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#NumNodes.() |
| 26 | fb := &fwdBuilderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#[L, Fact, NodeID]{ |
| 27 | cfgscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#cfg.: cg, |
| 28 | nodeMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#nodeMap.: nodeMap, |
| 29 | transferscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#transfer.: transfer, |
| 30 | blocksscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#blocks.: make([]blockInfoscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#[Fact], nNodes), |
| 31 | } |
| 32 | fb.queuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#queue..initscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#init().(cg) |
| 33 | |
| 34 | // Initialize each node. |
| 35 | totalEdges := 0 |
| 36 | for ni := range nNodes { |
| 37 | b := &fb.blocksscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#blocks.[ni] |
| 38 | |
| 39 | // Construct back-edges. |
| 40 | // |
| 41 | // I experimented with making Graph support iterating over in-edges, but |
| 42 | // in practice that just meant each Graph implementation had a copy of |
| 43 | // this logic. So instead we keep Graph as simple as possible and |
| 44 | // compute the auxiliary data in the algorithm. One drawback of this is |
| 45 | // that, for the [Transpose] graph, this information is redundant with |
| 46 | // the underlying graph. We could potentially special-case that. |
| 47 | outs := 0 |
| 48 | for succID := range cg.Outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#Out.(ni) { |
| 49 | succ := &fb.blocksscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#blocks.[succID] |
| 50 | succ.predsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#preds. = append(succ.predsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#preds., blockEdgescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockEdge#{ni, outs}) |
| 51 | outs++ |
| 52 | totalEdges++ |
| 53 | } |
| 54 | |
| 55 | // Initialize in & out states. |
| 56 | fact, ok := entry[nodeMap.Valuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Index#Value().(ni)] |
| 57 | if !ok { |
| 58 | fact = fb.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#l..Identscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#Ident.() |
| 59 | } |
| 60 | b.inscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#in. = fact |
| 61 | b.outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#out. = slicesscip-go gomod github.com/golang/go/src go1.25.0 slices/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 slices/Repeat().([]Fact{fb.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#l..Identscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#Ident.()}, outs) |
| 62 | |
| 63 | // Enqueue block. |
| 64 | // |
| 65 | // It's tempting to enqueue only the entry blocks, but this is wrong. |
| 66 | // The entry map may be empty if there are no interesting entry states, |
| 67 | // but the transfer function may still introduce interesting states |
| 68 | // anywhere. |
| 69 | b.dirtyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#dirty. = true |
| 70 | fb.queuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#queue..enqueuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#enqueue().(ni) |
| 71 | } |
| 72 | |
| 73 | // Propagate over blocks. |
| 74 | fb.propagatescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#propagate().() |
| 75 | |
| 76 | // Collect the final analysis results. |
| 77 | a := Analysisscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#[Fact, NodeID]{ |
| 78 | nodeMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#nodeMap.: nodeMap, |
| 79 | insscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#ins.: make([]Fact, nNodes), |
| 80 | edgesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#edges.: make([]edgeFactscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/edgeFact#[Fact], 0, totalEdges), |
| 81 | } |
| 82 | for pred := range nNodes { |
| 83 | a.insscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#ins.[pred] = fb.blocksscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#blocks.[pred].inscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#in. |
| 84 | i := 0 |
| 85 | for succ := range cg.Outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#Out.(pred) { |
| 86 | edge := edgescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/edge#{pred, succ} |
| 87 | a.edgesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#edges. = append(a.edgesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#edges., edgeFactscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/edgeFact#[Fact]{edge, fb.blocksscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#blocks.[pred].outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#out.[i]}) |
| 88 | i++ |
| 89 | } |
| 90 | } |
| 91 | slicesscip-go gomod github.com/golang/go/src go1.25.0 slices/.SortFuncscip-go gomod github.com/golang/go/src go1.25.0 slices/SortFunc().(a.edgesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Analysis#edges., func(a, b edgeFactscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/edgeFact#[Fact]) int { return a.edgescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/edgeFact#edge..comparescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/edge#compare().(b.edgescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/edgeFact#edge.) }) |
| 92 | return &a |
| 93 | } |
| 94 | |
| 95 | // fwdBuilder is the state used during [Forward] analysis. |
| 96 | type fwdBuilderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#[L Semilatticescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#[Factscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Fact#], Fact any, NodeID comparable] struct { |
| 97 | lscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#l. L // Lattice |
| 98 | |
| 99 | cfgscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#cfg. graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/.Graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#[int] // Control flow graph (compact) |
| 100 | nodeMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#nodeMap. *graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/.Indexscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Index#[NodeID] // Map from cfg to original NodeIDs |
| 101 | |
| 102 | // transfer is the edge transfer function. |
| 103 | transferscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#transfer. func(from, to NodeID, fact Fact) Fact |
| 104 | |
| 105 | blocksscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#blocks. []blockInfoscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#[Fact] |
| 106 | |
| 107 | queuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#queue. nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap# |
| 108 | } |
| 109 | |
| 110 | type blockInfoscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#[Fact any] struct { |
| 111 | dirtyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#dirty. bool // The in fact has never been propagated. |
| 112 | |
| 113 | predsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#preds. []blockEdgescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockEdge# |
| 114 | |
| 115 | inscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#in. Fact |
| 116 | outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#out. []Fact // Corresponds to i'th out edge |
| 117 | } |
| 118 | |
| 119 | type blockEdgescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockEdge# struct { |
| 120 | nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockEdge#node. int |
| 121 | iscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockEdge#i. int // Out edge index |
| 122 | } |
| 123 | |
| 124 | // nodeHeap implements a heap of NodeIDs, ordered topologically. |
| 125 | // |
| 126 | // We use this ordering so forward analysis converges more quickly. |
| 127 | type nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap# struct { |
| 128 | heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap. []int |
| 129 | inQueuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#inQueue. []int64 // Bitmap over node IDs |
| 130 | prioscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#prio. []int // NodeID -> priority |
| 131 | } |
| 132 | |
| 133 | func (h *nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#) initscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#init().(g graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/.Graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#[int]) { |
| 134 | nNodes := g.NumNodesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#NumNodes.() |
| 135 | *h = nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#{ |
| 136 | inQueuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#inQueue.: make([]int64, (nNodes+63)/64), |
| 137 | prioscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#prio.: make([]int, nNodes), |
| 138 | } |
| 139 | for p, nid := range graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/.ReversePostorderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/ReversePostorder().(g) { |
| 140 | h.prioscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#prio.[nid] = p |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | func (h *nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#) enqueuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#enqueue().(nid int) { |
| 145 | if h.inQueuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#inQueue.[nid/64]&(1<<(nid%64)) != 0 { |
| 146 | return |
| 147 | } |
| 148 | h.inQueuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#inQueue.[nid/64] |= 1 << (nid % 64) |
| 149 | heapscip-go gomod github.com/golang/go/src go1.25.0 `container/heap`/.Pushscip-go gomod github.com/golang/go/src go1.25.0 `container/heap`/Push().(h, nid) |
| 150 | } |
| 151 | |
| 152 | func (h *nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#) dequeuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#dequeue().() int { |
| 153 | nid := h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[0] |
| 154 | heapscip-go gomod github.com/golang/go/src go1.25.0 `container/heap`/.Popscip-go gomod github.com/golang/go/src go1.25.0 `container/heap`/Pop().(h) |
| 155 | h.inQueuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#inQueue.[nid/64] &^= 1 << (nid % 64) |
| 156 | return nid |
| 157 | } |
| 158 | |
| 159 | func (h nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#) Lenscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#Len().() int { return len(h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.) } |
| 160 | func (h nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#) Lessscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#Less().(i, j int) bool { return h.prioscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#prio.[h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[i]] < h.prioscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#prio.[h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[j]] } |
| 161 | func (h nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#) Swapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#Swap().(i, j int) { h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[i], h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[j] = h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[j], h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[i] } |
| 162 | func (h *nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#) Pushscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#Push().(x any) { h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap. = append(h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap., x.(int)) } |
| 163 | func (h *nodeHeapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#) Popscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#Pop().() any { |
| 164 | n := len(h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.) |
| 165 | x := h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[n-1] |
| 166 | h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap. = h.heapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#heap.[:n-1] |
| 167 | return x |
| 168 | } |
| 169 | |
| 170 | func (fb *fwdBuilderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#[L, Fact, NodeID]) mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#merge().(a, b Fact) Fact { |
| 171 | if fb.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#l..Equalsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#Equals.(a, b) { |
| 172 | return a |
| 173 | } |
| 174 | return fb.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#l..Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#Merge.(a, b) |
| 175 | } |
| 176 | |
| 177 | func (fb *fwdBuilderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#[L, Fact, NodeID]) propagatescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#propagate().() { |
| 178 | for fb.queuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#queue..Lenscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#Len().() > 0 { |
| 179 | bi := fb.queuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#queue..dequeuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#dequeue().() |
| 180 | block := &fb.blocksscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#blocks.[bi] |
| 181 | |
| 182 | // Merge predecessor facts to compute updated "in" fact. |
| 183 | var in Fact |
| 184 | first := true |
| 185 | for _, edge := range block.predsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#preds. { |
| 186 | pred := &fb.blocksscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#blocks.[edge.nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockEdge#node.] |
| 187 | var edgeFact Fact |
| 188 | if pred.dirtyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#dirty. { |
| 189 | // We haven't visited this predecessor yet, so it doesn't have |
| 190 | // meaningful out facts. |
| 191 | edgeFact = fb.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#l..Identscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#Ident.() |
| 192 | } else { |
| 193 | edgeFact = pred.outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#out.[edge.iscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockEdge#i.] |
| 194 | } |
| 195 | if first { |
| 196 | if debugscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/debug. { |
| 197 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().("propagate to node %d", bi) |
| 198 | } |
| 199 | in = edgeFact |
| 200 | first = false |
| 201 | } else { |
| 202 | in = fb.mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#merge().(in, edgeFact) |
| 203 | } |
| 204 | if debugscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/debug. { |
| 205 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().(" from node %d: %v", edge.nodescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockEdge#node., edgeFact) |
| 206 | } |
| 207 | } |
| 208 | if first { |
| 209 | // No predecessors. |
| 210 | if debugscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/debug. { |
| 211 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().("node %d gets initial state", bi) |
| 212 | } |
| 213 | in = block.inscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#in. |
| 214 | } |
| 215 | |
| 216 | if !block.dirtyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#dirty. && fb.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#l..Equalsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#Equals.(in, block.inscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#in.) { |
| 217 | // No change to block input, which means the transfer function |
| 218 | // results also won't change from the last time we ran it. |
| 219 | if debugscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/debug. { |
| 220 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().(" initial state unchanged: %v", in) |
| 221 | } |
| 222 | continue |
| 223 | } |
| 224 | if debugscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/debug. { |
| 225 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().(" new initial state: %v", in) |
| 226 | } |
| 227 | block.inscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#in. = in |
| 228 | |
| 229 | // Apply transfer function. |
| 230 | predID := fb.nodeMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#nodeMap..Valuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Index#Value().(bi) |
| 231 | i := 0 |
| 232 | for succNum := range fb.cfgscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#cfg..Outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#Out.(bi) { |
| 233 | edgeFact := fb.transferscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#transfer.(predID, fb.nodeMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#nodeMap..Valuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Index#Value().(succNum), in) |
| 234 | if block.dirtyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#dirty. || !fb.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#l..Equalsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#Equals.(block.outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#out.[i], edgeFact) { |
| 235 | // Out fact changed, so recompute the target block. |
| 236 | if debugscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/debug. { |
| 237 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().(" to node %d: %v", succNum, edgeFact) |
| 238 | } |
| 239 | block.outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#out.[i] = edgeFact |
| 240 | fb.queuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/fwdBuilder#queue..enqueuescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/nodeHeap#enqueue().(succNum) |
| 241 | } else { |
| 242 | if debugscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/debug. { |
| 243 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().(" to node %d: no change", succNum) |
| 244 | } |
| 245 | } |
| 246 | i++ |
| 247 | } |
| 248 | |
| 249 | block.dirtyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/blockInfo#dirty. = false |
| 250 | } |
| 251 | } |