-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: Disable _some_ constant folding in IR #15969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MathiasVP
merged 10 commits into
github:main
from
MathiasVP:disable-some-constant-folding
Mar 20, 2024
Merged
C++: Disable _some_ constant folding in IR #15969
MathiasVP
merged 10 commits into
github:main
from
MathiasVP:disable-some-constant-folding
Mar 20, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jketema
reviewed
Mar 19, 2024
cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll
Outdated
Show resolved
Hide resolved
jketema
reviewed
Mar 19, 2024
cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll
Outdated
Show resolved
Hide resolved
…umberOfNestedBinaryOperands').
This reverts commit f36b483.
jketema
previously approved these changes
Mar 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, if DCA is happy
…no longer constant folded by IR construction.
DCA showed three FPs caused by us no longer realizing some code was dead in some really ugly php code. I've pushed 458ee13 to fix this. Locally this fixes those FPs. I'm running another DCA now to confirm this 🤞 |
jketema
approved these changes
Mar 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In #14210 Alex tried to disable close to all constant folding in IR generation. This made us hit some really complex cases (see the corresponding internal issue), which meant we had to back out of this approach.
This PR does the minimal changes necessary to fix the original issue: being able to select the dataflow node for
1
(or2
) in an expression such as1 | 2
. We do this by disabling constant folding for binary operations only. In addition, we only disable it for "small binary operations" (currently defined as an operation with less than 50 operands).Unsurprisingly, most binary operations are "small". Here's the distribution on Wireshark (with a threshold line at 50 to make it easy to spot which ones we fold and which ones we don't):

I imagine we could make this threshold a lot bigger, but this seems to be the safe way to go about this.