Fix incorrect copy propagation into table match keys #3399
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.
If table is applied at multiple places, local copy propagation must ensure expressions are propagated only if all control flow paths to all apply method calls assign the same expression to a variable. Currently, LocalCopyPropagation correctly inhibits copy propagation into match key
k
if two different paths to apply() call assign a different (not equivalent) expressions intok
. But if one path does not assign any value tok
, and all other assignk=a
, e.g.:the current implementation incorrectly propagates
a
into the table's match key (rewritingk
toa
).This PR fixes this problem by forbidding copy propagation of a match key in presence of a path without any remap. Before this change, the testcase
testdata/p4_16_samples/copyprop1.p4
fails becausecopyprop1-midend.p4
incorrectly matches onhdr.payload.y
instead ofx
.