Skip to content

Commit 0de3479

Browse files
authored
merge main into amd-staging (llvm#2457)
2 parents 8bbf7e3 + 73ad4ef commit 0de3479

Some content is hidden

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

47 files changed

+3943
-221
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ Non-comprehensive list of changes in this release
310310
different than before.
311311
- Fixed a crash when a VLA with an invalid size expression was used within a
312312
``sizeof`` or ``typeof`` expression. (#GH138444)
313+
- Deprecation warning is emitted for the deprecated ``__reference_binds_to_temporary`` intrinsic.
314+
``__reference_constructs_from_temporary`` should be used instead. (#GH44056)
313315

314316
New Compiler Flags
315317
------------------

clang/lib/Sema/SemaTypeTraits.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,9 @@ void DiagnoseBuiltinDeprecation(Sema &S, TypeTrait Kind, SourceLocation KWLoc) {
14581458
case UTT_IsTriviallyRelocatable:
14591459
Replacement = clang::UTT_IsCppTriviallyRelocatable;
14601460
break;
1461+
case BTT_ReferenceBindsToTemporary:
1462+
Replacement = clang::BTT_ReferenceConstructsFromTemporary;
1463+
break;
14611464
default:
14621465
return;
14631466
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang --target=riscv32-unknown-linux-gnu -march=rv32i -E -dM %s \
2+
// RUN: -o - | FileCheck %s
3+
// RUN: %clang --target=riscv64-unknown-linux-gnu -march=rv64i -E -dM %s \
4+
// RUN: -o - | FileCheck %s
5+
6+
// CHECK-NOT: __riscv_xandesperf {{.*$}}
7+
// CHECK-NOT: __riscv_xandesvpackfph {{.*$}}
8+
// CHECK-NOT: __riscv_xandesvdot {{.*$}}
9+
10+
// RUN: %clang --target=riscv32 \
11+
// RUN: -march=rv32i_xandesperf -E -dM %s \
12+
// RUN: -o - | FileCheck --check-prefix=CHECK-XANDESPERF %s
13+
// RUN: %clang --target=riscv64 \
14+
// RUN: -march=rv64i_xandesperf -E -dM %s \
15+
// RUN: -o - | FileCheck --check-prefix=CHECK-XANDESPERF %s
16+
// CHECK-XANDESPERF: __riscv_xandesperf 5000000{{$}}
17+
18+
// RUN: %clang --target=riscv32 \
19+
// RUN: -march=rv32i_xandesvpackfph -E -dM %s \
20+
// RUN: -o - | FileCheck --check-prefix=CHECK-XANDESVPACKFPH %s
21+
// RUN: %clang --target=riscv64 \
22+
// RUN: -march=rv64i_xandesvpackfph -E -dM %s \
23+
// RUN: -o - | FileCheck --check-prefix=CHECK-XANDESVPACKFPH %s
24+
// CHECK-XANDESVPACKFPH: __riscv_xandesvpackfph 5000000{{$}}
25+
26+
// RUN: %clang --target=riscv32 \
27+
// RUN: -march=rv32i_xandesvdot -E -dM %s \
28+
// RUN: -o - | FileCheck --check-prefix=CHECK-XANDESVDOT %s
29+
// RUN: %clang --target=riscv64 \
30+
// RUN: -march=rv64i_xandesvdot -E -dM %s \
31+
// RUN: -o - | FileCheck --check-prefix=CHECK-XANDESVDOT %s
32+
// CHECK-XANDESVDOT: __riscv_xandesvdot 5000000{{$}}

clang/test/SemaCXX/deprecated-builtins.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void f() {
1515
a = __has_trivial_constructor(A); // expected-warning-re {{__has_trivial_constructor {{.*}} use __is_trivially_constructible}}
1616
a = __has_trivial_move_constructor(A); // expected-warning-re {{__has_trivial_move_constructor {{.*}} use __is_trivially_constructible}}
1717
a = __has_trivial_destructor(A); // expected-warning-re {{__has_trivial_destructor {{.*}} use __is_trivially_destructible}}
18+
a = __reference_binds_to_temporary(const A&, A); // expected-warning-re {{__reference_binds_to_temporary {{.*}} use __reference_constructs_from_temporary}}
1819

1920
}
2021

compiler-rt/lib/builtins/riscv/restore.S

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
// them falling through into each other and don't want the linker to
1515
// accidentally split them up, garbage collect, or reorder them.
1616
//
17-
// The entry points are grouped up into 2s for rv64 and 4s for rv32 since this
18-
// is the minimum grouping which will maintain the required 16-byte stack
19-
// alignment.
17+
// For the conventional ABIs, entry points are grouped up into 2s for rv64 and
18+
// 4s for rv32 since this is the minimum grouping which will maintain the
19+
// required 16-byte stack alignment.
20+
//
21+
// For the ilp32e/lp64e abis, entry points are grouped into 1s, since this is
22+
// the minimum grouping which will maintain the required 4-byte stack alignment.
2023

2124
.text
2225

@@ -92,17 +95,23 @@ __riscv_restore_0:
9295

9396
.globl __riscv_restore_2
9497
.type __riscv_restore_2,@function
98+
__riscv_restore_2:
99+
lw s1, 0(sp)
100+
addi sp, sp, 4
101+
// fallthrough into __riscv_restore_1/0
102+
95103
.globl __riscv_restore_1
96104
.type __riscv_restore_1,@function
105+
__riscv_restore_1:
106+
lw s0, 0(sp)
107+
addi sp, sp, 4
108+
// fallthrough into __riscv_restore_0
109+
97110
.globl __riscv_restore_0
98111
.type __riscv_restore_0,@function
99-
__riscv_restore_2:
100-
__riscv_restore_1:
101112
__riscv_restore_0:
102-
lw s1, 0(sp)
103-
lw s0, 4(sp)
104-
lw ra, 8(sp)
105-
addi sp, sp, 12
113+
lw ra, 0(sp)
114+
addi sp, sp, 4
106115
ret
107116

108117
#endif
@@ -188,17 +197,23 @@ __riscv_restore_0:
188197

189198
.globl __riscv_restore_2
190199
.type __riscv_restore_2,@function
200+
__riscv_restore_2:
201+
ld s1, 0(sp)
202+
addi sp, sp, 8
203+
// fallthrough into __riscv_restore_1/0
204+
191205
.globl __riscv_restore_1
192206
.type __riscv_restore_1,@function
207+
__riscv_restore_1:
208+
ld s0, 0(sp)
209+
addi sp, sp, 8
210+
// fallthrough into __riscv_restore_0
211+
193212
.globl __riscv_restore_0
194213
.type __riscv_restore_0,@function
195-
__riscv_restore_2:
196-
__riscv_restore_1:
197214
__riscv_restore_0:
198-
ld s1, 0(sp)
199-
ld s0, 8(sp)
200-
ld ra, 16(sp)
201-
addi sp, sp, 24
215+
ld ra, 0(sp)
216+
addi sp, sp, 8
202217
ret
203218

204219
#endif

compiler-rt/lib/builtins/riscv/save.S

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,28 @@ __riscv_save_0:
9898

9999
.globl __riscv_save_2
100100
.type __riscv_save_2,@function
101-
.globl __riscv_save_1
102-
.type __riscv_save_1,@function
103-
.globl __riscv_save_0
104-
.type __riscv_save_0,@function
105101
__riscv_save_2:
106-
__riscv_save_1:
107-
__riscv_save_0:
108102
addi sp, sp, -12
109103
sw s1, 0(sp)
110104
sw s0, 4(sp)
111105
sw ra, 8(sp)
112106
jr t0
113107

108+
.globl __riscv_save_1
109+
.type __riscv_save_1,@function
110+
__riscv_save_1:
111+
addi sp, sp, -8
112+
sw s0, 0(sp)
113+
sw ra, 4(sp)
114+
jr t0
115+
116+
.globl __riscv_save_0
117+
.type __riscv_save_0,@function
118+
__riscv_save_0:
119+
addi sp, sp, -4
120+
sw ra, 0(sp)
121+
jr t0
122+
114123
#endif
115124

116125
#elif __riscv_xlen == 64
@@ -208,18 +217,27 @@ __riscv_save_0:
208217

209218
.globl __riscv_save_2
210219
.type __riscv_save_2,@function
220+
__riscv_save_2:
221+
addi sp, sp, -24
222+
sw s1, 0(sp)
223+
sw s0, 8(sp)
224+
sw ra, 16(sp)
225+
jr t0
226+
211227
.globl __riscv_save_1
212228
.type __riscv_save_1,@function
229+
__riscv_save_1:
230+
addi sp, sp, -16
231+
sw s0, 0(sp)
232+
sw ra, 8(sp)
233+
jr t0
234+
213235
.globl __riscv_save_0
214236
.type __riscv_save_0,@function
215-
__riscv_save_2:
216-
__riscv_save_1:
217237
__riscv_save_0:
218-
addi sp, sp, -24
219-
sd s1, 0(sp)
220-
sd s0, 8(sp)
221-
sd ra, 16(sp)
222-
jr t0
238+
addi sp, sp, -8
239+
sw ra, 0(sp)
240+
jr t0
223241

224242
#endif
225243

libcxx/include/__type_traits/reference_constructs_from_temporary.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_constructs_from_tempo
3030

3131
#endif
3232

33+
#if __has_builtin(__reference_constructs_from_temporary)
34+
template <class _Tp, class _Up>
35+
inline const bool __reference_constructs_from_temporary_v = __reference_constructs_from_temporary(_Tp, _Up);
36+
#else
37+
// TODO(LLVM 22): Remove this as all supported compilers should have __reference_constructs_from_temporary implemented.
38+
template <class _Tp, class _Up>
39+
inline const bool __reference_constructs_from_temporary_v = __reference_binds_to_temporary(_Tp, _Up);
40+
#endif
41+
3342
_LIBCPP_END_NAMESPACE_STD
3443

3544
#endif // _LIBCPP___TYPE_TRAITS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY_H

libcxx/include/tuple

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ template <class... Types>
258258
# include <__type_traits/maybe_const.h>
259259
# include <__type_traits/nat.h>
260260
# include <__type_traits/negation.h>
261+
# include <__type_traits/reference_constructs_from_temporary.h>
261262
# include <__type_traits/remove_cv.h>
262263
# include <__type_traits/remove_cvref.h>
263264
# include <__type_traits/remove_reference.h>
@@ -308,15 +309,6 @@ template <size_t _Ip, class _Hp, bool>
308309
class __tuple_leaf {
309310
_Hp __value_;
310311

311-
template <class _Tp>
312-
static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() {
313-
# if __has_keyword(__reference_binds_to_temporary)
314-
return !__reference_binds_to_temporary(_Hp, _Tp);
315-
# else
316-
return true;
317-
# endif
318-
}
319-
320312
public:
321313
_LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
322314

@@ -346,15 +338,15 @@ public:
346338
_LIBCPP_HIDE_FROM_ABI
347339
_LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)
348340
: __value_(std::forward<_Tp>(__t)) {
349-
static_assert(__can_bind_reference<_Tp&&>(),
341+
static_assert(!__reference_constructs_from_temporary_v<_Hp, _Tp&&>,
350342
"Attempted construction of reference element binds to a temporary whose lifetime has ended");
351343
}
352344

353345
template <class _Tp, class _Alloc>
354346
_LIBCPP_HIDE_FROM_ABI
355347
_LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
356348
: __value_(std::forward<_Tp>(__t)) {
357-
static_assert(__can_bind_reference<_Tp&&>(),
349+
static_assert(!__reference_constructs_from_temporary_v<_Hp, _Tp&&>,
358350
"Attempted construction of reference element binds to a temporary whose lifetime has ended");
359351
}
360352

libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.verify.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ template <class T> struct CannotDeduce {
3838
template <class ...Args>
3939
void F(typename CannotDeduce<std::tuple<Args...>>::type const&) {}
4040

41-
4241
void f() {
43-
#if TEST_HAS_BUILTIN_IDENTIFIER(__reference_binds_to_temporary)
4442
// Test that we emit our diagnostic from the library.
4543
// expected-error@tuple:* 8 {{Attempted construction of reference element binds to a temporary whose lifetime has ended}}
4644

@@ -73,8 +71,4 @@ void f() {
7371
std::tuple<std::string &&> t2("hello"); // expected-note {{requested here}}
7472
std::tuple<std::string &&> t3(std::allocator_arg, alloc, "hello"); // expected-note {{requested here}}
7573
}
76-
#else
77-
#error force failure
78-
// expected-error@-1 {{force failure}}
79-
#endif
8074
}

libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
#include <cassert>
1919
#include "test_macros.h"
2020

21-
#if TEST_HAS_BUILTIN_IDENTIFIER(__reference_binds_to_temporary)
22-
# define ASSERT_REFERENCE_BINDS_TEMPORARY(...) static_assert(__reference_binds_to_temporary(__VA_ARGS__), "")
23-
# define ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(...) static_assert(!__reference_binds_to_temporary(__VA_ARGS__), "")
21+
#if TEST_HAS_BUILTIN(__reference_constructs_from_temporary)
22+
# define ASSERT_REFERENCE_BINDS_TEMPORARY(...) static_assert(__reference_constructs_from_temporary(__VA_ARGS__), "")
23+
# define ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(...) \
24+
static_assert(!__reference_constructs_from_temporary(__VA_ARGS__), "")
2425
#else
25-
# define ASSERT_REFERENCE_BINDS_TEMPORARY(...) static_assert(true, "")
26-
# define ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(...) static_assert(true, "")
26+
// TODO(LLVM 22): Remove this as all support compilers should have __reference_constructs_from_temporary implemented.
27+
# define ASSERT_REFERENCE_BINDS_TEMPORARY(...) static_assert(__reference_binds_to_temporary(__VA_ARGS__), "")
28+
# define ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(...) static_assert(!__reference_binds_to_temporary(__VA_ARGS__), "")
2729
#endif
2830

2931
template <class Tp>

0 commit comments

Comments
 (0)