[PATCH] D156821: [CodeGen] [ubsan] Respect integer overflow handling in abs builtin
Craig Topper via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 18 17:16:34 PDT 2023
craig.topper added a comment.
In D156821#4600550 <https://reviews.llvm.org/D156821#4600550>, @MaskRay wrote:
>> Currenly both Clang and GCC support the following set of flags that control
>
> code gen of signed overflow:
>
>> [...]
>> Howerver, clang ignores these flags for __builtin_abs(int) and its higher-width
>
> versions, so passing minimum integer value always causes poison.
>
> This paragraph reads as if GCC emits a trap for `__builtin_abs` in -ftrapv mode, but it doesn't. That said, its `-fsanitize=signed-integer-overflow` does handle `__builtin_abs`.
On X86 at least, gcc does call `__negvsi2` for __builtin_abs under -ftrapv. https://godbolt.org/z/8dhn9bsv5
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156821/new/
https://reviews.llvm.org/D156821
More information about the cfe-commits
mailing list