Skip to content

Commit 7e6479d

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#4075)
2 parents 32b327a + b5cfecd commit 7e6479d

File tree

103 files changed

+4352
-5149
lines changed

Some content is hidden

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

103 files changed

+4352
-5149
lines changed

flang/lib/Semantics/check-acc-structure.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ void AccStructureChecker::CheckNotInComputeConstruct() {
136136
}
137137
}
138138

139-
bool AccStructureChecker::IsInsideParallelConstruct() const {
139+
bool AccStructureChecker::IsInsideKernelsConstruct() const {
140140
if (auto directive = getParentComputeConstruct())
141-
if (*directive == llvm::acc::ACCD_parallel ||
142-
*directive == llvm::acc::ACCD_parallel_loop)
141+
if (*directive == llvm::acc::ACCD_kernels ||
142+
*directive == llvm::acc::ACCD_kernels_loop)
143143
return true;
144144
return false;
145145
}
@@ -293,7 +293,10 @@ void AccStructureChecker::CheckNotInSameOrSubLevelLoopConstruct() {
293293
bool invalid{false};
294294
if (parentClause == llvm::acc::Clause::ACCC_gang &&
295295
cl == llvm::acc::Clause::ACCC_gang) {
296-
if (IsInsideParallelConstruct()) {
296+
if (IsInsideKernelsConstruct()) {
297+
context_.Say(GetContext().clauseSource,
298+
"Nested GANG loops are not allowed in the region of a KERNELS construct"_err_en_US);
299+
} else {
297300
auto parentDim = getGangDimensionSize(parent);
298301
auto currentDim = getGangDimensionSize(GetContext());
299302
std::int64_t parentDimNum = 1, currentDimNum = 1;
@@ -317,8 +320,6 @@ void AccStructureChecker::CheckNotInSameOrSubLevelLoopConstruct() {
317320
parentDimStr);
318321
continue;
319322
}
320-
} else {
321-
invalid = true;
322323
}
323324
} else if (parentClause == llvm::acc::Clause::ACCC_worker &&
324325
(cl == llvm::acc::Clause::ACCC_gang ||

flang/lib/Semantics/check-acc-structure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class AccStructureChecker
101101
bool IsLoopConstruct(llvm::acc::Directive directive) const;
102102
std::optional<llvm::acc::Directive> getParentComputeConstruct() const;
103103
bool IsInsideComputeConstruct() const;
104-
bool IsInsideParallelConstruct() const;
104+
bool IsInsideKernelsConstruct() const;
105105
void CheckNotInComputeConstruct();
106106
std::optional<std::int64_t> getGangDimensionSize(
107107
DirectiveContext &dirContext);

flang/test/Semantics/OpenACC/acc-loop.f90

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ program openacc_loop_validity
340340

341341
!$acc kernels loop gang(dim:3)
342342
do i = 1, n
343-
!ERROR: GANG clause is not allowed in the region of a loop with the GANG clause
343+
!ERROR: Nested GANG loops are not allowed in the region of a KERNELS construct
344344
!$acc loop gang(dim:2)
345345
do j = 1, n
346-
!ERROR: GANG clause is not allowed in the region of a loop with the GANG clause
346+
!ERROR: Nested GANG loops are not allowed in the region of a KERNELS construct
347347
!$acc loop gang(dim:1) worker vector
348348
do k = 1, i
349349
end do
@@ -447,4 +447,35 @@ program openacc_loop_validity
447447
END DO
448448
END DO
449449

450+
contains
451+
452+
subroutine sub1()
453+
!$acc routine gang(dim:2)
454+
implicit none
455+
integer, parameter :: N = 256
456+
integer :: i, j
457+
458+
!$acc loop gang(dim:2)
459+
DO j = 1, N
460+
!$acc loop gang(dim:1) vector
461+
DO i = 1, N
462+
END DO
463+
END DO
464+
end subroutine sub1
465+
466+
subroutine sub2()
467+
!$acc routine gang(dim:2)
468+
implicit none
469+
integer, parameter :: N = 256
470+
integer :: i, j
471+
472+
!$acc loop gang(dim:2)
473+
DO j = 1, N
474+
!ERROR: GANG(dim:2) clause is not allowed in the region of a loop with the GANG(dim:2) clause
475+
!$acc loop gang(dim:2) vector
476+
DO i = 1, N
477+
END DO
478+
END DO
479+
end subroutine sub2
480+
450481
end program openacc_loop_validity

libcxx/include/string

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,13 +1312,17 @@ public:
13121312
# if _LIBCPP_STD_VER >= 23
13131313
template <class _Op>
13141314
_LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) {
1315-
__resize_default_init(__n);
1316-
__erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
1315+
size_type __sz = size();
1316+
size_type __cap = capacity();
1317+
if (__n > __cap)
1318+
__grow_by_without_replace(__cap, __n - __cap, __sz, __sz, 0);
1319+
__annotate_delete();
1320+
__set_size(__n);
1321+
__annotate_new(__n);
1322+
__erase_to_end(std::move(__op)(data(), auto(__n)));
13171323
}
13181324
# endif
13191325

1320-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n);
1321-
13221326
# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE)
13231327
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }
13241328
# endif
@@ -1410,8 +1414,6 @@ public:
14101414
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
14111415
_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c);
14121416

