[GR-63033] [GR-63361] Add specialized filter primitive flow for constant y operand #10897
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.
This PR introduces a specialized flow for primitive comparisons whose
y
(right) operand is a constant. I discovered that typeflow graphs for methods containing lost of if statements liketend to be hard to comprehend when debugging, because there are lots of
use
edges from a primitive constant 0 to primitive filters. Also, propagating the constant primitive typestate viause
edges is essentially a waste of resources, because it is always the same value. I made a quick measurement and noticed that this pattern seems to be quite common. For example, onSpring Petclinic
, almost 72% of primitive comparisons that we model in the analysis have constanty
operands.To sum up, this change should make the following improvements:
use
edges that always propagate the same constant value, which could improve analysis time and memory footprint, though I do not expect significant gains here.As side tasks, this PR also:
StrengthenGraphs
to differentiate between optimizations caused by flows marked as disabled vs flows with empty typestate/list of callees