llvm-project
f4ec179b - [ARM] Fix undefined behavior in `isLegalAddImmediate` (#132219)

Commit
267 days ago
[ARM] Fix undefined behavior in `isLegalAddImmediate` (#132219) Building clang under UBsan, it reported an integer overflow in this function when the input value was -2^63, because it's UB to pass the maximum negative value of an integer type to `std::abs`. Fixed by adding a new absolute-value function in `MathExtras.h` whose return type is the unsigned version of the argument type, and using that instead. (This seems like the kind of thing C++ should have already had, but apparently it doesn't, and I couldn't find an existing one in LLVM Support either.)
Author
Parents
Loading