Commit f4ec179
authored
[ARM] Fix undefined behavior in
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.)isLegalAddImmediate (llvm#132219)1 parent 6da8f56 commit f4ec179
File tree
2 files changed
+10
-1
lines changed- llvm
- include/llvm/Support
- lib/Target/ARM
2 files changed
+10
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
598 | 607 | | |
599 | 608 | | |
600 | 609 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19691 | 19691 | | |
19692 | 19692 | | |
19693 | 19693 | | |
19694 | | - | |
| 19694 | + | |
19695 | 19695 | | |
19696 | 19696 | | |
19697 | 19697 | | |
| |||
0 commit comments