Skip to content

Commit da920f4

Browse files
committed
merge main into amd-staging
rever: hangs ocl tests at -O0 735a5f6 [AMDGPU] When allocating VGPRs, VGPR spills are not part of the prologue (llvm#109439) Change-Id: If6452f3c5943af849b606cbe6f1262597c5e0f2f
2 parents a879c42 + bfde178 commit da920f4

File tree

73 files changed

+1328
-274
lines changed

Some content is hidden

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

73 files changed

+1328
-274
lines changed

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ AST_MATCHER_P(DeducedTemplateSpecializationType, refsToTemplatedDecl,
2525
return false;
2626
}
2727

28+
AST_MATCHER_P(Type, asTagDecl, clang::ast_matchers::internal::Matcher<TagDecl>,
29+
DeclMatcher) {
30+
if (const TagDecl *ND = Node.getAsTagDecl())
31+
return DeclMatcher.matches(*ND, Finder, Builder);
32+
return false;
33+
}
34+
2835
} // namespace
2936

3037
// A function that helps to tell whether a TargetDecl in a UsingDecl will be
@@ -61,7 +68,8 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
6168
Finder->addMatcher(userDefinedLiteral().bind("used"), this);
6269
Finder->addMatcher(
6370
loc(elaboratedType(unless(hasQualifier(nestedNameSpecifier())),
64-
hasUnqualifiedDesugaredType(type().bind("usedType")))),
71+
hasUnqualifiedDesugaredType(
72+
type(asTagDecl(tagDecl().bind("used")))))),
6573
this);
6674
// Cases where we can identify the UsingShadowDecl directly, rather than
6775
// just its target.
@@ -139,12 +147,6 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
139147
return;
140148
}
141149

