mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 02:56:08 +00:00

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
24 lines
779 B
C
24 lines
779 B
C
//===-- mulodi4.c - Implement __mulodi4 -----------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements __mulodi4 for the compiler_rt library.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#define fixint_t di_int
|
|
#define fixuint_t du_int
|
|
#include "int_mulo_impl.inc"
|
|
|
|
// Returns: a * b
|
|
|
|
// Effects: sets *overflow to 1 if a * b overflows
|
|
|
|
COMPILER_RT_ABI di_int __mulodi4(di_int a, di_int b, int *overflow) {
|
|
return __muloXi4(a, b, overflow);
|
|
}
|