[all-commits] [llvm/llvm-project] 831b50: [builtins] Fix signed integer overflows in fp_fixi...
Karl-Johan Karlsson via All-commits
all-commits at lists.llvm.org
Thu Aug 31 01:11:56 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 831b509d5f73a4e8f86cf01de41c6e96f33de013
https://github.com/llvm/llvm-project/commit/831b509d5f73a4e8f86cf01de41c6e96f33de013
Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
Date: 2023-08-31 (Thu, 31 Aug 2023)
Changed paths:
M compiler-rt/lib/builtins/fp_fixint_impl.inc
M compiler-rt/test/builtins/Unit/fixsfdi_test.c
Log Message:
-----------
[builtins] Fix signed integer overflows in fp_fixint_impl.inc
When compiling the builtins with the undefined behavior sanitizer and running
testcases you end up with the following warning:
UBSan: fp_fixint_impl.inc:39:42: left shift of 8388608 by 40 places cannot be represented in type 'fixint_t' (aka 'long long')
UBSan: fp_fixint_impl.inc:39:17: signed integer overflow: -1 * -9223372036854775808 cannot be represented in type 'fixint_t' (aka 'long long')
This can be avoided by doing the shift and the multiplication in a matching
unsigned variant of the type.
The added test only trigger the intended signed overflow case when the builtins
are built with -D__SOFTFP__.
This was found in an out of tree target.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D159069
More information about the All-commits
mailing list