1413-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append_default_init(size_type __n);
1414-
14151417
template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
14161418
_LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
14171419
append(_InputIterator __first, _InputIterator __last) {
@@ -3081,22 +3083,6 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
30813083
return *this;
30823084
}
30833085

3084-
template <class _CharT, class _Traits, class _Allocator>
3085-
_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
3086-
basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) {
3087-
if (__n == 0)
3088-
return;
3089-
size_type __cap = capacity();
3090-
size_type __sz = size();
3091-
if (__cap - __sz < __n)
3092-
__grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);
3093-
__annotate_increase(__n);
3094-
pointer __p = __get_pointer();
3095-
__sz += __n;
3096-
__set_size(__sz);
3097-
traits_type::assign(__p[__sz], value_type());
3098-
}
3099-
31003086
template <class _CharT, class _Traits, class _Allocator>
31013087
_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) {
31023088
bool __is_short = !__is_long();
@@ -3435,16 +3421,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re
34353421
__erase_to_end(__n);
34363422
}
34373423

3438-
template <class _CharT, class _Traits, class _Allocator>
3439-
_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
3440-
basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) {
3441-
size_type __sz = size();
3442-
if (__n > __sz) {
3443-
__append_default_init(__n - __sz);
3444-
} else
3445-
__erase_to_end(__n);
3446-
}
3447-
34483424
template <class _CharT, class _Traits, class _Allocator>
34493425
_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) {
34503426
if (__requested_capacity > max_size())

libcxx/src/filesystem/format_string.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,19 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 0) string vformat_string(const ch
3434

3535
va_list apcopy;
3636
va_copy(apcopy, ap);
37-
int ret = ::vsnprintf(buf.data(), buf.size(), msg, apcopy);
37+
int size = ::vsnprintf(buf.data(), buf.size(), msg, apcopy);
3838
va_end(apcopy);
3939

4040
string result;
41-
if (static_cast<size_t>(ret) < buf.size()) {
42-
result.assign(buf.data(), static_cast<size_t>(ret));
41+
if (static_cast<size_t>(size) < buf.size()) {
42+
result.assign(buf.data(), static_cast<size_t>(size));
4343
} else {
4444
// we did not provide a long enough buffer on our first attempt. The
4545
// return value is the number of bytes (excluding the null byte) that are
4646
// needed for formatting.
47-
size_t size_with_null = static_cast<size_t>(ret) + 1;
48-
result.__resize_default_init(size_with_null - 1);
49-
ret = ::vsnprintf(&result[0], size_with_null, msg, ap);
50-
_LIBCPP_ASSERT_INTERNAL(static_cast<size_t>(ret) == (size_with_null - 1), "TODO");
47+
result.resize_and_overwrite(size, [&](char* res, size_t n) { return ::vsnprintf(res, n, msg, ap); });
48+
_LIBCPP_ASSERT_INTERNAL(static_cast<size_t>(size) == result.size(),
49+
"vsnprintf did not result in the same number of characters as the first attempt?");
5150
}
5251
return result;
5352
}

libcxx/test/benchmarks/containers/string.bench.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, c++11, c++14, c++17
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1010

11+
#include <algorithm>
1112
#include <cstdint>
1213
#include <cstdlib>
1314
#include <new>
@@ -67,6 +68,21 @@ static void BM_StringCtorDefault(benchmark::State& state) {
6768
}
6869
BENCHMARK(BM_StringCtorDefault);
6970

71+
static void BM_StringResizeAndOverwrite(benchmark::State& state) {
72+
std::string str;
73+
74+
for (auto _ : state) {
75+
benchmark::DoNotOptimize(str);
76+
str.resize_and_overwrite(10, [](char* ptr, size_t n) {
77+
std::fill_n(ptr, n, 'a');
78+
return n;
79+
});
80+
benchmark::DoNotOptimize(str);
81+
str.clear();
82+
}
83+
}
84+
BENCHMARK(BM_StringResizeAndOverwrite);
85+
7086
enum class Length { Empty, Small, Large, Huge };
7187
struct AllLengths : EnumValuesAsTuple<AllLengths, Length, 4> {
7288
static constexpr const char* Names[] = {"Empty", "Small", "Large", "Huge"};

libcxx/test/libcxx-03/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp

Lines changed: 0 additions & 75 deletions
This file was deleted.

libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, c++11, c++14
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1010
// UNSUPPORTED: availability-filesystem-missing
1111
// UNSUPPORTED: no-filesystem
1212
// ADDITIONAL_COMPILE_FLAGS: -I %{libcxx-dir}/src

libcxx/test/libcxx/input.output/filesystems/convert_file_time.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03, c++11, c++14
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1010
// UNSUPPORTED: availability-filesystem-missing
1111

1212
// <filesystem>

libcxx/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)