Check types when applying inverse cond pattern#323
Merged
viktormalik merged 1 commit intodiffkemp:masterfrom Mar 26, 2024
Merged
Check types when applying inverse cond pattern#323viktormalik merged 1 commit intodiffkemp:masterfrom
viktormalik merged 1 commit intodiffkemp:masterfrom
Conversation
viktormalik
reviewed
Mar 25, 2024
8e974e4 to
2b575c3
Compare
viktormalik
reviewed
Mar 26, 2024
Collaborator
viktormalik
left a comment
There was a problem hiding this comment.
Looks great, just one nit. Thanks!
In certain conditions, not checking the type could lead to an assertion failure in cmpOperationsWithOperands. FunctionComparator::cmpOperations checks the types of operands, however if the instructions are an inverse icmp instructions, Diffkemp discards this result. We need to differentiate, whether the non-zero return code from cmpOperations was caused by a difference in types or difference in values before applying the pattern.
2b575c3 to
837c8a9
Compare
viktormalik
approved these changes
Mar 26, 2024
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
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 certain conditions, not checking the type could lead to an assertion failure in cmpOperationsWithOperands. FunctionComparator::cmpOperations checks the types of operands, however if the instructions are an inverse icmp instructions, Diffkemp discards this result. We need to differentiate, whether the non-zero return code from cmpOperations was caused by a difference in types or difference in values before applying the pattern.
The attached test resulted in an assertion failure with current diffkemp version on this line:
diffkemp/diffkemp/simpll/DifferentialFunctionComparator.cpp
Lines 1849 to 1850 in 789ac18
I thought of two possible solutions to this problem:
DifferentialFunctionComparator::cmpValuesThe second option sounds a bit cleaner but I feel like it could have some side-effects that I may not be aware of (since the method is called quite often from various contexts) and it may be intentional that the comparison is left out. Therefore, I decided to use the "safer" alternative.