[all-commits] [llvm/llvm-project] 56255e: [builtins] Fix signed shift overflows in absvti2.c...
Karl-Johan Karlsson via All-commits
all-commits at lists.llvm.org
Sun Aug 27 21:47:11 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 56255e04211fd1e358cd02cafcb0fe38b97cd257
https://github.com/llvm/llvm-project/commit/56255e04211fd1e358cd02cafcb0fe38b97cd257
Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
Date: 2023-08-28 (Mon, 28 Aug 2023)
Changed paths:
M compiler-rt/lib/builtins/absvti2.c
M compiler-rt/lib/builtins/negvti2.c
Log Message:
-----------
[builtins] Fix signed shift overflows in absvti2.c and negvti2.c
When compiling the builtins with the undefined behavior sanitizer and running testcases you end up with the following warning:
UBSan: negvti2.c:22:32: left shift of 1 by 127 places cannot be represented in type 'ti_int' (aka '__int128')
UBSan: absvti2.c:23:23: left shift of 1 by 127 places cannot be represented in type 'ti_int' (aka '__int128')
This can be avoided by doing the shift in a matching unsigned variant of the type.
This is the same kind of fixes that already was done in commit
854686f0794b9d0695d5a0a85ea1e7e71ba8edfd
This was found in an out of tree target.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D158816
Commit: fb463778a7a4b85a5af287c40b957ffd7fcda53e
https://github.com/llvm/llvm-project/commit/fb463778a7a4b85a5af287c40b957ffd7fcda53e
Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
Date: 2023-08-28 (Mon, 28 Aug 2023)
Changed paths:
M compiler-rt/lib/builtins/negdi2.c
M compiler-rt/lib/builtins/negti2.c
Log Message:
-----------
[builtins] Fix undefined behavior in negdi2.c and negti2.c
When compiling the builtins with the undefined behavior sanitizer and running testcases you end up with the following warning:
UBSan: negdi2.c:20:10: negation of -9223372036854775808 cannot be represented in type 'di_int' (aka 'long long'); cast to an unsigned type to negate this value to itself
This can be avoided by doing negation in a matching unsigned variant of the type.
The same kind of pattern is found in negti2.c
This was found in an out of tree target.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D158818
Commit: 5ae3211b105126d0db3bf07777edc8ecb1c8a3b0
https://github.com/llvm/llvm-project/commit/5ae3211b105126d0db3bf07777edc8ecb1c8a3b0
Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
Date: 2023-08-28 (Mon, 28 Aug 2023)
Changed paths:
M compiler-rt/lib/builtins/ashldi3.c
M compiler-rt/lib/builtins/ashlti3.c
M compiler-rt/lib/builtins/ashrdi3.c
M compiler-rt/lib/builtins/ashrti3.c
Log Message:
-----------
[builtins] Fix signed shift overflows in ashlti3.c, ashrti3.c, ashldi3.c and ashrdi3.c
When compiling the builtins with the undefined behavior sanitizer and running testcases you end up with the following warning:
UBSan: ashlti3.c:33:35: left shift of 1 by 63 places cannot be represented in type 'di_int' (aka 'long long')
UBSan: ashrti3.c:34:34: left shift of negative value -81985529216486891
This can be avoided by doing the shift in a matching unsigned variant of the type.
The same kind of patterns are found in ashldi3.c and ashrdi3.c
This was found in an out of tree target.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D158819
Commit: 510b6b79141cc00641369c9544489b112c4e4f43
https://github.com/llvm/llvm-project/commit/510b6b79141cc00641369c9544489b112c4e4f43
Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
Date: 2023-08-28 (Mon, 28 Aug 2023)
Changed paths:
M compiler-rt/lib/builtins/divmoddi4.c
M compiler-rt/lib/builtins/divmodsi4.c
M compiler-rt/lib/builtins/divmodti4.c
Log Message:
-----------
[builtins] Fix signed integer overflows in divmodsi4.c, divmoddi4.c and divmodti4.c
When compiling the builtins with the undefined behavior sanitizer and running testcases you end up with the following warning:
UBSan: divmodsi4.c:22:17: signed integer overflow: 2147483647 - -1 cannot be represented in type 'si_int' (aka 'long')
This can be avoided by doing the subtract in a matching unsigned variant of the type.
The same kind of pattern is found in divmoddi4.c and divmodti4.c
This was found in an out of tree target.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D158821
Compare: https://github.com/llvm/llvm-project/compare/4198576157bf...510b6b79141c
More information about the All-commits
mailing list