[PATCH] D156821: [CodeGen] [ubsan] Respect integer overflow handling in abs builtin
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 19 19:09:12 PDT 2023
MaskRay added a comment.
In D156821#4600605 <https://reviews.llvm.org/D156821#4600605>, @craig.topper wrote:
> 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
Thank you. You are right, sorry for my neglection. GCC may use either `__negvsi2` or `__subvsi3` for different ports.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156821/new/
https://reviews.llvm.org/D156821
More information about the cfe-commits
mailing list