142-
if (const auto *T = Result.Nodes.getNodeAs<Type>("usedType")) {
143-
if (const auto *ND = T->getAsTagDecl())
144-
RemoveNamedDecl(ND);
145-
return;
146-
}
147-
148150
if (const auto *UsedShadow =
149151
Result.Nodes.getNodeAs<UsingShadowDecl>("usedShadow")) {
150152
removeFromFoundDecls(UsedShadow->getTargetDecl());

clang-tools-extra/clangd/index/SymbolCollector.cpp

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "llvm/ADT/DenseMap.h"
4242
#include "llvm/ADT/SmallVector.h"
4343
#include "llvm/ADT/StringRef.h"
44+
#include "llvm/Support/Casting.h"
4445
#include "llvm/Support/ErrorHandling.h"
4546
#include "llvm/Support/FileSystem.h"
4647
#include "llvm/Support/Path.h"
@@ -75,18 +76,62 @@ bool isPrivateProtoDecl(const NamedDecl &ND) {
7576
if (ND.getIdentifier() == nullptr)
7677
return false;
7778
auto Name = ND.getIdentifier()->getName();
78-
if (!Name.contains('_'))
79-
return false;
80-
// Nested proto entities (e.g. Message::Nested) have top-level decls
81-
// that shouldn't be used (Message_Nested). Ignore them completely.
82-
// The nested entities are dangling type aliases, we may want to reconsider
83-
// including them in the future.
84-
// For enum constants, SOME_ENUM_CONSTANT is not private and should be
85-
// indexed. Outer_INNER is private. This heuristic relies on naming style, it
86-
// will include OUTER_INNER and exclude some_enum_constant.
87-
// FIXME: the heuristic relies on naming style (i.e. no underscore in
88-
// user-defined names) and can be improved.
89-
return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
79+
// There are some internal helpers like _internal_set_foo();
80+
if (Name.contains("_internal_"))
81+
return true;
82+
83+
// https://protobuf.dev/reference/cpp/cpp-generated/#nested-types
84+
// Nested entities (messages/enums) has two names, one at the top-level scope,
85+
// with a mangled name created by prepending all the outer types. These names
86+
// are almost never preferred by the developers, so exclude them from index.
87+
// e.g.
88+
// message Foo {
89+
// message Bar {}
90+
// enum E { A }
91+
// }
92+
//
93+
// yields:
94+
// class Foo_Bar {};
95+
// enum Foo_E { Foo_E_A };
96+
// class Foo {
97+
// using Bar = Foo_Bar;
98+
// static constexpr Foo_E A = Foo_E_A;
99+
// };
100+
101+
// We get rid of Foo_Bar and Foo_E by discarding any top-level entries with
102+
// `_` in the name. This relies on original message/enum not having `_` in the
103+
// name. Hence might go wrong in certain cases.
104+
if (ND.getDeclContext()->isNamespace()) {
105+
// Strip off some known public suffix helpers for enums, rest of the helpers
106+
// are generated inside record decls so we don't care.
107+
// https://protobuf.dev/reference/cpp/cpp-generated/#enum
108+
Name.consume_back("_descriptor");
109+
Name.consume_back("_IsValid");
110+
Name.consume_back("_Name");
111+
Name.consume_back("_Parse");
112+
Name.consume_back("_MIN");
113+
Name.consume_back("_MAX");
114+
Name.consume_back("_ARRAYSIZE");
115+
return Name.contains('_');
116+
}
117+
118+
// EnumConstantDecls need some special attention, despite being nested in a
119+
// TagDecl, they might still have mangled names. We filter those by checking
120+
// if it has parent's name as a prefix.
121+
// This might go wrong if a nested entity has a name that starts with parent's
122+
// name, e.g: enum Foo { Foo_X }.
123+
if (llvm::isa<EnumConstantDecl>(&ND)) {
124+
auto *DC = llvm::cast<EnumDecl>(ND.getDeclContext());
125+
if (!DC || !DC->getIdentifier())
126+
return false;
127+
auto CtxName = DC->getIdentifier()->getName();
128+
return !CtxName.empty() && Name.consume_front(CtxName) &&
129+
Name.consume_front("_");
130+
}
131+
132+
// Now we're only left with fields/methods without an `_internal_` in the
133+
// name, they're intended for public use.
134+
return false;
90135
}
91136

92137
// We only collect #include paths for symbols that are suitable for global code

clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,63 @@ TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {
201201
build(
202202
R"(// Generated by the protocol buffer compiler. DO NOT EDIT!
203203
namespace nx {
204-
class Top_Level {};
205-
class TopLevel {};
206-
enum Kind {
207-
KIND_OK,
208-
Kind_Not_Ok,
204+
enum Outer_Enum : int {
205+
Outer_Enum_KIND1,
206+
Outer_Enum_Kind_2,
209207
};
208+
bool Outer_Enum_IsValid(int);
209+
210+
class Outer_Inner {};
211+
class Outer {
212+
using Inner = Outer_Inner;
213+
using Enum = Outer_Enum;
214+
static constexpr Enum KIND1 = Outer_Enum_KIND1;
215+
static constexpr Enum Kind_2 = Outer_Enum_Kind_2;
216+
static bool Enum_IsValid(int);
217+
int &x();
218+
void set_x();
219+
void _internal_set_x();
220+
221+
int &Outer_y();
222+
};
223+
enum Foo {
224+
FOO_VAL1,
225+
Foo_VAL2,
226+
};
227+
bool Foo_IsValid(int);
210228
})");
211-
EXPECT_TRUE(shouldCollect("nx::TopLevel"));
212-
EXPECT_TRUE(shouldCollect("nx::Kind::KIND_OK"));
213-
EXPECT_TRUE(shouldCollect("nx::Kind"));
214229

215-
EXPECT_FALSE(shouldCollect("nx::Top_Level"));
216-
EXPECT_FALSE(shouldCollect("nx::Kind::Kind_Not_Ok"));
230+
// Make sure all the mangled names for Outer::Enum is discarded.
231+
EXPECT_FALSE(shouldCollect("nx::Outer_Enum"));
232+
EXPECT_FALSE(shouldCollect("nx::Outer_Enum_KIND1"));
233+
EXPECT_FALSE(shouldCollect("nx::Outer_Enum_Kind_2"));
234+
EXPECT_FALSE(shouldCollect("nx::Outer_Enum_IsValid"));
235+
// But nested aliases are preserved.
236+
EXPECT_TRUE(shouldCollect("nx::Outer::Enum"));
237+
EXPECT_TRUE(shouldCollect("nx::Outer::KIND1"));
238+
EXPECT_TRUE(shouldCollect("nx::Outer::Kind_2"));
239+
EXPECT_TRUE(shouldCollect("nx::Outer::Enum_IsValid"));
240+
241+
// Check for Outer::Inner.
242+
EXPECT_FALSE(shouldCollect("nx::Outer_Inner"));
243+
EXPECT_TRUE(shouldCollect("nx::Outer"));
244+
EXPECT_TRUE(shouldCollect("nx::Outer::Inner"));
245+
246+
// Make sure field related information is preserved, unless it's explicitly
247+
// marked with `_internal_`.
248+
EXPECT_TRUE(shouldCollect("nx::Outer::x"));
249+
EXPECT_TRUE(shouldCollect("nx::Outer::set_x"));
250+
EXPECT_FALSE(shouldCollect("nx::Outer::_internal_set_x"));
251+
EXPECT_TRUE(shouldCollect("nx::Outer::Outer_y"));
252+
253+
// Handling of a top-level enum
254+
EXPECT_TRUE(shouldCollect("nx::Foo::FOO_VAL1"));
255+
EXPECT_TRUE(shouldCollect("nx::FOO_VAL1"));
256+
EXPECT_TRUE(shouldCollect("nx::Foo_IsValid"));
257+
// Our heuristic goes wrong here, if the user has a nested name that starts
258+
// with parent's name.
259+
EXPECT_FALSE(shouldCollect("nx::Foo::Foo_VAL2"));
260+
EXPECT_FALSE(shouldCollect("nx::Foo_VAL2"));
217261
}
218262

219263
TEST_F(ShouldCollectSymbolTest, DoubleCheckProtoHeaderComment) {

clang/include/clang/Basic/arm_sme.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,4 +817,9 @@ multiclass ZAReadzArray<string vg_num>{
817817

818818
defm SVREADZ_VG2 : ZAReadzArray<"2">;
819819
defm SVREADZ_VG4 : ZAReadzArray<"4">;
820+
821+
let SMETargetGuard = "sme2,sme-lutv2" in {
822+
def SVLUTI4_ZT_X4 : SInst<"svluti4_zt_{d}_x4", "4i2.u", "cUc", MergeNone, "aarch64_sme_luti4_zt_x4", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>]>;
823+
}
824+
820825
} // let SVETargetGuard = InvalidMode
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2+
3+
// REQUIRES: aarch64-registered-target
4+
5+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
6+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
7+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -disable-O0-optnone -Werror -Wall -o /dev/null %s
8+
9+
10+
#include <arm_sme.h>
11+
12+
// CHECK-LABEL: define dso_local { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } @test_luti4_zt_u8_x4(
13+
// CHECK-SAME: <vscale x 16 x i8> [[OP_COERCE0:%.*]], <vscale x 16 x i8> [[OP_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] {
14+
// CHECK-NEXT: [[ENTRY:.*:]]
15+
// CHECK-NEXT: [[TMP0:%.*]] = tail call { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } @llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0, <vscale x 16 x i8> [[OP_COERCE0]], <vscale x 16 x i8> [[OP_COERCE1]])
16+
// CHECK-NEXT: ret { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } [[TMP0]]
17+
//
18+
// CPP-CHECK-LABEL: define dso_local { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } @_Z19test_luti4_zt_u8_x411svuint8x2_t(
19+
// CPP-CHECK-SAME: <vscale x 16 x i8> [[OP_COERCE0:%.*]], <vscale x 16 x i8> [[OP_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] {
20+
// CPP-CHECK-NEXT: [[ENTRY:.*:]]
21+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } @llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0, <vscale x 16 x i8> [[OP_COERCE0]], <vscale x 16 x i8> [[OP_COERCE1]])
22+
// CPP-CHECK-NEXT: ret { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } [[TMP0]]
23+
//
24+
svuint8x4_t test_luti4_zt_u8_x4(svuint8x2_t op) __arm_streaming __arm_in("zt0") {
25+
return svluti4_zt_u8_x4(0, op);
26+
}
27+
28+
// CHECK-LABEL: define dso_local { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } @test_luti4_zt_s8_x4(
29+
// CHECK-SAME: <vscale x 16 x i8> [[OP_COERCE0:%.*]], <vscale x 16 x i8> [[OP_COERCE1:%.*]]) #[[ATTR0]] {
30+
// CHECK-NEXT: [[ENTRY:.*:]]
31+
// CHECK-NEXT: [[TMP0:%.*]] = tail call { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } @llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0, <vscale x 16 x i8> [[OP_COERCE0]], <vscale x 16 x i8> [[OP_COERCE1]])
32+
// CHECK-NEXT: ret { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } [[TMP0]]
33+
//
34+
// CPP-CHECK-LABEL: define dso_local { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } @_Z19test_luti4_zt_s8_x411svuint8x2_t(
35+
// CPP-CHECK-SAME: <vscale x 16 x i8> [[OP_COERCE0:%.*]], <vscale x 16 x i8> [[OP_COERCE1:%.*]]) #[[ATTR0]] {
36+
// CPP-CHECK-NEXT: [[ENTRY:.*:]]
37+
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } @llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0, <vscale x 16 x i8> [[OP_COERCE0]], <vscale x 16 x i8> [[OP_COERCE1]])
38+
// CPP-CHECK-NEXT: ret { <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8>, <vscale x 16 x i8> } [[TMP0]]
39+
//
40+
svint8x4_t test_luti4_zt_s8_x4(svuint8x2_t op) __arm_streaming __arm_in("zt0") {
41+
return svluti4_zt_s8_x4(0, op);
42+
}

clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_imm.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,8 @@ void test_svdot_multi_za32_bad_lane(uint32_t slice_base, svuint16_t z_u16,
350350
svsudot_lane_za32_s8_vg1x2(slice_base, z_s8x2, z_u8, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
351351
svsudot_lane_za32_s8_vg1x4(slice_base, z_s8x4, z_u8, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
352352
}
353+
354+
void test_luti4_zt_x4(svuint8x2_t op) __arm_streaming __arm_in("zt0") {
355+
// Check Zt tile 0
356+
svluti4_zt_u8_x4(1, op); // expected-error {{argument value 1 is outside the valid range [0, 0]}}
357+
}

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "sanitizer_errno.h"
4242
#include "sanitizer_placement_new.h"
4343
#include "sanitizer_platform_interceptors.h"
44+
#include "sanitizer_platform_limits_posix.h"
4445
#include "sanitizer_symbolizer.h"
4546
#include "sanitizer_tls_get_addr.h"
4647

@@ -3473,23 +3474,27 @@ INTERCEPTOR(uptr, ptrace, int request, int pid, void *addr, void *data) {
34733474
COMMON_INTERCEPTOR_ENTER(ctx, ptrace, request, pid, addr, data);
34743475
__sanitizer_iovec local_iovec;
34753476

3476-
if (data) {
3477+
void *data_arg = ptrace_data_arg(request, addr, data);
3478+
if (data_arg) {
34773479
if (request == ptrace_setregs) {
3478-
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_regs_struct_sz);
3480+
COMMON_INTERCEPTOR_READ_RANGE(ctx, data_arg, struct_user_regs_struct_sz);
34793481
} else if (request == ptrace_setfpregs) {
3480-
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_fpregs_struct_sz);
3482+
COMMON_INTERCEPTOR_READ_RANGE(ctx, data_arg,
3483+
struct_user_fpregs_struct_sz);
34813484
} else if (request == ptrace_setfpxregs) {
3482-
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_fpxregs_struct_sz);
3485+
COMMON_INTERCEPTOR_READ_RANGE(ctx, data_arg,
3486+
struct_user_fpxregs_struct_sz);
34833487
} else if (request == ptrace_setvfpregs) {
3484-
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_vfpregs_struct_sz);
3488+
COMMON_INTERCEPTOR_READ_RANGE(ctx, data_arg,
3489+
struct_user_vfpregs_struct_sz);
34853490
} else if (request == ptrace_setsiginfo) {
3486-
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, siginfo_t_sz);
3491+
COMMON_INTERCEPTOR_READ_RANGE(ctx, data_arg, siginfo_t_sz);
34873492

3488-
// Some kernel might zero the iovec::iov_base in case of invalid
3489-
// write access. In this case copy the invalid address for further
3490-
// inspection.
3493+
// Some kernel might zero the iovec::iov_base in case of invalid
3494+
// write access. In this case copy the invalid address for further
3495+
// inspection.
34913496
} else if (request == ptrace_setregset || request == ptrace_getregset) {
3492-
__sanitizer_iovec *iovec = (__sanitizer_iovec*)data;
3497+
__sanitizer_iovec *iovec = (__sanitizer_iovec *)data_arg;
34933498
COMMON_INTERCEPTOR_READ_RANGE(ctx, iovec, sizeof(*iovec));
34943499
local_iovec = *iovec;
34953500
if (request == ptrace_setregset)
@@ -3502,23 +3507,26 @@ INTERCEPTOR(uptr, ptrace, int request, int pid, void *addr, void *data) {
35023507
// https://github.com/google/sanitizers/issues/321.
35033508
uptr res = REAL(ptrace)(request, pid, addr, data);
35043509

3505-
if (!res && data) {
3510+
if (!res && data_arg) {
35063511
// Note that PEEK* requests assign different meaning to the return value.
35073512
// This function does not handle them (nor does it need to).
35083513
if (request == ptrace_getregs) {
3509-
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_regs_struct_sz);
3514+
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data_arg, struct_user_regs_struct_sz);
35103515
} else if (request == ptrace_getfpregs) {
3511-
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_fpregs_struct_sz);
3516+
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data_arg,
3517+
struct_user_fpregs_struct_sz);
35123518
} else if (request == ptrace_getfpxregs) {
3513-
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_fpxregs_struct_sz);
3519+
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data_arg,
3520+
struct_user_fpxregs_struct_sz);
35143521
} else if (request == ptrace_getvfpregs) {
3515-
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_vfpregs_struct_sz);
3522+
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data_arg,
3523+
struct_user_vfpregs_struct_sz);
35163524
} else if (request == ptrace_getsiginfo) {
3517-
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, siginfo_t_sz);
3525+
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data_arg, siginfo_t_sz);
35183526
} else if (request == ptrace_geteventmsg) {
3519-
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, sizeof(unsigned long));
3527+
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data_arg, sizeof(unsigned long));
35203528
} else if (request == ptrace_getregset) {
3521-
__sanitizer_iovec *iovec = (__sanitizer_iovec*)data;
3529+
__sanitizer_iovec *iovec = (__sanitizer_iovec *)data_arg;
35223530
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, iovec, sizeof(*iovec));
35233531
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, local_iovec.iov_base,
35243532
local_iovec.iov_len);

0 commit comments

Comments
 (0)