C++: Fix join order in AV rule 79 #5528
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes https://github.com/github/codeql-c-analysis-team/issues/257.
Two unfortunate join-order problems were introduced in #5431. The first one was observed by Jonas in https://github.com/github/codeql-c-analysis-team/issues/257. It arises due to this disjunction in
exprReleases
:(see https://github.com/github/codeql-c-analysis-team/issues/257 for the tuple counts from this disjunction).
The second one is of a similar nature, but apparently not as evil (as this disjunction contributes fewer tuples overall I guess):
Nevertheless it has a similar bad effect on the tuple counts:
The fix is to delay the joins involving GVN as much as possible. Apparently, this prevents these joins from materializing altogether.
Before:
Now the two evil predicates are gone and the join order is better.
After: