Skip to content

Commit e5c7d7e

Browse files
authored
merge main into amd-staging (llvm#2176)
2 parents f4201b7 + c429fd7 commit e5c7d7e

File tree

123 files changed

+3017
-909
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+3017
-909
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,6 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
474474
return false;
475475
return this->emitDecayPtr(*FromT, *ToT, CE);
476476
}
477-
478-
case CK_LValueToRValueBitCast:
479-
return this->emitBuiltinBitCast(CE);
480-
481477
case CK_IntegralToBoolean:
482478
case CK_FixedPointToBoolean: {
483479
// HLSL uses this to cast to one-element vectors.
@@ -735,6 +731,11 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
735731
llvm_unreachable("Unhandled clang::CastKind enum");
736732
}
737733

734+
template <class Emitter>
735+
bool Compiler<Emitter>::VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *E) {
736+
return this->emitBuiltinBitCast(E);
737+
}
738+
738739
template <class Emitter>
739740
bool Compiler<Emitter>::VisitIntegerLiteral(const IntegerLiteral *LE) {
740741
if (DiscardResult)

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
126126

127127
// Expressions.
128128
bool VisitCastExpr(const CastExpr *E);
129+
bool VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *E);
129130
bool VisitIntegerLiteral(const IntegerLiteral *E);
130131
bool VisitFloatingLiteral(const FloatingLiteral *E);
131132
bool VisitImaginaryLiteral(const ImaginaryLiteral *E);

