Skip to content

Commit 7f37006

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:52db7e27458f into amd-gfx:b433a27d80cf
Local branch amd-gfx b433a27 Merged main:cbf7d5f82b72 into amd-gfx:8494c22787c6 Remote branch main 52db7e2 [mlir][nvgpu] Improve `WarpgroupAccumulator` type to simplify IR (llvm#68728)
2 parents b433a27 + 52db7e2 commit 7f37006

File tree

42 files changed

+1191
-425
lines changed

Some content is hidden

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

42 files changed

+1191
-425
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,11 @@ set -eu
2121
set -o pipefail
2222

2323
# Environment variables script works with:
24-
# List of files affected by this commit
25-
: ${MODIFIED_FILES:=$(git diff --name-only HEAD~1)}
24+
2625
# Fetch origin/main to have an up to date merge base for main...HEAD diff.
2726
git fetch origin main:main
28-
echo "files modified HEAD~1" >&2
29-
git --no-pager diff --name-only HEAD~1 >&2
30-
echo "files modified main...HEAD" >&2
31-
git --no-pager diff --name-only main...HEAD | head -n 10 >&2
32-
merge_base=$(git merge-base main HEAD)
33-
echo "merge base with main $merge_base" >&2
34-
echo "git log" >&2
35-
git --no-pager log --oneline --abbrev-commit -n 5 >&2
27+
# List of files affected by this commit
28+
: ${MODIFIED_FILES:=$(git diff --name-only main...HEAD)}
3629
# Filter rules for generic windows tests
3730
: ${WINDOWS_AGENTS:='{"queue": "windows"}'}
3831
# Filter rules for generic linux tests

clang/lib/AST/ASTContext.cpp

Lines changed: 115 additions & 99 deletions
Large diffs are not rendered by default.

clang/lib/Sema/SemaType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6684,8 +6684,8 @@ ParsedType Sema::CreateParsedType(QualType T, TypeSourceInfo *TInfo) {
66846684
// FIXME: LocInfoTypes are "transient", only needed for passing to/from Parser
66856685
// and Sema during declaration parsing. Try deallocating/caching them when
66866686
// it's appropriate, instead of allocating them and keeping them around.
6687-
LocInfoType *LocT = (LocInfoType*)BumpAlloc.Allocate(sizeof(LocInfoType),
6688-
TypeAlignment);
6687+
LocInfoType *LocT = (LocInfoType *)BumpAlloc.Allocate(sizeof(LocInfoType),
6688+
alignof(LocInfoType));
66896689
new (LocT) LocInfoType(T, TInfo);
66906690
assert(LocT->getTypeClass() != T->getTypeClass() &&
66916691
"LocInfoType's TypeClass conflicts with an existing Type class");

clang/test/AST/Interp/cxx23.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=ref20 %s
2+
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=ref23 %s
3+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=expected20 %s -fexperimental-new-constant-interpreter
4+
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=expected23 %s -fexperimental-new-constant-interpreter
5+
6+
7+
// expected23-no-diagnostics
8+
9+
10+
/// FIXME: The new interpreter is missing all the 'control flows through...' diagnostics.
11+
12+
constexpr int f(int n) { // ref20-error {{constexpr function never produces a constant expression}} \
13+
// ref23-error {{constexpr function never produces a constant expression}}
14+
static const int m = n; // ref20-note {{control flows through the definition of a static variable}} \
15+
// ref20-warning {{is a C++23 extension}} \
16+
// ref23-note {{control flows through the definition of a static variable}} \
17+
// expected20-warning {{is a C++23 extension}}
18+
19+
return m;
20+
}
21+
constexpr int g(int n) { // ref20-error {{constexpr function never produces a constant expression}} \
22+
// ref23-error {{constexpr function never produces a constant expression}}
23+
thread_local const int m = n; // ref20-note {{control flows through the definition of a thread_local variable}} \
24+
// ref20-warning {{is a C++23 extension}} \
25+
// ref23-note {{control flows through the definition of a thread_local variable}} \
26+
// expected20-warning {{is a C++23 extension}}
27+
return m;
28+
}
29+
30+
constexpr int c_thread_local(int n) { // ref20-error {{constexpr function never produces a constant expression}} \
31+
// ref23-error {{constexpr function never produces a constant expression}}
32+
static _Thread_local int m = 0; // ref20-note {{control flows through the definition of a thread_local variable}} \
33+
// ref20-warning {{is a C++23 extension}} \
34+
// ref23-note {{control flows through the definition of a thread_local variable}} \
35+
// expected20-warning {{is a C++23 extension}}
36+
return m;
37+
}
38+
39+
40+
constexpr int gnu_thread_local(int n) { // ref20-error {{constexpr function never produces a constant expression}} \
41+
// ref23-error {{constexpr function never produces a constant expression}}
42+
static __thread int m = 0; // ref20-note {{control flows through the definition of a thread_local variable}} \
43+
// ref20-warning {{is a C++23 extension}} \
44+
// ref23-note {{control flows through the definition of a thread_local variable}} \
45+
// expected20-warning {{is a C++23 extension}}
46+
return m;
47+
}
48+
49+
constexpr int h(int n) { // ref20-error {{constexpr function never produces a constant expression}} \
50+
// ref23-error {{constexpr function never produces a constant expression}}
51+
static const int m = n; // ref20-note {{control flows through the definition of a static variable}} \
52+
// ref20-warning {{is a C++23 extension}} \
53+
// ref23-note {{control flows through the definition of a static variable}} \
54+
// expected20-warning {{is a C++23 extension}}
55+
return &m - &m;
56+
}
57+
58+
constexpr int i(int n) { // ref20-error {{constexpr function never produces a constant expression}} \
59+
// ref23-error {{constexpr function never produces a constant expression}}
60+
thread_local const int m = n; // ref20-note {{control flows through the definition of a thread_local variable}} \
61+
// ref20-warning {{is a C++23 extension}} \
62+
// ref23-note {{control flows through the definition of a thread_local variable}} \
63+
// expected20-warning {{is a C++23 extension}}
64+
return &m - &m;
65+
}
66+
67+
constexpr int j(int n) {
68+
if (!n)
69+
return 0;
70+
static const int m = n; // ref20-warning {{is a C++23 extension}} \
71+
// expected20-warning {{is a C++23 extension}}
72+
return m;
73+
}
74+
constexpr int j0 = j(0);
75+
76+
constexpr int k(int n) {
77+
if (!n)
78+
return 0;
79+
thread_local const int m = n; // ref20-warning {{is a C++23 extension}} \
80+
// expected20-warning {{is a C++23 extension}}
81+
82+
return m;
83+
}
84+
constexpr int k0 = k(0);

compiler-rt/test/hwasan/TestCases/deep-recursion.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
// Stack histories are currently not recorded on x86.
1818
// XFAIL: target=x86_64{{.*}}
1919

20+
#include <stdint.h>
2021
#include <stdlib.h>
22+
2123
// At least -O1 is needed for this function to not have a stack frame on
2224
// AArch64.
2325
void USE(void *x) { // pretend_to_do_something(void *x)

libcxx/include/sstream

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ public:
400400
_LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const & { return str(__str_.get_allocator()); }
401401

402402
_LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && {
403-
string_type __result;
404403
const basic_string_view<_CharT, _Traits> __view = view();
405-
if (!__view.empty()) {
406-
auto __pos = __view.data() - __str_.data();
407-
__result.assign(std::move(__str_), __pos, __view.size());
408-
}
404+
typename string_type::size_type __pos = __view.empty() ? 0 : __view.data() - __str_.data();
405+
// In C++23, this is just string_type(std::move(__str_), __pos, __view.size(), __str_.get_allocator());
406+
// But we need something that works in C++20 also.
407+
string_type __result(__str_.get_allocator());
408+
__result.__move_assign(std::move(__str_), __pos, __view.size());
409409
__str_.clear();
410410
__init_buf_ptrs();
411411
return __result;

libcxx/include/string

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,12 +979,7 @@ public:
979979

980980
auto __len = std::min<size_type>(__n, __str.size() - __pos);
981981
if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc()) {
982-
__r_.first() = __str.__r_.first();
983-
__str.__r_.first() = __rep();
984-
985-
_Traits::move(data(), data() + __pos, __len);
986-
__set_size(__len);
987-
_Traits::assign(data()[__len], value_type());
982+
__move_assign(std::move(__str), __pos, __len);
988983
} else {
989984
// Perform a copy because the allocators are not compatible.
990985
__init(__str.data() + __pos, __len);
@@ -1329,6 +1324,20 @@ public:
13291324
return assign(__sv.data(), __sv.size());
13301325
}
13311326

1327+
#if _LIBCPP_STD_VER >= 20
1328+
_LIBCPP_HIDE_FROM_ABI constexpr
1329+
void __move_assign(basic_string&& __str, size_type __pos, size_type __len) {
1330+
// Pilfer the allocation from __str.
1331+
_LIBCPP_ASSERT_INTERNAL(__alloc() == __str.__alloc(), "__move_assign called with wrong allocator");
1332+
__r_.first() = __str.__r_.first();
1333+
__str.__r_.first() = __rep();
1334+
1335+
_Traits::move(data(), data() + __pos, __len);
1336+
__set_size(__len);
1337+
_Traits::assign(data()[__len], value_type());
1338+
}
1339+
#endif
1340+
13321341
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13331342
basic_string& assign(const basic_string& __str) { return *this = __str; }
13341343
#ifndef _LIBCPP_CXX03_LANG
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
//===----------------------------------------------------------------------===//
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+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
// TODO: Change to XFAIL once https://github.com/llvm/llvm-project/issues/40340 is fixed
11+
// UNSUPPORTED: availability-pmr-missing
12+
13+
// This test ensures that we properly propagate allocators from istringstream's
14+
// inner string object to the new string returned from .str().
15+
// `str() const&` is specified to preserve the allocator (not copy the string).
16+
// `str() &&` isn't specified, but should preserve the allocator (move the string).
17+
18+
#include <cassert>
19+
#include <memory>
20+
#include <memory_resource>
21+
#include <sstream>
22+
#include <string>
23+
#include <string_view>
24+
#include <type_traits>
25+
26+
#include "make_string.h"
27+
#include "test_allocator.h"
28+
#include "test_macros.h"
29+
30+
template <class CharT>
31+
void test_soccc_behavior() {
32+
using Alloc = SocccAllocator<CharT>;
33+
using SS = std::basic_istringstream<CharT, std::char_traits<CharT>, Alloc>;
34+
using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc>;
35+
{
36+
SS ss = SS(std::ios_base::in, Alloc(10));
37+
38+
// [stringbuf.members]/6 specifies that the allocator is copied,
39+
// not select_on_container_copy_construction'ed.
40+
//
41+
S copied = ss.str();
42+
assert(copied.get_allocator().count_ == 10);
43+
assert(ss.rdbuf()->get_allocator().count_ == 10);
44+
assert(copied.empty());
45+
46+
// sanity-check that SOCCC does in fact work
47+
assert(S(copied).get_allocator().count_ == 11);
48+
49+
// [stringbuf.members]/10 doesn't specify the allocator to use,
50+
// but copying the allocator as-if-by moving the string makes sense.
51+
//
52+
S moved = std::move(ss).str();
53+
assert(moved.get_allocator().count_ == 10);
54+
assert(ss.rdbuf()->get_allocator().count_ == 10);
55+
assert(moved.empty());
56+
}
57+
}
58+
59+
template <class CharT,
60+
class Base = std::basic_stringbuf<CharT, std::char_traits<CharT>, std::pmr::polymorphic_allocator<CharT>>>
61+
struct StringBuf : Base {
62+
explicit StringBuf(std::pmr::memory_resource* mr) : Base(std::ios_base::in, mr) {}
63+
void public_setg(int a, int b, int c) {
64+
CharT* p = this->eback();
65+
assert(this->view().data() == p);
66+
this->setg(p + a, p + b, p + c);
67+
assert(this->eback() == p + a);
68+
assert(this->view().data() == p + a);
69+
}
70+
};
71+
72+
template <class CharT>
73+
void test_allocation_is_pilfered() {
74+
using SS = std::basic_istringstream<CharT, std::char_traits<CharT>, std::pmr::polymorphic_allocator<CharT>>;
75+
using S = std::pmr::basic_string<CharT>;
76+
alignas(void*) char buf[80 * sizeof(CharT)];
77+
const CharT* initial =
78+
MAKE_CSTRING(CharT, "a very long string that exceeds the small string optimization buffer length");
79+
{
80+
std::pmr::set_default_resource(std::pmr::null_memory_resource());
81+
auto mr1 = std::pmr::monotonic_buffer_resource(buf, sizeof(buf), std::pmr::null_memory_resource());
82+
SS ss = SS(S(initial, &mr1));
83+
S s = std::move(ss).str();
84+
assert(s == initial);
85+
}
86+
{
87+
// Try moving-out-of a stringbuf whose view() is not the entire string.
88+
// This is libc++'s behavior; libstdc++ doesn't allow such stringbufs to be created.
89+
//
90+
std::pmr::set_default_resource(std::pmr::null_memory_resource());
91+
auto mr1 = std::pmr::monotonic_buffer_resource(buf, sizeof(buf), std::pmr::null_memory_resource());
92+
auto src = StringBuf<CharT>(&mr1);
93+
src.str(S(initial, &mr1));
94+
src.public_setg(2, 6, 40);
95+
SS ss(std::ios_base::in, &mr1);
96+
*ss.rdbuf() = std::move(src);
97+
LIBCPP_ASSERT(ss.view() == std::basic_string_view<CharT>(initial).substr(2, 38));
98+
S s = std::move(ss).str();
99+
LIBCPP_ASSERT(s == std::basic_string_view<CharT>(initial).substr(2, 38));
100+
}
101+
}
102+
103+
template <class CharT>
104+
void test_no_foreign_allocations() {
105+
using SS = std::basic_istringstream<CharT, std::char_traits<CharT>, std::pmr::polymorphic_allocator<CharT>>;
106+
using S = std::pmr::basic_string<CharT>;
107+
const CharT* initial =
108+
MAKE_CSTRING(CharT, "a very long string that exceeds the small string optimization buffer length");
109+
{
110+
std::pmr::set_default_resource(std::pmr::null_memory_resource());
111+
auto mr1 = std::pmr::monotonic_buffer_resource(std::pmr::new_delete_resource());
112+
auto ss = SS(S(initial, &mr1));
113+
assert(ss.rdbuf()->get_allocator().resource() == &mr1);
114+
115+
// [stringbuf.members]/6 specifies that the result of `str() const &`
116+
// does NOT use the default allocator; it uses the original allocator.
117+
//
118+
S copied = ss.str();
119+
assert(copied.get_allocator().resource() == &mr1);
120+
assert(ss.rdbuf()->get_allocator().resource() == &mr1);
121+
assert(copied == initial);
122+
123+
// [stringbuf.members]/10 doesn't specify the allocator to use,
124+
// but copying the allocator as-if-by moving the string makes sense.
125+
//
126+
S moved = std::move(ss).str();
127+
assert(moved.get_allocator().resource() == &mr1);
128+
assert(ss.rdbuf()->get_allocator().resource() == &mr1);
129+
assert(moved == initial);
130+
}
131+
}
132+
133+
int main(int, char**) {
134+
test_soccc_behavior<char>();
135+
test_allocation_is_pilfered<char>();
136+
test_no_foreign_allocations<char>();
137+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
138+
test_soccc_behavior<wchar_t>();
139+
test_allocation_is_pilfered<wchar_t>();
140+
test_no_foreign_allocations<wchar_t>();
141+
#endif
142+
143+
return 0;
144+
}

libcxx/test/std/input.output/string.streams/istringstream/istringstream.members/str.move.pass.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ static void test() {
3737
assert(s.empty());
3838
assert(ss.view().empty());
3939
}
40+
{
41+
std::basic_istringstream<CharT> ss(
42+
STR("a very long string that exceeds the small string optimization buffer length"));
43+
const CharT* p = ss.view().data();
44+
std::basic_string<CharT> s = std::move(ss).str();
45+
assert(s.data() == p); // the allocation was pilfered
46+
assert(ss.view().empty());
47+
}
4048
}
4149

4250
int main(int, char**) {

0 commit comments

Comments
 (0)