Skip to content

Commit 6985a64

Browse files
Merge branch 'sycl' of https://github.com/intel/llvm into esimdcpu_kernel_launch_memory_intrinsic
2 parents c1e6f9c + df1ff7a commit 6985a64

File tree

3,437 files changed

+208088
-241602
lines changed

Some content is hidden

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

3,437 files changed

+208088
-241602
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sycl/ @intel/llvm-reviewers-runtime
2525
sycl/ReleaseNotes.md @pvchupin @tfzhu
2626
sycl/doc/ @pvchupin @bader
2727
sycl/doc/extensions/ @intel/dpcpp-specification-reviewers
28-
sycl/doc/SPIRV @AlexeySotkin @bashbaug @mbelicki
28+
sycl/doc/extensions/SPIRV/ @AlexeySotkin @bashbaug @mbelicki
2929

3030
# Sub-groups
3131
sycl/include/CL/sycl/detail/spirv.hpp @Pennycook @AlexeySachkov

.mailmap

Lines changed: 1 addition & 0 deletions

CONTRIBUTING.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,37 @@ Every product change should be accompanied with corresponding test modification
6262
(adding new test(s), extending, removing or modifying existing test(s)).
6363

6464
There are 3 types of tests which are used for DPC++ toolchain validation:
65-
* DPC++ in-tree LIT tests including [check-llvm](../../llvm/test),
66-
[check-clang](../../clang/test), [check-llvm-spirv](../../llvm-spirv/test) and
67-
[check-sycl](../../sycl/test) targets stored in this repository. These tests
65+
* DPC++ in-tree tests including [check-llvm](llvm/test),
66+
[check-clang](clang/test), [check-llvm-spirv](llvm-spirv/test) and
67+
[check-sycl](sycl/test) targets stored in this repository. These tests
6868
should not have hardware (e.g. GPU, FPGA, etc.) or external software
6969
dependencies (e.g. OpenCL, Level Zero, CUDA runtimes). All tests not following
7070
this approach should be moved to DPC++ end-to-end or SYCL-CTS tests.
71+
Generally, any functional change to any of the DPC++ toolchain components
72+
should be accompanied by one or more tests of this type when possible. They
73+
allow verifying individual components and tend to be more lightweight than
74+
end-to-end or SYCL-CTS tests.
75+
76+
**General guidelines for adding DPC++ in-tree tests**:
7177

72-
**Guidelines for adding DPC++ in-tree LIT tests (DPC++ Clang FE tests)**:
7378
- Use `sycl::` namespace instead of `cl::sycl::`
7479

80+
- Add a helpful comment describing what the test does at the beginning and
81+
other comments throughout the test as necessary.
82+
83+
- Try to follow descriptive naming convention for variables, functions as
84+
much as possible.
85+
Please refer to
86+
[LLVM naming convention](https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly)
87+
88+
**DPC++ clang FE tests**:
89+
7590
- Include sycl mock headers as system headers.
7691
Example: `-internal-isystem %S/Inputs`
7792
`#include "sycl.hpp"`
7893

