Skip to content

Commit ad29648

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:12239d253d555d6cbd65588b72e9da7acf482c2f into amd-gfx:ea720c69bcc4
Local branch amd-gfx ea720c6 Merged main:e5aa7999bf1bc9a6c7a03bbc65036325a4ec5503 into amd-gfx:3a4569369d18 Remote branch main 12239d2 [lldb] Small cleanup of ProcessEventData::ShouldStop (llvm#98154)
2 parents ea720c6 + 12239d2 commit ad29648

File tree

27 files changed

+283
-84
lines changed

27 files changed

+283
-84
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,9 @@ Improvements to Clang's diagnostics
686686

687687
- Clang now shows implicit deduction guides when diagnosing overload resolution failure. #GH92393.
688688

689+
- Clang no longer emits a "no previous prototype" warning for Win32 entry points under ``-Wmissing-prototypes``.
690+
Fixes #GH94366.
691+
689692
Improvements to Clang's time-trace
690693
----------------------------------
691694

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15222,6 +15222,9 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
1522215222
if (II->isStr("main") || II->isStr("efi_main"))
1522315223
return false;
1522415224

15225+
if (FD->isMSVCRTEntryPoint())
15226+
return false;
15227+
1522515228
// Don't warn about inline functions.
1522615229
if (FD->isInlined())
1522715230
return false;

clang/test/Sema/no-warn-missing-prototype.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c -ffreestanding -verify %s
22
// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -verify %s
3+
// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -triple=x86_64-pc-win32 -verify -DMS %s
34
// expected-no-diagnostics
45
int main() {
56
return 0;
@@ -8,3 +9,21 @@ int main() {
89
int efi_main() {
910
return 0;
1011
}
12+
13+
#ifdef MS
14+
int wmain(int, wchar_t *[], wchar_t *[]) {
15+
return 0;
16+
}
17+
18+
int wWinMain(void*, void*, wchar_t*, int) {
19+
return 0;
20+
}
21+
22+
int WinMain(void*, void*, char*, int) {
23+
return 0;
24+
}
25+
26+
bool DllMain(void*, unsigned, void*) {
27+
return true;
28+
}
29+
#endif

compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
3232
${LOONGARCH64})
3333
set(ALL_ASAN_ABI_SUPPORTED_ARCH ${X86_64} ${ARM64} ${ARM64_32})
3434
set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${LOONGARCH64})
35-
#set(ALL_RTSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
36-
# ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
37-
# ${LOONGARCH64})
35+
set(ALL_RTSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
36+
${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
37+
${LOONGARCH64})
3838

3939
if(ANDROID)
4040
set(OS_NAME "Android")

compiler-rt/lib/nsan/tests/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ set(NSAN_UNITTESTS
2323

2424
add_custom_target(NsanUnitTests)
2525

26-
# set(NSAN_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_LINK_FLAGS} -ldl)
27-
# list(APPEND NSAN_UNITTEST_LINK_FLAGS --driver-mode=g++)
28-
2926
if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST NSAN_SUPPORTED_ARCH)
3027
# NSan unit tests are only run on the host machine.
3128
set(arch ${COMPILER_RT_DEFAULT_TARGET_ARCH})

compiler-rt/lib/rtsan/tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ set(RTSAN_UNITTEST_LINK_FLAGS
3636
${SANITIZER_TEST_CXX_LIBRARIES}
3737
-no-pie)
3838

39+
append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread RTSAN_UNITTEST_LINK_FLAGS)
40+
3941
if (APPLE)
4042
add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
4143
list(APPEND RTSAN_UNITTEST_LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS})

