Skip to content

Commit 63aac1b

Browse files
committed
Rust: Fix bad join in getCanonicalPath
Before ``` Pipeline standard for PathResolution::ItemNode.getCanonicalPath/1#dispred#f52ac1c6@5132b1w8 was evaluated in 107 iterations totaling 1217ms (delta sizes total: 870557). 568160 ~1% {2} r1 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::AssocItemNode.hasCanonicalPath/1#dispred#120fa1ad_project#PathResolution::ItemNode.__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 564597 ~1% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 68670 ~1% {2} r2 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::VariantItemNode.hasCanonicalPath/1#dispred#12012145_project#PathResolution::ItemNod__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 68670 ~0% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#5` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 49047 ~1% {2} r3 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::StructItemNode.hasCanonicalPath/1#dispred#f482e99c_project#PathResolution::ItemNode__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 49047 ~2% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#2` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 229 ~0% {2} r4 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::UnionItemNode.hasCanonicalPath/1#dispred#f67c4b73_project#PathResolution::ItemNode.__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 229 ~0% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#4` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 12207 ~0% {2} r5 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::EnumItemNode.hasCanonicalPath/1#dispred#03ce35b1_project#PathResolution::ItemNode.g__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 12207 ~0% {3} | JOIN WITH `__PathResolution::EnumItemNode.getName/0#dispred#f21ce0ed_PathResolution::ItemNode.getCanonicalPathP__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 26698 ~2% {2} r6 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::ModuleItemNode.hasCanonicalPath/1#dispred#2fee2540_project#PathResolution::ItemNode__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 26698 ~0% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#1` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 6315 ~1% {2} r7 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::TraitItemNode.hasCanonicalPath/1#dispred#824f98e3_project#PathResolution::ItemNode.__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 6315 ~1% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#3` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 112374 ~0% {3} r8 = JOIN `PathResolution::ImplItemNode.getCanonicalPathTraitPart/1#dispred#009a7fd0#prev_delta` WITH `_PathResolution::ImplItemNode.getTraitPath/0#dispred#3b7d1cb6_PathResolution::ImplItemNode.hasCanoni__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, _ 112374 ~3% {3} | REWRITE WITH Out.2 := 3 872046 ~1% {2} r9 = SCAN `PathResolution::ItemNode.getCanonicalPath/1#dispred#f52ac1c6#prev_delta` OUTPUT In.1, In.0 777662505 ~2% {3} | JOIN WITH `PathResolution::ImplItemNode.hasCanonicalPath/1#dispred#4e7c51c6_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.0 150127 ~1% {3} | JOIN WITH `PathResolution::ImplItemNode.resolveSelfTy/0#dispred#cf157d04` ON FIRST 2 OUTPUT Lhs.0, Lhs.2, _ 150127 ~0% {3} | REWRITE WITH Out.2 := 1 262501 ~1% {3} r10 = r8 UNION r9 230996 ~1% {5} r11 = JOIN r10 WITH `PathResolution::ImplItemNode.getTraitPath/0#dispred#3b7d1cb6` ON FIRST 1 OUTPUT Lhs.0, Lhs.1, Lhs.2, _, _ 230996 ~0% {5} | REWRITE WITH Out.3 := 4, Out.4 := 0 {3} r12 = r10 AND NOT `PathResolution::ImplItemNode.getTraitPath/0#dispred#3b7d1cb6_0#antijoin_rhs`(FIRST 1) 31487 ~0% {5} | SCAN OUTPUT In.0, In.1, In.2, _, _ 31487 ~1% {5} | REWRITE WITH Out.3 := 2, Out.4 := 0 262483 ~0% {5} r13 = r11 UNION r12 262483 ~0% {5} | JOIN WITH PRIMITIVE range#bbb ON Lhs.4,Lhs.3,Lhs.2 262483 ~0% {3} | SCAN OUTPUT In.3, In.0, In.1 142807 ~1% {3} | JOIN WITH `__PathResolution::ImplItemNode.getCanonicalPathTraitPart/1#dispred#009a7fd0#prev_PathResolution::Imp__#join_rhs` ON FIRST 3 OUTPUT Lhs.1, Lhs.2, Rhs.3 870570 ~1% {3} r14 = r1 UNION r2 UNION r3 UNION r4 UNION r5 UNION r6 UNION r7 UNION r13 870566 ~1% {3} | AND NOT `PathResolution::ItemNode.getCanonicalPath/1#dispred#f52ac1c6#prev`(FIRST 3) return r14 ``` After ``` Pipeline standard for PathResolution::ItemNode.getCanonicalPath/1#dispred#f52ac1c6@90aba2wd was evaluated in 100 iterations totaling 28ms (delta sizes total: 870531). 568160 ~0% {2} r1 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::AssocItemNode.hasCanonicalPath/1#dispred#120fa1ad_project#PathResolution::ItemNode.__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 564597 ~1% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 68670 ~0% {2} r2 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::VariantItemNode.hasCanonicalPath/1#dispred#12012145_project#PathResolution::ItemNod__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 68670 ~1% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#5` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 49047 ~0% {2} r3 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::StructItemNode.hasCanonicalPath/1#dispred#f482e99c_project#PathResolution::ItemNode__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 49047 ~1% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#2` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 229 ~0% {2} r4 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::UnionItemNode.hasCanonicalPath/1#dispred#f67c4b73_project#PathResolution::ItemNode.__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 229 ~0% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#4` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 12207 ~1% {2} r5 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::EnumItemNode.hasCanonicalPath/1#dispred#03ce35b1_project#PathResolution::ItemNode.g__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 12207 ~0% {3} | JOIN WITH `__PathResolution::EnumItemNode.getName/0#dispred#f21ce0ed_PathResolution::ItemNode.getCanonicalPathP__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 26698 ~0% {2} r6 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::ModuleItemNode.hasCanonicalPath/1#dispred#2fee2540_project#PathResolution::ItemNode__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 26698 ~4% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#1` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 6315 ~1% {2} r7 = JOIN `PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_delta` WITH `_PathResolution::TraitItemNode.hasCanonicalPath/1#dispred#824f98e3_project#PathResolution::ItemNode.__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1 6315 ~2% {3} | JOIN WITH `__PathResolution::ItemNode.getCanonicalPathPrefix/1#dispred#a1d9332d#prev_PathResolution::ItemNode.g__#join_rhs#3` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, Rhs.2 150127 ~0% {3} r8 = JOIN `PathResolution::ImplItemNode.getSelfCanonicalPath/1#dispred#8ed81fbe#prev_delta` WITH `PathResolution::ImplItemNode.hasCanonicalPath/1#dispred#4e7c51c6` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, _ 150127 ~0% {3} | REWRITE WITH Out.2 := 1 112374 ~1% {3} r9 = JOIN `PathResolution::ImplItemNode.getCanonicalPathTraitPart/1#dispred#009a7fd0#prev_delta` WITH `_PathResolution::ImplItemNode.getTraitPath/0#dispred#3b7d1cb6_PathResolution::ImplItemNode.hasCanoni__#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.1, _ 112374 ~0% {3} | REWRITE WITH Out.2 := 3 262501 ~0% {3} r10 = r8 UNION r9 230996 ~1% {5} r11 = JOIN r10 WITH `PathResolution::ImplItemNode.getTraitPath/0#dispred#3b7d1cb6` ON FIRST 1 OUTPUT Lhs.0, Lhs.1, Lhs.2, _, _ 230996 ~1% {5} | REWRITE WITH Out.3 := 4, Out.4 := 0 {3} r12 = r10 AND NOT `PathResolution::ImplItemNode.getTraitPath/0#dispred#3b7d1cb6_0#antijoin_rhs`(FIRST 1) 31487 ~0% {5} | SCAN OUTPUT In.0, In.1, In.2, _, _ 31487 ~0% {5} | REWRITE WITH Out.3 := 2, Out.4 := 0 262483 ~1% {5} r13 = r11 UNION r12 262483 ~1% {5} | JOIN WITH PRIMITIVE range#bbb ON Lhs.4,Lhs.3,Lhs.2 262483 ~0% {3} | SCAN OUTPUT In.3, In.0, In.1 142772 ~0% {3} | JOIN WITH `__PathResolution::ImplItemNode.getCanonicalPathTraitPart/1#dispred#009a7fd0#prev_PathResolution::Imp__#join_rhs` ON FIRST 3 OUTPUT Lhs.1, Lhs.2, Rhs.3 870535 ~1% {3} r14 = r1 UNION r2 UNION r3 UNION r4 UNION r5 UNION r6 UNION r7 UNION r13 870531 ~1% {3} | AND NOT `PathResolution::ItemNode.getCanonicalPath/1#dispred#f52ac1c6#prev`(FIRST 3) return r14 ```
1 parent 3fed7f5 commit 63aac1b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

rust/ql/lib/codeql/rust/internal/PathResolution.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
607607
result = this.resolveTraitTy().getCanonicalPath(c)
608608
}
609609

610+
pragma[nomagic]
611+
private string getSelfCanonicalPath(Crate c) { result = this.resolveSelfTy().getCanonicalPath(c) }
612+
610613
pragma[nomagic]
611614
private string getCanonicalPathTraitPart(Crate c) {
612615
exists(Crate c2 |
@@ -621,7 +624,7 @@ class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
621624
result = "<"
622625
or
623626
i = 1 and
624-
result = this.resolveSelfTy().getCanonicalPath(c)
627+
result = this.getSelfCanonicalPath(c)
625628
or
626629
if exists(this.getTraitPath())
627630
then

0 commit comments

Comments
 (0)