[all-commits] [llvm/llvm-project] 854686: [compiler-rt] Fix signed shift overflows in absvdi...

Karl-Johan Karlsson via All-commits all-commits at lists.llvm.org
Thu Apr 13 22:52:35 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 854686f0794b9d0695d5a0a85ea1e7e71ba8edfd
      https://github.com/llvm/llvm-project/commit/854686f0794b9d0695d5a0a85ea1e7e71ba8edfd
  Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
  Date:   2023-04-14 (Fri, 14 Apr 2023)

  Changed paths:
    M compiler-rt/lib/builtins/absvdi2.c
    M compiler-rt/lib/builtins/absvsi2.c
    M compiler-rt/lib/builtins/negvdi2.c
    M compiler-rt/lib/builtins/negvsi2.c

  Log Message:
  -----------
  [compiler-rt] Fix signed shift overflows in absvdi2.c, absvsi2.c, negvdi2.c and negvsi2.c

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

UBSan: absvdi2.c:21:23: left shift of 1 by 63 places cannot be represented in type 'di_int' (aka 'long long')
UBSan: absvsi2.c:21:23: left shift of 1 by 31 places cannot be represented in type 'si_int' (aka 'long')
UBSan: negvdi2.c:20:32: left shift of 1 by 63 places cannot be represented in type 'di_int' (aka 'long long')
UBSan: negvsi2.c:20:32: left shift of 1 by 31 places cannot be represented in type 'si_int' (aka 'long')

This can be avoided by doing the shift in a matching unsigned variant of the
type.

This was found in an out of tree target.

Reviewed By: MaskRay

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




More information about the All-commits mailing list