-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Signed integer overflow in Constraint Elimination pass #133903
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
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
nikic
left a comment
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.
Why does fixing this bug require changes to MulOverflow? I would expect it to only require the use of MulOverflow.
What do your changes to MulOverflow fix? I would expect this to come with a change to unit tests.
|
Hi @nikic This is my first Pull Request, and I wanted to make sure it adheres to LLVM’s standards and best practices. The main reason for rewriting the entire MulOverflow function is to address the lack of handling for the INT_MIN * -1 overflow case (UB error) in the original implementation. This is a common edge case that, if not properly handled, can result in Undefined Behavior (UB) and cause potential errors. During the modification process, I also reorganized the function structure to improve readability and maintainability. As this is my first contribution, I wanted to ensure that the implementation is clean and meets the quality expected for LLVM. I have already run the tests using ninja check-llvm, and all test cases passed successfully. Please feel free to let me know if there are any adjustments or improvements I should make. Just a quick question: The return type should be bool, correct? std::enable_if_t<std::is_signed_v, ""T -> bool""> MulOverflow(T X, T Y, T &Result) { I appreciate your time and guidance, and I look forward to your feedback! @houngkoungting |
|
What makes you think that MulOverflow does not handle INT_MIN * -1 correctly? There is a test for it here: llvm-project/llvm/unittests/Support/MathExtrasTest.cpp Lines 667 to 672 in 48441cb
|
|
HI @nikic |
1 similar comment
|
HI @nikic |
Fix #133154
Refined limit check to use MaxNegative and improved code flow for better readability and maintainability. Applied clang-format for consistent formatting.