type loop … // outerinner records that outer contains inner func (sdom SparseTree) outerinner(outer, inner *loop) { … } func checkContainsCall(bb *Block) bool { … } type loopnest … const blDEFAULT … const blMin … const blCALL … const blRET … const blEXIT … var bllikelies … func describePredictionAgrees(b *Block, prediction BranchPrediction) string { … } func describeBranchPrediction(f *Func, b *Block, likely, not int8, prediction BranchPrediction) { … } func likelyadjust(f *Func) { … } func (l *loop) String() string { … } func (l *loop) LongString() string { … } func (l *loop) isWithinOrEq(ll *loop) bool { … } // nearestOuterLoop returns the outer loop of loop most nearly // containing block b; the header must dominate b. loop itself // is assumed to not be that loop. For acceptable performance, // we're relying on loop nests to not be terribly deep. func (l *loop) nearestOuterLoop(sdom SparseTree, b *Block) *loop { … } func loopnestfor(f *Func) *loopnest { … } // assembleChildren initializes the children field of each // loop in the nest. Loop A is a child of loop B if A is // directly nested within B (based on the reducible-loops // detection above) func (ln *loopnest) assembleChildren() { … } // calculateDepths uses the children field of loops // to determine the nesting depth (outer=1) of each // loop. This is helpful for finding exit edges. func (ln *loopnest) calculateDepths() { … } // findExits uses loop depth information to find the // exits from a loop. func (ln *loopnest) findExits() { … } // depth returns the loop nesting level of block b. func (ln *loopnest) depth(b ID) int16 { … } // recordIfExit checks sl (the loop containing b) to see if it // is outside of loop l, and if so, records b as an exit block // from l and returns true. func recordIfExit(l, sl *loop, b *Block) bool { … } func (l *loop) setDepth(d int16) { … } // iterationEnd checks if block b ends iteration of loop l. // Ending iteration means either escaping to outer loop/code or // going back to header func (l *loop) iterationEnd(b *Block, b2l []*loop) bool { … }