Skip to content

Commit a9b5553

Browse files
committed
CPP: Speed up phi_node > frontier_phi_node > ssa_defn recursion.
1 parent 6fc5ff5 commit a9b5553

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/SSAUtils.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,17 @@ cached library class SSAHelper extends int {
124124
* Modern Compiler Implementation by Andrew Appel.
125125
*/
126126
private predicate frontier_phi_node(LocalScopeVariable v, BasicBlock b) {
127-
exists(BasicBlock x | dominanceFrontier(x, b) and ssa_defn(v, _, x, _))
127+
exists(BasicBlock x | dominanceFrontier(x, b) and ssa_defn_rec(v, x))
128128
/* We can also eliminate those nodes where the variable is not live on any incoming edge */
129129
and live_at_start_of_bb(v, b)
130130
}
131131

132+
private predicate ssa_defn_rec(LocalScopeVariable v, BasicBlock b) {
133+
phi_node(v, b)
134+
or
135+
variableUpdate(v, _, b, _)
136+
}
137+
132138
/**
133139
* Holds if `v` is defined, for the purpose of SSA, at `node`, which is at
134140
* position `index` in block `b`. This includes definitions from phi nodes.

0 commit comments

Comments
 (0)