mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: Fix bad join in satisfiesConstraintTypeMention
Before
```
Pipeline standard for TypeInference::CallExprBaseMatching::AccessConstraint::satisfiesConstraintTypeMention/6#69a92324@e8671rw7 was evaluated in 378 iterations totaling 313ms (delta sizes total: 168323).
462477 ~1% {7} r1 = JOIN `TypeInference::CallExprBaseMatching::AccessConstraint::hasConstraintMention/5#8730ee97#prev_delta` WITH TypeInference::CallExprBaseMatching::AccessConstraint::MkRelevantAccess#8a6252ad#reorder_3_0_1_2#prev ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.4, Lhs.3, Rhs.1, Rhs.2, Rhs.3
993561 ~2% {9} | JOIN WITH `TypeInference::M2::BaseTypes::conditionSatisfiesConstraintTypeAt/5#e92dcc7a` ON FIRST 3 OUTPUT Lhs.0, Lhs.1, Lhs.2, Rhs.3, Rhs.4, Lhs.3, Lhs.4, Lhs.5, Lhs.6
993561 ~38% {7} | JOIN WITH `TypeInference::M2::BaseTypes::conditionSatisfiesConstraintTypeAt/5#e92dcc7a` ON FIRST 5 OUTPUT Lhs.0, Lhs.4, Lhs.5, Lhs.6, Lhs.7, Lhs.8, Lhs.3
{7} | AND NOT `Type::TypeAbstraction.getATypeParameter/0#dispred#030257a0`(FIRST 2)
772102 ~427% {6} | SCAN OUTPUT In.3, In.4, In.5, In.2, In.6, In.1
56885 ~1% {4} r2 = SCAN TypeInference::CallExprBaseMatching::AccessConstraint::MkRelevantAccess#8a6252ad#prev_delta OUTPUT In.3, In.0, In.1, In.2
0 ~0% {7} r3 = JOIN r2 WITH `TypeInference::CallExprBaseMatching::AccessConstraint::hasConstraintMention/5#8730ee97#prev` ON FIRST 1 OUTPUT Rhs.1, Rhs.2, Rhs.4, Lhs.1, Lhs.2, Lhs.3, Rhs.3
0 ~0% {9} | JOIN WITH `TypeInference::M2::BaseTypes::conditionSatisfiesConstraintTypeAt/5#e92dcc7a` ON FIRST 3 OUTPUT Lhs.0, Lhs.1, Lhs.2, Rhs.3, Rhs.4, Lhs.3, Lhs.4, Lhs.5, Lhs.6
0 ~0% {7} | JOIN WITH `TypeInference::M2::BaseTypes::conditionSatisfiesConstraintTypeAt/5#e92dcc7a` ON FIRST 5 OUTPUT Lhs.0, Lhs.4, Lhs.5, Lhs.6, Lhs.7, Lhs.8, Lhs.3
{7} | AND NOT `Type::TypeAbstraction.getATypeParameter/0#dispred#030257a0`(FIRST 2)
0 ~0% {6} | SCAN OUTPUT In.2, In.3, In.4, In.5, In.6, In.1
462477 ~1% {8} r4 = JOIN `TypeInference::CallExprBaseMatching::AccessConstraint::hasConstraintMention/5#8730ee97#prev_delta` WITH TypeInference::CallExprBaseMatching::AccessConstraint::MkRelevantAccess#8a6252ad#reorder_3_0_1_2#prev ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.4, Lhs.0, Lhs.3, Rhs.1, Rhs.2, Rhs.3
993561 ~39% {9} | JOIN WITH `TypeInference::M2::BaseTypes::conditionSatisfiesConstraintTypeAt/5#e92dcc7a` ON FIRST 3 OUTPUT Lhs.0, Rhs.4, Lhs.3, Lhs.1, Lhs.4, Lhs.5, Lhs.6, Lhs.7, Rhs.3
23413 ~1% {8} | JOIN WITH `Type::TypeAbstraction.getATypeParameter/0#dispred#030257a0` ON FIRST 2 OUTPUT Lhs.3, Lhs.1, Lhs.2, Lhs.4, Lhs.5, Lhs.6, Lhs.7, Lhs.8
2817 ~7% {7} | JOIN WITH `TypeMention::TypeMention.resolveTypeAt/1#dispred#a125c821#bff#reorder_0_2_1` ON FIRST 2 OUTPUT Lhs.2, Lhs.3, Lhs.4, Lhs.5, Lhs.6, Lhs.7, Rhs.2
11550 ~0% {9} | JOIN WITH `TypeInference::CallExprBaseMatching::AccessConstraint::RelevantAccess.getTypeAt/1#dispred#3a89868c#prev` ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Rhs.2, _, Lhs.6, Rhs.1
{7} | REWRITE WITH Tmp.6 := "", Out.6 := InverseAppend(In.7,Tmp.6,In.8) KEEPING 7
2397 ~1% {11} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.5, _, _, In.4, In.6, _, _
{7} | REWRITE WITH Out.5 := (In.7 ++ In.8), Tmp.6 := (In.7 ++ In.8), Tmp.9 := "[0-9]+", Tmp.10 := "", Out.6 := regexpReplaceAll(Tmp.6,Tmp.9,Tmp.10) KEEPING 7
2397 ~1% {9} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.4, In.5, _, In.6, _
{7} | REWRITE WITH Out.6 := length(In.7), Tmp.8 := 10, TEST Out.6 <= Tmp.8 KEEPING 7
2397 ~1% {6} | SCAN OUTPUT In.1, In.2, In.3, In.0, In.5, In.4
66727 ~0% {6} r5 = JOIN `TypeInference::CallExprBaseMatching::AccessConstraint::RelevantAccess.getTypeAt/1#dispred#3a89868c#prev_delta` WITH TypeInference::CallExprBaseMatching::AccessConstraint::MkRelevantAccess#8a6252ad#reorder_3_0_1_2#prev ON FIRST 1 OUTPUT Lhs.0, Lhs.1, Lhs.2, Rhs.1, Rhs.2, Rhs.3
19305359 ~0% {9} | JOIN WITH `TypeInference::CallExprBaseMatching::AccessConstraint::hasConstraintMention/5#8730ee97#prev` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Rhs.2, Rhs.3, Rhs.4
3454881 ~1% {10} | JOIN WITH `Type::TypeAbstraction.getATypeParameter/0#dispred#030257a0` ON FIRST 1 OUTPUT Lhs.0, Lhs.6, Lhs.8, Rhs.1, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Lhs.7
753104 ~1% {9} | JOIN WITH `TypeInference::M2::BaseTypes::conditionSatisfiesConstraintTypeAt/5#e92dcc7a_01243#join_rhs` ON FIRST 4 OUTPUT Lhs.1, Lhs.3, Lhs.4, Lhs.5, Lhs.6, Lhs.7, Lhs.8, Lhs.9, Rhs.4
32040 ~18% {9} | JOIN WITH `TypeMention::TypeMention.resolveTypeAt/1#dispred#a125c821#bff#reorder_0_2_1` ON FIRST 2 OUTPUT Lhs.3, Lhs.4, Lhs.5, Lhs.6, Lhs.7, Lhs.8, _, Rhs.2, Lhs.2
{7} | REWRITE WITH Tmp.6 := "", Out.6 := InverseAppend(In.7,Tmp.6,In.8) KEEPING 7
13192 ~54% {11} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.4, _, _, In.5, In.6, _, _
{7} | REWRITE WITH Out.5 := (In.7 ++ In.8), Tmp.6 := (In.7 ++ In.8), Tmp.9 := "[0-9]+", Tmp.10 := "", Out.6 := regexpReplaceAll(Tmp.6,Tmp.9,Tmp.10) KEEPING 7
13192 ~54% {9} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.4, In.5, _, In.6, _
{7} | REWRITE WITH Out.6 := length(In.7), Tmp.8 := 10, TEST Out.6 <= Tmp.8 KEEPING 7
13192 ~55% {6} | SCAN OUTPUT In.1, In.2, In.3, In.4, In.5, In.0
0 ~0% {8} r6 = JOIN r2 WITH `TypeInference::CallExprBaseMatching::AccessConstraint::hasConstraintMention/5#8730ee97#prev` ON FIRST 1 OUTPUT Rhs.1, Rhs.2, Rhs.4, Lhs.1, Lhs.2, Lhs.3, Lhs.0, Rhs.3
0 ~0% {9} | JOIN WITH `TypeInference::M2::BaseTypes::conditionSatisfiesConstraintTypeAt/5#e92dcc7a` ON FIRST 3 OUTPUT Lhs.0, Rhs.4, Lhs.3, Lhs.4, Lhs.5, Lhs.6, Lhs.1, Lhs.7, Rhs.3
0 ~0% {8} | JOIN WITH `Type::TypeAbstraction.getATypeParameter/0#dispred#030257a0` ON FIRST 2 OUTPUT Lhs.6, Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Lhs.7, Lhs.8
0 ~0% {7} | JOIN WITH `TypeMention::TypeMention.resolveTypeAt/1#dispred#a125c821#bff#reorder_0_2_1` ON FIRST 2 OUTPUT Lhs.5, Lhs.2, Lhs.3, Lhs.4, Lhs.6, Lhs.7, Rhs.2
0 ~0% {9} | JOIN WITH `TypeInference::CallExprBaseMatching::AccessConstraint::RelevantAccess.getTypeAt/1#dispred#3a89868c#prev` ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Rhs.2, _, Lhs.6, Rhs.1
{7} | REWRITE WITH Tmp.6 := "", Out.6 := InverseAppend(In.7,Tmp.6,In.8) KEEPING 7
0 ~0% {11} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.5, _, _, In.4, In.6, _, _
{7} | REWRITE WITH Out.5 := (In.7 ++ In.8), Tmp.6 := (In.7 ++ In.8), Tmp.9 := "[0-9]+", Tmp.10 := "", Out.6 := regexpReplaceAll(Tmp.6,Tmp.9,Tmp.10) KEEPING 7
0 ~0% {9} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.4, In.5, _, In.6, _
{7} | REWRITE WITH Out.6 := length(In.7), Tmp.8 := 10, TEST Out.6 <= Tmp.8 KEEPING 7
0 ~0% {6} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.5, In.4
787691 ~403% {6} r7 = r1 UNION r3 UNION r4 UNION r5 UNION r6
212766 ~54% {6} | AND NOT `TypeInference::CallExprBaseMatching::AccessConstraint::satisfiesConstraintTypeMention/6#69a92324#prev`(FIRST 6)
return r7
```
After
```
Pipeline standard for TypeInference::CallExprBaseMatching::AccessConstraint::satisfiesConstraintTypeMention/6#69a92324@9c099xwn was evaluated in 380 iterations totaling 11ms (delta sizes total: 153004).
768937 ~1% {7} r1 = SCAN `TypeInference::CallExprBaseMatching::AccessConstraint::satisfiesConstraintTypeMention0/9#c82a4f76#prev_delta` OUTPUT In.5, In.8, In.1, In.2, In.3, In.4, In.7
{7} | AND NOT `Type::TypeAbstraction.getATypeParameter/0#dispred#030257a0`(FIRST 2)
745524 ~423% {6} | SCAN OUTPUT In.2, In.3, In.4, In.5, In.6, In.1
26916 ~0% {9} r2 = JOIN `TypeInference::CallExprBaseMatching::AccessConstraint::RelevantAccess.getTypeAt/1#dispred#3a89868c#prev_delta` WITH `TypeInference::CallExprBaseMatching::AccessConstraint::satisfiesConstraintTypeMention1/7#b265d17e#prev` ON FIRST 1 OUTPUT Lhs.2, Rhs.1, Rhs.2, Rhs.3, Rhs.4, Rhs.5, _, Rhs.6, Lhs.1
{7} | REWRITE WITH Tmp.6 := "", Out.6 := InverseAppend(In.7,Tmp.6,In.8) KEEPING 7
8530 ~1% {11} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.4, _, _, In.5, In.6, _, _
{7} | REWRITE WITH Out.5 := (In.7 ++ In.8), Tmp.6 := (In.7 ++ In.8), Tmp.9 := "[0-9]+", Tmp.10 := "", Out.6 := regexpReplaceAll(Tmp.6,Tmp.9,Tmp.10) KEEPING 7
8530 ~1% {9} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.4, In.5, _, In.6, _
{7} | REWRITE WITH Out.6 := length(In.7), Tmp.8 := 10, TEST Out.6 <= Tmp.8 KEEPING 7
8530 ~1% {6} | SCAN OUTPUT In.1, In.2, In.3, In.4, In.5, In.0
11763 ~1% {9} r3 = JOIN `TypeInference::CallExprBaseMatching::AccessConstraint::satisfiesConstraintTypeMention1/7#b265d17e#prev_delta` WITH `TypeInference::CallExprBaseMatching::AccessConstraint::RelevantAccess.getTypeAt/1#dispred#3a89868c#prev` ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.3, Lhs.4, Lhs.5, Rhs.2, _, Lhs.6, Rhs.1
{7} | REWRITE WITH Tmp.6 := "", Out.6 := InverseAppend(In.7,Tmp.6,In.8) KEEPING 7
2461 ~1% {11} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.5, _, _, In.4, In.6, _, _
{7} | REWRITE WITH Out.5 := (In.7 ++ In.8), Tmp.6 := (In.7 ++ In.8), Tmp.9 := "[0-9]+", Tmp.10 := "", Out.6 := regexpReplaceAll(Tmp.6,Tmp.9,Tmp.10) KEEPING 7
2461 ~1% {9} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.4, In.5, _, In.6, _
{7} | REWRITE WITH Out.6 := length(In.7), Tmp.8 := 10, TEST Out.6 <= Tmp.8 KEEPING 7
2461 ~1% {6} | SCAN OUTPUT In.0, In.1, In.2, In.3, In.5, In.4
756515 ~396% {6} r4 = r1 UNION r2 UNION r3
155599 ~6% {6} | AND NOT `TypeInference::CallExprBaseMatching::AccessConstraint::satisfiesConstraintTypeMention/6#69a92324#prev`(FIRST 6)
return r4
```
This commit is contained in:
@@ -1036,6 +1036,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
/**
|
||||
* Holds if `at` satisfies `constraint` through `abs`, `sub`, and `constraintMention`.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private predicate hasConstraintMention(
|
||||
RelevantAccess at, TypeAbstraction abs, TypeMention sub, Type constraint,
|
||||
TypeMention constraintMention
|
||||
@@ -1059,6 +1060,30 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
predicate satisfiesConstraintTypeMention0(
|
||||
RelevantAccess at, Access a, AccessPosition apos, TypePath prefix, Type constraint,
|
||||
TypeAbstraction abs, TypeMention sub, TypePath path, Type t
|
||||
) {
|
||||
exists(TypeMention constraintMention |
|
||||
at = MkRelevantAccess(a, apos, prefix) and
|
||||
hasConstraintMention(at, abs, sub, constraint, constraintMention) and
|
||||
conditionSatisfiesConstraintTypeAt(abs, sub, constraintMention, path, t)
|
||||
)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
predicate satisfiesConstraintTypeMention1(
|
||||
RelevantAccess at, Access a, AccessPosition apos, TypePath prefix, Type constraint,
|
||||
TypePath path, TypePath pathToTypeParamInSub
|
||||
) {
|
||||
exists(TypeAbstraction abs, TypeMention sub, TypeParameter tp |
|
||||
satisfiesConstraintTypeMention0(at, a, apos, prefix, constraint, abs, sub, path, tp) and
|
||||
tp = abs.getATypeParameter() and
|
||||
sub.resolveTypeAt(pathToTypeParamInSub) = tp
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if the type at `a`, `apos`, and `path` satisfies the constraint
|
||||
* `constraint` with the type `t` at `path`.
|
||||
@@ -1067,22 +1092,18 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
predicate satisfiesConstraintTypeMention(
|
||||
Access a, AccessPosition apos, TypePath prefix, Type constraint, TypePath path, Type t
|
||||
) {
|
||||
exists(TypeAbstraction abs |
|
||||
satisfiesConstraintTypeMention0(_, a, apos, prefix, constraint, abs, _, path, t) and
|
||||
not t = abs.getATypeParameter()
|
||||
)
|
||||
or
|
||||
exists(
|
||||
RelevantAccess at, TypeAbstraction abs, TypeMention sub, Type t0, TypePath prefix0,
|
||||
TypeMention constraintMention
|
||||
RelevantAccess at, TypePath prefix0, TypePath pathToTypeParamInSub, TypePath suffix
|
||||
|
|
||||
at = MkRelevantAccess(a, apos, prefix) and
|
||||
hasConstraintMention(at, abs, sub, constraint, constraintMention) and
|
||||
conditionSatisfiesConstraintTypeAt(abs, sub, constraintMention, prefix0, t0)
|
||||
|
|
||||
not t0 = abs.getATypeParameter() and t = t0 and path = prefix0
|
||||
or
|
||||
t0 = abs.getATypeParameter() and
|
||||
exists(TypePath path3, TypePath suffix |
|
||||
sub.resolveTypeAt(path3) = t0 and
|
||||
at.getTypeAt(path3.appendInverse(suffix)) = t and
|
||||
path = prefix0.append(suffix)
|
||||
)
|
||||
satisfiesConstraintTypeMention1(at, a, apos, prefix, constraint, prefix0,
|
||||
pathToTypeParamInSub) and
|
||||
at.getTypeAt(pathToTypeParamInSub.appendInverse(suffix)) = t and
|
||||
path = prefix0.append(suffix)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user