Skip to content

Commit aae8ec2

Browse files
committed
SSA: Use fastTC for even better performance.
1 parent af5adba commit aae8ec2

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

shared/ssa/codeql/ssa/Ssa.qll

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,38 +2095,25 @@ module Make<
20952095
)
20962096
}
20972097

2098-
/**
2099-
* Holds if `prev` is the block containing the unique predecessor of `phi`
2100-
* that reaches `phi` through the input block `input`, and that `mid` is a
2101-
* block in the dominator tree between `prev` and `input` that is
2102-
* guard-equivalent with `input` in the sense that the set of guards
2103-
* controlling `mid` is the same as the set of guards controlling `input`.
2104-
*
2105-
* This is restricted to phi inputs that are actually read.
2106-
*/
2107-
private predicate phiInputGuardEquivalenceReaches(
2108-
BasicBlock prev, BasicBlock mid, SsaPhiExt phi, BasicBlock input
2109-
) {
2110-
phiInputHasRead(phi, input) and
2111-
AdjacentSsaRefs::adjacentRefPhi(prev, _, input, phi.getBasicBlock(), phi.getSourceVariable()) and
2112-
mid = input
2113-
or
2114-
exists(BasicBlock mid0 |
2115-
phiInputGuardEquivalenceReaches(prev, mid0, phi, input) and
2116-
not guardControlledBranchTarget(mid0) and
2117-
mid0 != prev and
2118-
mid = mid0.getImmediateDominator()
2119-
)
2098+
private BasicBlock getGuardEquivalentImmediateDominator(BasicBlock bb) {
2099+
result = bb.getImmediateDominator() and
2100+
not guardControlledBranchTarget(bb)
21202101
}
21212102

21222103
/**
21232104
* Holds if the immediately preceding reference to the input to `phi` from
2124-
* the block `input` is guard-equivalent with `input`.
2105+
* the block `input` is guard-equivalent with `input` in the sense that the
2106+
* set of guards controlling the preceding reference is the same as the set
2107+
* of guards controlling `input`.
21252108
*
21262109
* This is restricted to phi inputs that are actually read.
21272110
*/
21282111
private predicate phiInputIsGuardEquivalentWithPreviousRef(SsaPhiExt phi, BasicBlock input) {
2129-
exists(BasicBlock prev | phiInputGuardEquivalenceReaches(prev, prev, phi, input))
2112+
exists(BasicBlock prev |
2113+
phiInputHasRead(phi, input) and
2114+
AdjacentSsaRefs::adjacentRefPhi(prev, _, input, phi.getBasicBlock(), phi.getSourceVariable()) and
2115+
prev = getGuardEquivalentImmediateDominator*(input)
2116+
)
21302117
}
21312118

21322119
/**

0 commit comments

Comments
 (0)