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
C++: Deduplicate dataflow query results #14151
C++: Deduplicate dataflow query results #14151
Conversation
…to an expression.
…ion to an expression.
…d' instruction in a bunch of places.
1�7 by only using the 0'th result from the 'asExpr' predicate. However, when we want to convert between nodes and expressions we don't care about which one we get.
|
Note: This PR isn't green on CI because there are some internal tests that need to be updated. There's a backlink to the internal PR (for those with access) where the PR is green 🟢 |
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.
Generally looks good. There is a weird result for one of the tests that I don't understand. (I have used request changes because of this but if it is fine then I can just approve).
I know most of the n are on internal only predicates but it would be useful to have some doc so it is easier understand what they mean (even if it is just a non doc comment at the start of the predicate).
| | test.cpp:30:27:30:31 | ... * ... | test.cpp:30:27:30:31 | ... * ... | test.cpp:30:27:30:31 | ... * ... | Potentially overflowing value from $@ is used in the size of this allocation. | test.cpp:30:27:30:31 | ... * ... | multiplication | | ||
| | test.cpp:31:27:31:31 | ... * ... | test.cpp:31:27:31:31 | ... * ... | test.cpp:31:27:31:31 | ... * ... | Potentially overflowing value from $@ is used in the size of this allocation. | test.cpp:31:27:31:31 | ... * ... | multiplication | | ||
| | test.cpp:37:46:37:49 | size | test.cpp:45:36:45:40 | ... * ... | test.cpp:37:46:37:49 | size | Potentially overflowing value from $@ is used in the size of this allocation. | test.cpp:45:36:45:40 | ... * ... | multiplication | | ||
| | test.cpp:30:18:30:32 | new[] | test.cpp:30:18:30:32 | new[] | test.cpp:30:18:30:32 | new[] | Potentially overflowing value from $@ is used in the size of this allocation. | test.cpp:30:18:30:32 | new[] | multiplication | |
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.
These results look a bit weird and aren't on the other side of the diff?
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.
Well spotted! This is due to the IR inserting an additional conversion on n in an expression like new int[n], and the generated ConvertInstruction doesn't map back to n. I've fixed this in 7d2c12e (and added a few more comments).
This PR fixes the problem of duplicated dataflow results we've seen since we switched to IR-based dataflow.
To see why we get such duplicated results, consider the following query:
When running on:
we get two identical results. This is because both the dataflow node for the unconverted
xand the dataflow node for the convertedxmap to thexexpression.This PR fixes this issue by ensuring that only the fully converted expression has a result for
asExpr(). CallingasExpr()on a dataflow node gives the unconverted expression, and callingasConvertedExpr()gives the converted expression.Commit-by-commit strongly encouraged (You can see the effects of each commit in the updated
.expectedfiles):Instruction::getConvertedResultExpression()with this new predicate.asExpr.asExprinstead ofasConvertedExpr, and removes manual deduplication. These workarounds are no longer needed.DCA shows significant result deduplication 🎉. There are a couple of reported lost results, but the only ones that are genuinely lost are the two
cpp/very-likely-overrunning-writeonvim. This is a bit unfortunate, but I can't see a good way of bringing them back with the current semantics ofunique.I'll create a follow-up issue for this last part. I don't think it should block the PR, though.