clang/lib/Headers/__clang_hip_cmath.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,13 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};
466466
#if __cplusplus >= 201103L
467467
#define __HIP_OVERLOAD2(__retty, __fn) \
468468
template <typename __T1, typename __T2> \
469-
__DEVICE__ __CONSTEXPR__ typename __hip_enable_if< \
470-
__hip::is_arithmetic<__T1>::value && __hip::is_arithmetic<__T2>::value, \
471-
typename __hip::__promote<__T1, __T2>::type>::type \
472-
__fn(__T1 __x, __T2 __y) { \
473-
typedef typename __hip::__promote<__T1, __T2>::type __result_type; \
474-
return __fn((__result_type)__x, (__result_type)__y); \
469+
__DEVICE__ __CONSTEXPR__ \
470+
typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && \
471+
__hip::is_arithmetic<__T2>::value, \
472+
__retty>::type \
473+
__fn(__T1 __x, __T2 __y) { \
474+
typedef typename __hip::__promote<__T1, __T2>::type __arg_type; \
475+
return __fn((__arg_type)__x, (__arg_type)__y); \
475476
}
476477
#else
477478
#define __HIP_OVERLOAD2(__retty, __fn) \

clang/test/AST/ByteCode/builtin-bit-cast.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,16 @@ namespace OversizedBitField {
503503
#endif
504504
}
505505

506+
namespace Discarded {
507+
enum my_byte : unsigned char {};
508+
struct pad {
509+
char a;
510+
int b;
511+
};
512+
constexpr int bad_my_byte = (__builtin_bit_cast(my_byte[8], pad{1, 2}), 0); // both-error {{must be initialized by a constant expression}} \
513+
// both-note {{indeterminate value can only initialize an object of type 'unsigned char' or 'std::byte';}}
514+
}
515+
506516
typedef bool bool9 __attribute__((ext_vector_type(9)));
507517
// both-error@+2 {{constexpr variable 'bad_bool9_to_short' must be initialized by a constant expression}}
508518
// both-note@+1 {{bit_cast involving type 'bool __attribute__((ext_vector_type(9)))' (vector of 9 'bool' values) is not allowed in a constant expression; element size 1 * element count 9 is not a multiple of the byte size 8}}

clang/test/CodeGen/AArch64/struct-coerce-using-ptr.cpp

Lines changed: 622 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/Headers/__clang_hip_cmath-return_types.hip

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -376,19 +376,19 @@ __device__ void test_isnormal()
376376
__device__ void test_isgreater()
377377
{
378378
static_assert(is_same<decltype(isgreater((float)0, (float)0)), bool>::value, "");
379-
static_assert(is_same<decltype(isgreater((float)0, (double)0)), double>::value, "");
380-
static_assert(is_same<decltype(isgreater((double)0, (float)0)), double>::value, "");
379+
static_assert(is_same<decltype(isgreater((float)0, (double)0)), bool>::value, "");
380+
static_assert(is_same<decltype(isgreater((double)0, (float)0)), bool>::value, "");
381381
static_assert(is_same<decltype(isgreater((double)0, (double)0)), bool>::value, "");
382-
static_assert(is_same<decltype(isgreater(0, (double)0)), double>::value, "");
382+
static_assert(is_same<decltype(isgreater(0, (double)0)), bool>::value, "");
383383
}
384384

385385
__device__ void test_isgreaterequal()
386386
{
387387
static_assert(is_same<decltype(isgreaterequal((float)0, (float)0)), bool>::value, "");
388-
static_assert(is_same<decltype(isgreaterequal((float)0, (double)0)), double>::value, "");
389-
static_assert(is_same<decltype(isgreaterequal((double)0, (float)0)), double>::value, "");
388+
static_assert(is_same<decltype(isgreaterequal((float)0, (double)0)), bool>::value, "");
389+
static_assert(is_same<decltype(isgreaterequal((double)0, (float)0)), bool>::value, "");
390390
static_assert(is_same<decltype(isgreaterequal((double)0, (double)0)), bool>::value, "");
391-
static_assert(is_same<decltype(isgreaterequal(0, (double)0)), double>::value, "");
391+
static_assert(is_same<decltype(isgreaterequal(0, (double)0)), bool>::value, "");
392392
}
393393

394394
__device__ void test_isinf()
@@ -400,28 +400,28 @@ __device__ void test_isinf()
400400
__device__ void test_isless()
401401
{
402402
static_assert(is_same<decltype(isless((float)0, (float)0)), bool>::value, "");
403-
static_assert(is_same<decltype(isless((float)0, (double)0)), double>::value, "");
404-
static_assert(is_same<decltype(isless((double)0, (float)0)), double>::value, "");
403+
static_assert(is_same<decltype(isless((float)0, (double)0)), bool>::value, "");
404+
static_assert(is_same<decltype(isless((double)0, (float)0)), bool>::value, "");
405405
static_assert(is_same<decltype(isless((double)0, (double)0)), bool>::value, "");
406-
static_assert(is_same<decltype(isless(0, (double)0)), double>::value, "");
406+
static_assert(is_same<decltype(isless(0, (double)0)), bool>::value, "");
407407
}
408408

409409
__device__ void test_islessequal()
410410
{
411411
static_assert(is_same<decltype(islessequal((float)0, (float)0)), bool>::value, "");
412-
static_assert(is_same<decltype(islessequal((float)0, (double)0)), double>::value, "");
413-
static_assert(is_same<decltype(islessequal((double)0, (float)0)), double>::value, "");
412+
static_assert(is_same<decltype(islessequal((float)0, (double)0)), bool>::value, "");
413+
static_assert(is_same<decltype(islessequal((double)0, (float)0)), bool>::value, "");
414414
static_assert(is_same<decltype(islessequal((double)0, (double)0)), bool>::value, "");
415-
static_assert(is_same<decltype(islessequal(0, (double)0)), double>::value, "");
415+
static_assert(is_same<decltype(islessequal(0, (double)0)), bool>::value, "");
416416
}
417417

418418
__device__ void test_islessgreater()
419419
{
420420
static_assert(is_same<decltype(islessgreater((float)0, (float)0)), bool>::value, "");
421-
static_assert(is_same<decltype(islessgreater((float)0, (double)0)), double>::value, "");
422-
static_assert(is_same<decltype(islessgreater((double)0, (float)0)), double>::value, "");
421+
static_assert(is_same<decltype(islessgreater((float)0, (double)0)), bool>::value, "");
422+
static_assert(is_same<decltype(islessgreater((double)0, (float)0)), bool>::value, "");
423423
static_assert(is_same<decltype(islessgreater((double)0, (double)0)), bool>::value, "");
424-
static_assert(is_same<decltype(islessgreater(0, (double)0)), double>::value, "");
424+
static_assert(is_same<decltype(islessgreater(0, (double)0)), bool>::value, "");
425425
}
426426

427427
__device__ void test_isnan()
@@ -433,10 +433,10 @@ __device__ void test_isnan()
433433
__device__ void test_isunordered()
434434
{
435435
static_assert(is_same<decltype(isunordered((float)0, (float)0)), bool>::value, "");
436-
static_assert(is_same<decltype(isunordered((float)0, (double)0)), double>::value, "");
437-
static_assert(is_same<decltype(isunordered((double)0, (float)0)), double>::value, "");
436+
static_assert(is_same<decltype(isunordered((float)0, (double)0)), bool>::value, "");
437+
static_assert(is_same<decltype(isunordered((double)0, (float)0)), bool>::value, "");
438438
static_assert(is_same<decltype(isunordered((double)0, (double)0)), bool>::value, "");
439-
static_assert(is_same<decltype(isunordered(0, (double)0)), double>::value, "");
439+
static_assert(is_same<decltype(isunordered(0, (double)0)), bool>::value, "");
440440
}
441441

442442
__device__ void test_acosh()

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ macro(set_output_name output name arch)
123123
else()
124124
if(ANDROID AND ${arch} STREQUAL "i386")
125125
set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}")
126-
elseif("${arch}" MATCHES "^arm")
126+
elseif(NOT "${arch}" MATCHES "^arm64" AND "${arch}" MATCHES "^arm")
127127
if(COMPILER_RT_DEFAULT_TARGET_ONLY)
128128
set(triple "${COMPILER_RT_DEFAULT_TARGET_TRIPLE}")
129129
else()

compiler-rt/cmake/builtin-config-ix.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ else()
5959
endif()
6060

6161
set(AMDGPU amdgcn)
62-
set(ARM64 aarch64)
62+
set(ARM64 aarch64 arm64ec)
6363
set(ARM32 arm armhf armv4t armv5te armv6 armv6m armv7m armv7em armv7 armv7s armv7k armv8m.base armv8m.main armv8.1m.main)
6464
set(AVR avr)
6565
set(HEXAGON hexagon)

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ set(armv7k_SOURCES ${arm_SOURCES})
668668
set(arm64_SOURCES ${aarch64_SOURCES})
669669
set(arm64e_SOURCES ${aarch64_SOURCES})
670670
set(arm64_32_SOURCES ${aarch64_SOURCES})
671+
set(arm64ec_SOURCES ${aarch64_SOURCES})
671672

672673
# macho_embedded archs
673674
set(armv6m_SOURCES ${thumb1_SOURCES})

compiler-rt/lib/builtins/aarch64/chkstk.S

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@
1515
// bl __chkstk
1616
// sub sp, sp, x15, lsl #4
1717

18-
#ifdef __aarch64__
18+
#if defined(__aarch64__) || defined(__arm64ec__)
19+
20+
#ifdef __arm64ec__
21+
#define CHKSTK_FUNC __chkstk_arm64ec
22+
#else
23+
#define CHKSTK_FUNC __chkstk
24+
#endif
1925

2026
#define PAGE_SIZE 4096
2127

2228
.p2align 2
23-
DEFINE_COMPILERRT_FUNCTION(__chkstk)
29+
DEFINE_COMPILERRT_FUNCTION(CHKSTK_FUNC)
2430
lsl x16, x15, #4
2531
mov x17, sp
2632
1:
@@ -30,6 +36,6 @@ DEFINE_COMPILERRT_FUNCTION(__chkstk)
3036
b.gt 1b
3137

3238
ret
33-
END_COMPILERRT_FUNCTION(__chkstk)
39+
END_COMPILERRT_FUNCTION(CHKSTK_FUNC)
3440

35-
#endif // __aarch64__
41+
#endif // defined(__aarch64__) || defined(__arm64ec__)

compiler-rt/lib/builtins/aarch64/lse.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// Routines may modify temporary registers tmp0, tmp1, tmp2,
2121
// return value x0 and the flags only.
2222

23-
#ifdef __aarch64__
23+
#if defined(__aarch64__) || defined(__arm64ec__)
2424

2525
#ifdef HAS_ASM_LSE
2626
.arch armv8-a+lse
@@ -267,4 +267,4 @@ NO_EXEC_STACK_DIRECTIVE
267267
// GNU property note for BTI and PAC
268268
GNU_PROPERTY_BTI_PAC
269269

270-
#endif // __aarch64__
270+
#endif // defined(__aarch64__) || defined(__arm64ec__)

compiler-rt/lib/builtins/aarch64/sme-libc-mem-routines.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ END_COMPILERRT_FUNCTION(__arm_sc_memcpy)
235235
DEFINE_COMPILERRT_FUNCTION_ALIAS(__arm_sc_memmove, __arm_sc_memcpy)
236236

237237
// This version uses FP registers. Use this only on targets with them
238-
#if defined(__aarch64__) && __ARM_FP != 0
238+
#if (defined(__aarch64__) && __ARM_FP != 0) || defined(__arm64ec__)
239239
//
240240
// __arm_sc_memset
241241
//

compiler-rt/lib/builtins/clear_cache.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ uintptr_t GetCurrentProcess(void);
5959
// specified range.
6060

6161
void __clear_cache(void *start, void *end) {
62-
#if __i386__ || __x86_64__ || defined(_M_IX86) || defined(_M_X64)
62+
#if defined(_WIN32) && \
63+
(defined(__arm__) || defined(__aarch64__) || defined(__arm64ec__))
64+
FlushInstructionCache(GetCurrentProcess(), start, end - start);
65+
#elif __i386__ || __x86_64__ || defined(_M_IX86) || defined(_M_X64)
6366
// Intel processors have a unified instruction and data cache
6467
// so there is nothing to do
6568
#elif defined(__s390__)
6669
// no-op
67-
#elif defined(_WIN32) && (defined(__arm__) || defined(__aarch64__))
68-
FlushInstructionCache(GetCurrentProcess(), start, end - start);
6970
#elif defined(__arm__) && !defined(__APPLE__)
7071
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
7172
struct arm_sync_icache_args arg;

compiler-rt/lib/builtins/cpu_model/aarch64.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
#include "aarch64.h"
1616

17-
#if !defined(__aarch64__) && !defined(__arm64__) && !defined(_M_ARM64)
17+
#if !defined(__aarch64__) && !defined(__arm64__) && !defined(_M_ARM64) && \
18+
!defined(__arm64ec__) && !defined(_M_ARM64EC)
1819
#error This file is intended only for aarch64-based targets
1920
#endif
2021

compiler-rt/lib/builtins/cpu_model/aarch64.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
#include "cpu_model.h"
1010

11-
#if !defined(__aarch64__) && !defined(__arm64__) && !defined(_M_ARM64)
11+
#if !defined(__aarch64__) && !defined(__arm64__) && !defined(_M_ARM64) && \
12+
!defined(__arm64ec__) && !defined(_M_ARM64EC)
1213
#error This file is intended only for aarch64-based targets
1314
#endif
1415

compiler-rt/lib/builtins/fp_compare_impl.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// functions. We need to ensure that the return value is sign-extended in the
1313
// same way as GCC expects (since otherwise GCC-generated __builtin_isinf
1414
// returns true for finite 128-bit floating-point numbers).
15-
#ifdef __aarch64__
15+
#if defined(__aarch64__) || defined(__arm64ec__)
1616
// AArch64 GCC overrides libgcc_cmp_return to use int instead of long.
1717
typedef int CMP_RESULT;
1818
#elif __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 4

compiler-rt/lib/builtins/fp_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static __inline fp_t __compiler_rt_scalbn(fp_t x, int y) {
359359
return __compiler_rt_scalbnX(x, y);
360360
}
361361
static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) {
362-
#if defined(__aarch64__)
362+
#if defined(__aarch64__) || defined(__arm64ec__)
363363
// Use __builtin_fmax which turns into an fmaxnm instruction on AArch64.
364364
return __builtin_fmax(x, y);
365365
#else

compiler-rt/lib/builtins/udivmodti4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline du_int udiv128by64to64default(du_int u1, du_int u0, du_int v,
8383

8484
static inline du_int udiv128by64to64(du_int u1, du_int u0, du_int v,
8585
du_int *r) {
86-
#if defined(__x86_64__)
86+
#if defined(__x86_64__) && !defined(__arm64ec__)
8787
du_int result;
8888
__asm__("divq %[v]"
8989
: "=a"(result), "=d"(*r)

compiler-rt/test/builtins/Unit/enable_execute_stack_test.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ extern void __enable_execute_stack(void* addr);
1010

1111
typedef int (*pfunc)(void);
1212

13+
#ifdef __arm64ec__
14+
// On ARM64EC, we need the x86_64 version of this function, but the compiler
15+
// would normally generate the AArch64 variant, so we hardcode it here.
16+
static char func1[] = {
17+
0xb8, 0x01, 0x00, 0x00, 0x00, // movl $0x1, %eax
18+
0xc3 // retq
19+
};
20+
static char func2[] = {
21+
0xb8, 0x02, 0x00, 0x00, 0x00, // movl $0x2, %eax
22+
0xc3 // retq
23+
};
24+
#else
1325
// Make these static to avoid ILT jumps for incremental linking on Windows.
1426
static int func1() { return 1; }
1527
static int func2() { return 2; }
28+
#endif
1629

1730
void *__attribute__((noinline))
1831
memcpy_f(void *dst, const void *src, size_t n) {

compiler-rt/test/builtins/Unit/fixunstfdi_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <stdio.h>
66

7-
#if _ARCH_PPC || __aarch64__
7+
#if _ARCH_PPC || __aarch64__ || __arm64ec__
88

99
#include "int_lib.h"
1010

@@ -35,7 +35,7 @@ char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
3535

3636
int main()
3737
{
38-
#if _ARCH_PPC || __aarch64__
38+
#if _ARCH_PPC || __aarch64__ || __arm64ec__
3939
if (test__fixunstfdi(0.0, 0))
4040
return 1;
4141

compiler-rt/test/builtins/Unit/multc3_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <stdio.h>
66

7-
#if _ARCH_PPC || __aarch64__
7+
#if _ARCH_PPC || __aarch64__ || __arm64ec__
88

99
#include "int_lib.h"
1010
#include <math.h>
@@ -348,7 +348,7 @@ long double x[][2] =
348348

349349
int main()
350350
{
351-
#if _ARCH_PPC || __aarch64__
351+
#if _ARCH_PPC || __aarch64__ || __arm64ec__
352352
const unsigned N = sizeof(x) / sizeof(x[0]);
353353
unsigned i, j;
354354
for (i = 0; i < N; ++i)

0 commit comments

Comments
 (0)