mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 13:16: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
30 lines
850 B
C
30 lines
850 B
C
//===-- muloti4.c - Implement __muloti4 -----------------------------------===//
|
|
//
|
|
// 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 __muloti4 for the compiler_rt library.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "int_lib.h"
|
|
|
|
#ifdef CRT_HAS_128BIT
|
|
|
|
// Returns: a * b
|
|
|
|
// Effects: sets *overflow to 1 if a * b overflows
|
|
|
|
#define fixint_t ti_int
|
|
#define fixuint_t tu_int
|
|
#include "int_mulo_impl.inc"
|
|
|
|
COMPILER_RT_ABI ti_int __muloti4(ti_int a, ti_int b, int *overflow) {
|
|
return __muloXi4(a, b, overflow);
|
|
}
|
|
|
|
#endif // CRT_HAS_128BIT
|