From ac115e0a6fc97ca936ca232a900343c36f5b6296 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Wed, 1 Nov 2023 15:33:28 +0100 Subject: [PATCH] Rangeanalysis: Reshuffle perf fix. This should result in the same join-order, but with less materialisation. --- .../codeql/rangeanalysis/ModulusAnalysis.qll | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/shared/rangeanalysis/codeql/rangeanalysis/ModulusAnalysis.qll b/shared/rangeanalysis/codeql/rangeanalysis/ModulusAnalysis.qll index f9fbfa98614..1217439d3c0 100644 --- a/shared/rangeanalysis/codeql/rangeanalysis/ModulusAnalysis.qll +++ b/shared/rangeanalysis/codeql/rangeanalysis/ModulusAnalysis.qll @@ -17,14 +17,10 @@ module ModulusAnalysis< LocationSig Location, Semantic Sem, DeltaSig D, BoundSig Bounds, UtilSig U> { - pragma[nomagic] - private predicate valueFlowStepSsaEqFlowCond( - Sem::SsaReadPosition pos, Sem::SsaVariable v, Sem::Expr e, int delta - ) { - exists(Sem::Guard guard, boolean testIsTrue | - guard = U::semEqFlowCond(v, e, D::fromInt(delta), true, testIsTrue) and - Sem::guardDirectlyControlsSsaRead(guard, pos, testIsTrue) - ) + bindingset[pos, v] + pragma[inline_late] + private predicate hasReadOfVarInlineLate(Sem::SsaReadPosition pos, Sem::SsaVariable v) { + pos.hasReadOfVar(v) } /** @@ -36,8 +32,11 @@ module ModulusAnalysis< ) { U::semSsaUpdateStep(v, e, D::fromInt(delta)) and pos.hasReadOfVar(v) or - pos.hasReadOfVar(v) and - valueFlowStepSsaEqFlowCond(pos, v, e, delta) + exists(Sem::Guard guard, boolean testIsTrue | + hasReadOfVarInlineLate(pos, v) and + guard = U::semEqFlowCond(v, e, D::fromInt(delta), true, testIsTrue) and + Sem::guardDirectlyControlsSsaRead(guard, pos, testIsTrue) + ) } /**