[all-commits] [llvm/llvm-project] ff1458: [builtins] Avoid undefined behavior when calculati...

Karl-Johan Karlsson via All-commits all-commits at lists.llvm.org
Tue Aug 22 23:58:59 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ff14585eb02f96b78a2544f8bcddd2685202cc56
      https://github.com/llvm/llvm-project/commit/ff14585eb02f96b78a2544f8bcddd2685202cc56
  Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
  Date:   2023-08-23 (Wed, 23 Aug 2023)

  Changed paths:
    M compiler-rt/lib/builtins/floatsidf.c
    M compiler-rt/lib/builtins/floatsisf.c
    M compiler-rt/lib/builtins/floatsitf.c

  Log Message:
  -----------
  [builtins] Avoid undefined behavior when calculating absolute value in floatsidf.c and floatsisf.c

When compiling compiler-rt with -fsanitize=undefined and running testcases you
end up with the following warning:

UBSan: floatsidf.c:32:9: negation of -2147483648 cannot be represented in type 'si_int' (aka 'long'); cast to an unsigned type to negate this value to itself

The same kind of pattern exists in floatsisf.c

This was found in an out of tree target.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D146123




More information about the All-commits mailing list