libc/config/gpu/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ set(TARGET_LIBM_ENTRYPOINTS
313313
libc.src.math.nexttowardf
314314
libc.src.math.pow
315315
libc.src.math.powf
316+
libc.src.math.powi
317+
libc.src.math.powif
316318
libc.src.math.remainder
317319
libc.src.math.remainderf
318320
libc.src.math.remquo

libc/docs/math/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ Higher Math Functions
320320
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
321321
| pow | |check| | | | | | 7.12.7.5 | F.10.4.5 |
322322
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
323+
| powi\* | | | | | | | |
324+
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
323325
| pown | | | | | | 7.12.7.6 | F.10.4.6 |
324326
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
325327
| powr | | | | | | 7.12.7.7 | F.10.4.7 |

libc/spec/llvm_libc_ext.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> {
7676
GuardedFunctionSpec<"f16sqrt", RetValSpec<Float16Type>, [ArgSpec<DoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
7777
GuardedFunctionSpec<"f16sqrtf", RetValSpec<Float16Type>, [ArgSpec<FloatType>], "LIBC_TYPES_HAS_FLOAT16">,
7878
GuardedFunctionSpec<"f16sqrtl", RetValSpec<Float16Type>, [ArgSpec<LongDoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
79+
80+
FunctionSpec<"powi", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<IntType>]>,
81+
FunctionSpec<"powif", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntType>]>,
7982
]
8083
>;
8184

libc/src/__support/FPUtil/dyadic_float.h

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,26 @@ template <size_t Bits> struct DyadicFloat {
6767
}
6868

6969
// Used for aligning exponents. Output might not be normalized.
70-
LIBC_INLINE constexpr DyadicFloat &shift_left(int shift_length) {
71-
exponent -= shift_length;
72-
mantissa <<= static_cast<size_t>(shift_length);
70+
LIBC_INLINE constexpr DyadicFloat &shift_left(unsigned shift_length) {
71+
if (shift_length < Bits) {
72+
exponent -= static_cast<int>(shift_length);
73+
mantissa <<= shift_length;
74+
} else {
75+
exponent = 0;
76+
mantissa = MantissaType(0);
77+
}
7378
return *this;
7479
}
7580

7681
// Used for aligning exponents. Output might not be normalized.
77-
LIBC_INLINE constexpr DyadicFloat &shift_right(int shift_length) {
78-
exponent += shift_length;
79-
mantissa >>= static_cast<size_t>(shift_length);
82+
LIBC_INLINE constexpr DyadicFloat &shift_right(unsigned shift_length) {
83+
if (shift_length < Bits) {
84+
exponent += static_cast<int>(shift_length);
85+
mantissa >>= shift_length;
86+
} else {
87+
exponent = 0;
88+
mantissa = MantissaType(0);
89+
}
8090
return *this;
8191
}
8292

@@ -261,9 +271,9 @@ LIBC_INLINE constexpr DyadicFloat<Bits> quick_add(DyadicFloat<Bits> a,
261271

262272
// Align exponents
263273
if (a.exponent > b.exponent)
264-
b.shift_right(a.exponent - b.exponent);
274+
b.shift_right(static_cast<unsigned>(a.exponent - b.exponent));
265275
else if (b.exponent > a.exponent)
266-
a.shift_right(b.exponent - a.exponent);
276+
a.shift_right(static_cast<unsigned>(b.exponent - a.exponent));
267277

268278
DyadicFloat<Bits> result;
269279

libc/src/math/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ add_math_entrypoint_object(nextupf128)
342342

343343
add_math_entrypoint_object(pow)
344344
add_math_entrypoint_object(powf)
345+
add_math_entrypoint_object(powi)
346+
add_math_entrypoint_object(powif)
345347

346348
add_math_entrypoint_object(remainder)
347349
add_math_entrypoint_object(remainderf)

libc/src/math/amdgpu/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,30 @@ add_entrypoint_object(
468468
VENDOR
469469
)
470470

471+
add_entrypoint_object(
472+
powi
473+
SRCS
474+
powi.cpp
475+
HDRS
476+
../powi.h
477+
COMPILE_OPTIONS
478+
${bitcode_link_flags}
479+
-O2
480+
VENDOR
481+
)
482+
483+
add_entrypoint_object(
484+
powif
485+
SRCS
486+
powif.cpp
487+
HDRS
488+
../powif.h
489+
COMPILE_OPTIONS
490+
${bitcode_link_flags}
491+
-O2
492+
VENDOR
493+
)
494+
471495
add_entrypoint_object(
472496
sinh
473497
SRCS

libc/src/math/amdgpu/declarations.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ float __ocml_nextafter_f32(float, float);
6565
double __ocml_nextafter_f64(double, double);
6666
float __ocml_pow_f32(float, float);
6767
double __ocml_pow_f64(double, double);
68+
float __ocml_pown_f32(float, int);
69+
double __ocml_pown_f64(double, int);
6870
float __ocml_sin_f32(float);
6971
double __ocml_sin_f64(double);
7072
float __ocml_sincos_f32(float, float *);

libc/src/math/amdgpu/powi.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of the powi function for GPU -----------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/math/powi.h"
10+
#include "src/__support/common.h"
11+
12+
#include "declarations.h"
13+
14+
namespace LIBC_NAMESPACE {
15+
16+
LLVM_LIBC_FUNCTION(double, powi, (double x, int y)) {
17+
return __ocml_pown_f64(x, y);
18+
}
19+
20+
} // namespace LIBC_NAMESPACE

libc/src/math/amdgpu/powif.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation of the powi function for GPU -----------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/math/powif.h"
10+
#include "src/__support/common.h"
11+
12+
#include "declarations.h"
13+
14+
namespace LIBC_NAMESPACE {
15+
16+
LLVM_LIBC_FUNCTION(float, powif, (float x, int y)) {
17+
return __ocml_pown_f32(x, y);
18+
}
19+
20+
} // namespace LIBC_NAMESPACE

libc/src/math/generic/expm1.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
#include "src/__support/integer_literals.h"
2626
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
2727

28-
#include <errno.h>
28+
#if ((LIBC_MATH & LIBC_MATH_SKIP_ACCURATE_PASS) != 0)
29+
#define LIBC_MATH_EXPM1_SKIP_ACCURATE_PASS
30+
#endif
2931

3032
// #define DEBUGDEBUG
3133

@@ -51,7 +53,7 @@ constexpr double LOG2_E = 0x1.71547652b82fep+0;
5153
constexpr uint64_t ERR_D = 0x3c08000000000000;
5254
// Errors when using double-double precision.
5355
// 0x1.0p-99
54-
constexpr uint64_t ERR_DD = 0x39c0000000000000;
56+
[[maybe_unused]] constexpr uint64_t ERR_DD = 0x39c0000000000000;
5557

5658
// -2^-12 * log(2)
5759
// > a = -2^-12 * log(2);
@@ -108,7 +110,7 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
108110
// Return (exp(dx) - 1)/dx ~ 1 + dx / 2 + dx^2 / 6 + ... + dx^6 / 5040
109111
// For |dx| < 2^-13 + 2^-30:
110112
// | output - exp(dx) | < 2^-126.
111-
Float128 poly_approx_f128(const Float128 &dx) {
113+
[[maybe_unused]] Float128 poly_approx_f128(const Float128 &dx) {
112114
constexpr Float128 COEFFS_128[]{
113115
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
114116
{Sign::POS, -128, 0x80000000'00000000'00000000'00000000_u128}, // 0.5
@@ -127,21 +129,22 @@ Float128 poly_approx_f128(const Float128 &dx) {
127129

128130
#ifdef DEBUGDEBUG
129131
std::ostream &operator<<(std::ostream &OS, const Float128 &r) {
130-
OS << (r.sign ? "-(" : "(") << r.mantissa.val[0] << " + " << r.mantissa.val[1]
131-
<< " * 2^64) * 2^" << r.exponent << "\n";
132+
OS << (r.sign == Sign::NEG ? "-(" : "(") << r.mantissa.val[0] << " + "
133+
<< r.mantissa.val[1] << " * 2^64) * 2^" << r.exponent << "\n";
132134
return OS;
133135
}
134136

135137
std::ostream &operator<<(std::ostream &OS, const DoubleDouble &r) {
136-
OS << std::hexfloat << r.hi << " + " << r.lo << std::defaultfloat << "\n";
138+
OS << std::hexfloat << "(" << r.hi << " + " << r.lo << ")"
139+
<< std::defaultfloat << "\n";
137140
return OS;
138141
}
139142
#endif
140143

141144
// Compute exp(x) - 1 using 128-bit precision.
142145
// TODO(lntue): investigate triple-double precision implementation for this
143146
// step.
144-
Float128 expm1_f128(double x, double kd, int idx1, int idx2) {
147+
[[maybe_unused]] Float128 expm1_f128(double x, double kd, int idx1, int idx2) {
145148
// Recalculate dx:
146149

147150
double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -182,9 +185,10 @@ Float128 expm1_f128(double x, double kd, int idx1, int idx2) {
182185
#ifdef DEBUGDEBUG
183186
std::cout << "=== VERY SLOW PASS ===\n"
184187
<< " kd: " << kd << "\n"
185-
<< " dx: " << dx << "exp_mid_m1: " << exp_mid_m1
186-
<< " exp_mid: " << exp_mid << " p: " << p
187-
<< " r: " << r << std::endl;
188+
<< " hi: " << hi << "\n"
189+
<< " minus_one: " << minus_one << " dx: " << dx
190+
<< "exp_mid_m1: " << exp_mid_m1 << " exp_mid: " << exp_mid
191+
<< " p: " << p << " r: " << r << std::endl;
188192
#endif
189193

190194
return r;
@@ -479,6 +483,12 @@ LLVM_LIBC_FUNCTION(double, expm1, (double x)) {
479483
// Use double-double
480484
DoubleDouble r_dd = exp_double_double(x, kd, exp_mid, hi_part);
481485

486+
#ifdef LIBC_MATH_EXPM1_SKIP_ACCURATE_PASS
487+
int64_t exp_hi = static_cast<int64_t>(hi) << FPBits::FRACTION_LEN;
488+
double r =
489+
cpp::bit_cast<double>(exp_hi + cpp::bit_cast<int64_t>(r_dd.hi + r_dd.lo));
490+
return r;
491+
#else
482492
double err_dd = cpp::bit_cast<double>(ERR_DD + err);
483493

484494
double upper_dd = r_dd.hi + (r_dd.lo + err_dd);
@@ -494,6 +504,7 @@ LLVM_LIBC_FUNCTION(double, expm1, (double x)) {
494504
Float128 r_f128 = expm1_f128(x, kd, idx1, idx2);
495505

496506
return static_cast<double>(r_f128);
507+
#endif // LIBC_MATH_EXPM1_SKIP_ACCURATE_PASS
497508
}
498509

499510
} // namespace LIBC_NAMESPACE

libc/src/math/nvptx/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,30 @@ add_entrypoint_object(
421421
VENDOR
422422
)
423423

424+
add_entrypoint_object(
425+
powi
426+
SRCS
427+
powi.cpp
428+
HDRS
429+
../powi.h
430+
COMPILE_OPTIONS
431+
${bitcode_link_flags}
432+
-O2
433+
VENDOR
434+
)
435+
436+
add_entrypoint_object(
437+
powif
438+
SRCS
439+
powif.cpp
440+
HDRS
441+
../powif.h
442+
COMPILE_OPTIONS
443+
${bitcode_link_flags}
444+
-O2
445+
VENDOR
446+
)
447+
424448
add_entrypoint_object(
425449
sinh
426450
SRCS

libc/src/math/nvptx/declarations.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ double __nv_nextafter(double, double);
6464
float __nv_nextafterf(float, float);
6565
double __nv_pow(double, double);
6666
float __nv_powf(float, float);
67+
double __nv_powi(double, int);
68+
float __nv_powif(float, int);
6769
double __nv_sin(double);
6870
float __nv_sinf(float);
6971
void __nv_sincos(double, double *, double *);

libc/src/math/nvptx/powi.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation of the powi function for GPU -----------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/math/powi.h"
10+
#include "src/__support/common.h"
11+
12+
#include "declarations.h"
13+
14+
namespace LIBC_NAMESPACE {
15+
16+
LLVM_LIBC_FUNCTION(double, powi, (double x, int y)) { return __nv_powi(x, y); }
17+
18+
} // namespace LIBC_NAMESPACE

0 commit comments

Comments
 (0)