diff --git a/shared/controlflow/codeql/controlflow/Guards.qll b/shared/controlflow/codeql/controlflow/Guards.qll index 9a4f65bcd532..e12535b4b328 100644 --- a/shared/controlflow/codeql/controlflow/Guards.qll +++ b/shared/controlflow/codeql/controlflow/Guards.qll @@ -640,7 +640,11 @@ module Make< Guard guard, GuardValue v, SsaPhiDefinition phi, Expr input ) { exists(GuardValue dv, SsaExplicitWrite inp | - guardControlsPhiBranch(guard, v, phi, inp) and + // The `forall` below implies that there's only one `inp` guarded by + // `guard == v`, but checking this upfront using `unique` as opposed to + // merely stating `guardControlsPhiBranch(guard, v, phi, inp)` improves + // performance of the `forall` check. + inp = unique(SsaDefinition inp0 | guardControlsPhiBranch(guard, v, phi, inp0)) and inp.getValue() = input and dv = v.getDualValue() and forall(SsaDefinition other | phi.hasInputFromBlock(other, _) and other != inp | @@ -741,7 +745,7 @@ module Make< possibleValue(v, false, e, k) and not possibleValue(v, true, e, k) and // there's only one expression with the value `k` - 1 = strictcount(Expr e0 | possibleValue(v, _, e0, k)) and + e = unique(Expr e0 | possibleValue(v, _, e0, k)) and // and `v` has at least two possible values 2 <= strictcount(GuardValue k0 | possibleValue(v, _, _, k0)) }