79-
- Use SYCL functions for invoking kernels from the mock header `(single_task, parallel_for, parallel_for_work_group)`
94+
- Use SYCL functions for invoking kernels from the mock header
95+
`(single_task, parallel_for, parallel_for_work_group)`
8096
Example:
8197
```bash
8298
`#include "Inputs/sycl.hpp"`
@@ -86,10 +102,14 @@ this approach should be moved to DPC++ end-to-end or SYCL-CTS tests.
86102
});
87103
```
88104
89-
- Add a helpful comment describing what the test does at the beginning and other comments throughout the test as necessary.
105+
**DPC++ headers and runtime tests**:
90106
91-
- Try to follow descriptive naming convention for variables, functions as much as possible.
92-
Please refer [LLVM naming convention](https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly)
107+
- [check-sycl](sycl/test) target contains 2 types of tests: LIT tests and
108+
unit tests. LIT tests make compile-time checks of DPC++ headers, e.g. device
109+
code IR verification, static_assert tests. Unit tests check DPC++ runtime
110+
behavior and do not perform any device code compilation, instead relying on
111+
redefining plugin API with [PiMock](sycl/unittests/helpers/PiMock.hpp) when
112+
necessary.
93113
94114
* DPC++ end-to-end (E2E) tests which are extension to
95115
[LLVM\* test suite](https://github.com/intel/llvm-test-suite/tree/intel/SYCL).

clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ AST_MATCHER(Decl, isFromStdNamespaceOrSystemHeader) {
2424
if (const auto *D = Node.getDeclContext()->getEnclosingNamespaceContext())
2525
if (D->isStdNamespace())
2626
return true;
27+
if (Node.getLocation().isInvalid())
28+
return false;
2729
return Node.getASTContext().getSourceManager().isInSystemHeader(
2830
Node.getLocation());
2931
}

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
106106
Opts["cppcoreguidelines-non-private-member-variables-in-classes."
107107
"IgnoreClassesWithAllMemberVariablesBeingPublic"] = "true";
108108

109-
Opts["cppcoreguidelines-explicit-virtual-functions."
110-
"IgnoreDestructors"] = "true";
111-
112109
return Options;
113110
}
114111
};

clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,29 @@ namespace clang {
1919
namespace tidy {
2020
namespace cppcoreguidelines {
2121

22+
AST_MATCHER(CXXRecordDecl, hasPublicVirtualOrProtectedNonVirtualDestructor) {
23+
// We need to call Node.getDestructor() instead of matching a
24+
// CXXDestructorDecl. Otherwise, tests will fail for class templates, since
25+
// the primary template (not the specialization) always gets a non-virtual
26+
// CXXDestructorDecl in the AST. https://bugs.llvm.org/show_bug.cgi?id=51912
27+
const CXXDestructorDecl *Destructor = Node.getDestructor();
28+
if (!Destructor)
29+
return false;
30+
31+
return (((Destructor->getAccess() == AccessSpecifier::AS_public) &&
32+
Destructor->isVirtual()) ||
33+
((Destructor->getAccess() == AccessSpecifier::AS_protected) &&
34+
!Destructor->isVirtual()));
35+
}
36+
2237
void VirtualClassDestructorCheck::registerMatchers(MatchFinder *Finder) {
2338
ast_matchers::internal::Matcher<CXXRecordDecl> InheritsVirtualMethod =
2439
hasAnyBase(hasType(cxxRecordDecl(has(cxxMethodDecl(isVirtual())))));
2540

2641
Finder->addMatcher(
2742
cxxRecordDecl(
2843
anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod),
29-
unless(anyOf(
30-
has(cxxDestructorDecl(isPublic(), isVirtual())),
31-
has(cxxDestructorDecl(isProtected(), unless(isVirtual()))))))
44+
unless(hasPublicVirtualOrProtectedNonVirtualDestructor()))
3245
.bind("ProblematicClassOrStruct"),
3346
this);
3447
}

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ struct TargetFinder {
507507
// DeclRefExpr).
508508
if (Arg.getKind() == TemplateArgument::Template ||
509509
Arg.getKind() == TemplateArgument::TemplateExpansion) {
510-
if (TemplateDecl *TD = Arg.getAsTemplate().getAsTemplateDecl()) {
510+
if (TemplateDecl *TD =
511+
Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) {
511512
report(TD, Flags);
512513
}
513514
}

clang-tools-extra/clangd/IncludeCleaner.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,15 @@ struct ReferencedFiles {
121121
if (!Macros.insert(FID).second)
122122
return;
123123
const auto &Exp = SM.getSLocEntry(FID).getExpansion();
124-
add(Exp.getSpellingLoc());
125-
add(Exp.getExpansionLocStart());
126-
add(Exp.getExpansionLocEnd());
124+
// For token pasting operator in macros, spelling and expansion locations
125+
// can be within a temporary buffer that Clang creates (scratch space or
126+
// ScratchBuffer). That is not a real file we can include.
127+
if (!SM.isWrittenInScratchSpace(Exp.getSpellingLoc()))
128+
add(Exp.getSpellingLoc());
129+
if (!SM.isWrittenInScratchSpace(Exp.getExpansionLocStart()))
130+
add(Exp.getExpansionLocStart());
131+
if (!SM.isWrittenInScratchSpace(Exp.getExpansionLocEnd()))
132+
add(Exp.getExpansionLocEnd());
127133
}
128134
};
129135

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,15 @@ TEST_F(TargetDeclTest, Types) {
341341
EXPECT_DECLS("TemplateSpecializationTypeLoc", "template <typename> class T");
342342
Flags.clear();
343343

344+
Code = R"cpp(
345+
template<template<typename> class ...T>
346+
class C {
347+
C<[[T...]]> foo;
348+
};
349+
)cpp";
350+
EXPECT_DECLS("TemplateArgumentLoc", {"template <typename> class ...T"});
351+
Flags.clear();
352+
344353
Code = R"cpp(
345354
struct S{};
346355
S X;

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,47 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
167167
UnorderedElementsAre("\"unused.h\"", "\"dir/unused.h\""));
168168
}
169169

170+
TEST(IncludeCleaner, ScratchBuffer) {
171+
TestTU TU;
172+
TU.Filename = "foo.cpp";
173+
TU.Code = R"cpp(
174+
#include "macro_spelling_in_scratch_buffer.h"
175+
176+
using flags::FLAGS_FOO;
177+
178+
int concat(a, b) = 42;
179+
)cpp";
180+
// The pasting operator in combination with DEFINE_FLAG will create
181+
// ScratchBuffer with `flags::FLAGS_FOO` that will have FileID but not
182+
// FileEntry.
183+
TU.AdditionalFiles["macro_spelling_in_scratch_buffer.h"] = R"cpp(
184+
#define DEFINE_FLAG(X) \
185+
namespace flags { \
186+
int FLAGS_##X; \
187+
} \
188+
189+
DEFINE_FLAG(FOO)
190+
191+
#define ab x
192+
#define concat(x, y) x##y
193+
)cpp";
194+
ParsedAST AST = TU.build();
195+
auto &SM = AST.getSourceManager();
196+
auto &Includes = AST.getIncludeStructure();
197+
auto ReferencedFiles = findReferencedFiles(findReferencedLocations(AST), SM);
198+
auto Entry = SM.getFileManager().getFile(
199+
testPath("macro_spelling_in_scratch_buffer.h"));
200+
ASSERT_TRUE(Entry);
201+
auto FID = SM.translateFile(*Entry);
202+
// No "<scratch space>" FID.
203+
EXPECT_THAT(ReferencedFiles, UnorderedElementsAre(FID));
204+
// Should not crash due to <scratch space> "files" missing from include
205+
// structure.
206+
EXPECT_THAT(
207+
getUnused(Includes, translateToHeaderIDs(ReferencedFiles, Includes, SM)),
208+
::testing::IsEmpty());
209+
}
210+
170211
} // namespace
171212
} // namespace clangd
172213
} // namespace clang

0 commit comments

Comments
 (0)