[all-commits] [llvm/llvm-project] 303218: [compiler-rt] Avoid signed shift overflow in __mul...

Karl-Johan Karlsson via All-commits all-commits at lists.llvm.org
Wed Mar 8 23:44:53 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3032189c0b73b340c10fa317467b0e540d08df09
      https://github.com/llvm/llvm-project/commit/3032189c0b73b340c10fa317467b0e540d08df09
  Author: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
  Date:   2023-03-09 (Thu, 09 Mar 2023)

  Changed paths:
    M compiler-rt/lib/builtins/int_mulo_impl.inc
    M compiler-rt/lib/builtins/int_mulv_impl.inc
    M compiler-rt/lib/builtins/mulodi4.c
    M compiler-rt/lib/builtins/mulosi4.c
    M compiler-rt/lib/builtins/muloti4.c
    M compiler-rt/lib/builtins/mulvdi3.c
    M compiler-rt/lib/builtins/mulvsi3.c
    M compiler-rt/lib/builtins/mulvti3.c

  Log Message:
  -----------
  [compiler-rt] Avoid signed shift overflow in __muloXi4 and __mulvXi3

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

UBSan: int_mulo_impl.inc:21:36: left shift of 1 by 63 places cannot be represented in type 'di_int' (aka 'long long')

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

The same kind of pattern seems to exist in int_mulv_impl.inc

This was found in an out of tree target.

Reviewed By: MaskRay

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




More information about the All-commits mailing list