MCPcopy Create free account
hub / github.com/decomp/decomp / IsValid

Method IsValid

cfa/post_loop.go:100–116  ·  view source on GitHub ↗

IsValid reports whether the cond and exit node candidates of prim form a valid post-test loop in g. Control flow graph: cond ↘ ↓ ↖↲ ↓ exit

(g graph.Directed, dom cfg.DominatorTree)

Source from the content-addressed store, hash-verified

98// ↓
99// exit
100func (prim PostLoop) IsValid(g graph.Directed, dom cfg.DominatorTree) bool {
101 // Dominator sanity check.
102 cond, exit := prim.Cond, prim.Exit
103 if !dom.Dominates(cond, exit) {
104 return false
105 }
106
107 // Verify that cond has two successors (cond and exit).
108 condSuccs := g.From(cond)
109 if len(condSuccs) != 2 || !g.HasEdgeFromTo(cond, cond) || !g.HasEdgeFromTo(cond, exit) {
110 return false
111 }
112
113 // Verify that exit has one predecessor (cond).
114 exitPreds := g.To(exit)
115 return len(exitPreds) == 1
116}

Callers 1

FindPostLoopFunction · 0.45

Calls 1

DominatesMethod · 0.80

Tested by

no test coverage detected