[llvm] Signed integer overflow in Constraint Elimination pass (PR #133903)

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 6 05:58:08 PDT 2025


houngkoungting wrote:

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>, ""T  -> bool""> MulOverflow(T X, T Y, T &Result) {
                                   
I appreciate your time and guidance, and I look forward to your feedback!   @houngkoungting 

https://github.com/llvm/llvm-project/pull/133903


More information about the llvm-commits mailing list