Skip to content

Commit 58a9fad

Browse files
committed
Merge branch 'sycl' of https://github.com/intel/llvm into ij30862
2 parents 16f8991 + 0d3cc99 commit 58a9fad

File tree

3,802 files changed

+163569
-56445
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,802 files changed

+163569
-56445
lines changed

.github/workflows/linux_post_commit.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- sycl
77
jobs:
88
check:
9-
runs-on: ubuntu-18.04
9+
runs-on: ubuntu-20.04
1010
if: github.repository == 'intel/llvm'
1111
strategy:
1212
fail-fast: false
@@ -18,7 +18,15 @@ jobs:
1818
with:
1919
path: src
2020
- name: Install Ubuntu deps
21-
run: sudo apt install -y ninja-build
21+
run: sudo apt install -y ninja-build ccache
22+
- name: Setup Cache
23+
uses: actions/cache@v2
24+
id: cache
25+
with:
26+
path: ${{ github.workspace }}/cache
27+
key: build-${{ runner.os }}-${{ matrix.config }}-${{ github.sha }}
28+
restore-keys: |
29+
build-${{ runner.os }}-${{ matrix.config }}-
2230
- name: Configure
2331
run: |
2432
CONFIG=${{ matrix.config }}
@@ -28,12 +36,12 @@ jobs:
2836
;;
2937
SharedLibs)
3038
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
31-
sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main"
39+
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"
3240
sudo apt-get update
33-
sudo apt-get install -y clang-12
41+
sudo apt-get install -y clang-13
3442
export ARGS="--shared-libs"
35-
export CC="clang-12"
36-
export CXX="clang++-12"
43+
export CC="clang-13"
44+
export CXX="clang++-13"
3745
;;
3846
NoAssertions)
3947
export ARGS="--no-assertions"
@@ -42,7 +50,10 @@ jobs:
4250
mkdir -p $GITHUB_WORKSPACE/build
4351
cd $GITHUB_WORKSPACE/build
4452
python3 $GITHUB_WORKSPACE/src/buildbot/configure.py -w $GITHUB_WORKSPACE \
45-
-s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t Release $ARGS
53+
-s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t Release \
54+
--ci-defaults $ARGS --cmake-opt="-DLLVM_CCACHE_BUILD=ON" \
55+
--cmake-opt="-DLLVM_CCACHE_DIR=$GITHUB_WORKSPACE/cache" \
56+
--cmake-opt="-DLLVM_CCACHE_MAXSIZE=2G"
4657
- name: Compile
4758
run: |
4859
python3 $GITHUB_WORKSPACE/src/buildbot/compile.py -w $GITHUB_WORKSPACE \
@@ -74,4 +85,3 @@ jobs:
7485
with:
7586
name: sycl_linux_${{ matrix.config }}
7687
path: llvm_sycl.tar.gz
77-

buildbot/configure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ def do_configure(args):
4141

4242
sycl_enable_xpti_tracing = 'ON'
4343

44+
if args.ci_defaults:
45+
print("#############################################")
46+
print("# Default CI configuration will be applied. #")
47+
print("#############################################")
48+
4449
# replace not append, so ARM ^ X86
4550
if args.arm:
4651
llvm_targets_to_build = 'ARM;AArch64'
@@ -193,6 +198,7 @@ def main():
193198
parser.add_argument("--libcxx-library", metavar="LIBCXX_LIBRARY_PATH", help="libcxx library path")
194199
parser.add_argument("--use-lld", action="store_true", help="Use LLD linker for build")
195200
parser.add_argument("--llvm-external-projects", help="Add external projects to build. Add as comma seperated list.")
201+
parser.add_argument("--ci-defaults", action="store_true", help="Enable default CI parameters")
196202
args = parser.parse_args()
197203

198204
print("args:{}".format(args))

buildbot/dependency.conf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ ocl_cpu_rt_ver=2021.12.6.0.19
44
# https://github.com/intel/llvm/releases/download/2021-WW26/win-oclcpuexp-2021.12.6.0.19_rel.zip
55
ocl_cpu_rt_ver_win=2021.12.6.0.19
66
# Same GPU driver supports Level Zero and OpenCL
7-
# https://github.com/intel/compute-runtime/releases/tag/21.34.20767
8-
ocl_gpu_rt_ver=21.34.20767
7+
# https://github.com/intel/compute-runtime/releases/tag/21.37.20939
8+
ocl_gpu_rt_ver=21.37.20939
99
# Same GPU driver supports Level Zero and OpenCL
10-
# https://downloadmirror.intel.com/646152/igfx_win_100.9805.zip
11-
ocl_gpu_rt_ver_win=30.0.100.9805
10+
# https://downloadmirror.intel.com/648245/igfx_win_100.9864.zip
11+
ocl_gpu_rt_ver_win=30.0.100.9864
1212
intel_sycl_ver=build
1313

1414
# TBB binaries can be built from sources following instructions under
@@ -30,8 +30,8 @@ ocloc_ver_win=27.20.100.9168
3030
[DRIVER VERSIONS]
3131
cpu_driver_lin=2021.12.6.0.19
3232
cpu_driver_win=2021.12.6.0.19
33-
gpu_driver_lin=21.34.20767
34-
gpu_driver_win=30.0.100.9805
33+
gpu_driver_lin=21.37.20939
34+
gpu_driver_win=30.0.100.9864
3535
fpga_driver_lin=2021.12.6.0.19
3636
fpga_driver_win=2021.12.6.0.19
3737
# NVidia CUDA driver

clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,11 @@ AST_POLYMORPHIC_MATCHER(
4747
if (PrefixPosition == StringRef::npos)
4848
return false;
4949
Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
50-
static const char *AbseilLibraries[] = {"algorithm", "base",
51-
"container", "debugging",
52-
"flags", "hash",
53-
"iterator", "memory",
54-
"meta", "numeric",
55-
"random", "status",
56-
"strings", "synchronization",
57-
"time", "types",
58-
"utility"};
50+
static const char *AbseilLibraries[] = {
51+
"algorithm", "base", "container", "debugging", "flags",
52+
"hash", "iterator", "memory", "meta", "numeric",
53+
"profiling", "random", "status", "strings", "synchronization",
54+
"time", "types", "utility"};
5955
return llvm::any_of(AbseilLibraries, [&](const char *Library) {
6056
return Path.startswith(Library);
6157
});

clang-tools-extra/clang-tidy/add_new_check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#===-----------------------------------------------------------------------===#
1010

1111
from __future__ import print_function
12+
from __future__ import unicode_literals
1213

1314
import argparse
1415
import io

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ static bool isVarThatIsPossiblyChanged(const Decl *Func, const Stmt *LoopStmt,
6565
ObjCIvarRefExpr, ObjCPropertyRefExpr, ObjCMessageExpr>(Cond)) {
6666
// FIXME: Handle MemberExpr.
6767
return true;
68+
} else if (const auto *CE = dyn_cast<CastExpr>(Cond)) {
69+
QualType T = CE->getType();
70+
while (true) {
71+
if (T.isVolatileQualified())
72+
return true;
73+
74+
if (!T->isAnyPointerType() && !T->isReferenceType())
75+
break;
76+
77+
T = T->getPointeeType();
78+
}
6879
}
6980

7081
return false;

clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
2626
ProTypeVarargCheck.cpp
2727
SlicingCheck.cpp
2828
SpecialMemberFunctionsCheck.cpp
29+
VirtualClassDestructorCheck.cpp
2930

3031
LINK_LIBS
3132
clangTidy

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "ProTypeVarargCheck.h"
3636
#include "SlicingCheck.h"
3737
#include "SpecialMemberFunctionsCheck.h"
38+
#include "VirtualClassDestructorCheck.h"
3839

3940
namespace clang {
4041
namespace tidy {
@@ -94,6 +95,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
9495
CheckFactories.registerCheck<SlicingCheck>("cppcoreguidelines-slicing");
9596
CheckFactories.registerCheck<misc::UnconventionalAssignOperatorCheck>(
9697
"cppcoreguidelines-c-copy-assignment-signature");
98+
CheckFactories.registerCheck<VirtualClassDestructorCheck>(
99+
"cppcoreguidelines-virtual-class-destructor");
97100
}
98101

99102
ClangTidyOptions getModuleOptions() override {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static bool isSafeAssignment(const FieldDecl *Field, const Expr *Init,
8383
.empty();
8484
}
8585

86-
static const std::pair<const FieldDecl *, const Expr *>
86+
static std::pair<const FieldDecl *, const Expr *>
8787
isAssignmentToMemberOf(const CXXRecordDecl *Rec, const Stmt *S,
8888
const CXXConstructorDecl *Ctor) {
8989
if (const auto *BO = dyn_cast<BinaryOperator>(S)) {
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
//===--- VirtualClassDestructorCheck.cpp - clang-tidy -----------------===//
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+
#include "VirtualClassDestructorCheck.h"
10+
#include "../utils/LexerUtils.h"
11+
#include "clang/AST/ASTContext.h"
12+
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/Lex/Lexer.h"
14+
#include <string>
15+
16+
using namespace clang::ast_matchers;
17+
18+
namespace clang {
19+
namespace tidy {
20+
namespace cppcoreguidelines {
21+
22+
void VirtualClassDestructorCheck::registerMatchers(MatchFinder *Finder) {
23+
ast_matchers::internal::Matcher<CXXRecordDecl> InheritsVirtualMethod =
24+
hasAnyBase(hasType(cxxRecordDecl(has(cxxMethodDecl(isVirtual())))));
25+
26+
Finder->addMatcher(
27+
cxxRecordDecl(
28+
anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod),
29+
unless(anyOf(
30+
has(cxxDestructorDecl(isPublic(), isVirtual())),
31+
has(cxxDestructorDecl(isProtected(), unless(isVirtual()))))))
32+
.bind("ProblematicClassOrStruct"),
33+
this);
34+
}
35+
36+
static CharSourceRange
37+
getVirtualKeywordRange(const CXXDestructorDecl &Destructor,
38+
const SourceManager &SM, const LangOptions &LangOpts) {
39+
SourceLocation VirtualBeginLoc = Destructor.getBeginLoc();
40+
SourceLocation VirtualEndLoc = VirtualBeginLoc.getLocWithOffset(
41+
Lexer::MeasureTokenLength(VirtualBeginLoc, SM, LangOpts));
42+
43+
/// Range ends with \c StartOfNextToken so that any whitespace after \c
44+
/// virtual is included.
45+
SourceLocation StartOfNextToken =
46+
Lexer::findNextToken(VirtualEndLoc, SM, LangOpts)
47+
.getValue()
48+
.getLocation();
49+
50+
return CharSourceRange::getCharRange(VirtualBeginLoc, StartOfNextToken);
51+
}
52+
53+
static const AccessSpecDecl *
54+
getPublicASDecl(const CXXRecordDecl &StructOrClass) {
55+
for (DeclContext::specific_decl_iterator<AccessSpecDecl>
56+
AS{StructOrClass.decls_begin()},
57+
ASEnd{StructOrClass.decls_end()};
58+
AS != ASEnd; ++AS) {
59+
AccessSpecDecl *ASDecl = *AS;
60+
if (ASDecl->getAccess() == AccessSpecifier::AS_public)
61+
return ASDecl;
62+
}
63+
64+
return nullptr;
65+
}
66+
67+
static FixItHint
68+
generateUserDeclaredDestructor(const CXXRecordDecl &StructOrClass,
69+
const SourceManager &SourceManager) {
70+
std::string DestructorString;
71+
SourceLocation Loc;
72+
bool AppendLineBreak = false;
73+
74+
const AccessSpecDecl *AccessSpecDecl = getPublicASDecl(StructOrClass);
75+
76+
if (!AccessSpecDecl) {
77+
if (StructOrClass.isClass()) {
78+
Loc = StructOrClass.getEndLoc();
79+
DestructorString = "public:";
80+
AppendLineBreak = true;
81+
} else {
82+
Loc = StructOrClass.getBraceRange().getBegin().getLocWithOffset(1);
83+
}
84+
} else {
85+
Loc = AccessSpecDecl->getEndLoc().getLocWithOffset(1);
86+
}
87+
88+
DestructorString = (llvm::Twine(DestructorString) + "\nvirtual ~" +
89+
StructOrClass.getName().str() + "() = default;" +
90+
(AppendLineBreak ? "\n" : ""))
91+
.str();
92+
93+
return FixItHint::CreateInsertion(Loc, DestructorString);
94+
}
95+
96+
static std::string getSourceText(const CXXDestructorDecl &Destructor) {
97+
std::string SourceText;
98+
llvm::raw_string_ostream DestructorStream(SourceText);
99+
Destructor.print(DestructorStream);
100+
return SourceText;
101+
}
102+
103+
static std::string eraseKeyword(std::string &DestructorString,
104+
const std::string &Keyword) {
105+
size_t KeywordIndex = DestructorString.find(Keyword);
106+
if (KeywordIndex != std::string::npos)
107+
DestructorString.erase(KeywordIndex, Keyword.length());
108+
return DestructorString;
109+
}
110+
111+
static FixItHint changePrivateDestructorVisibilityTo(
112+
const std::string &Visibility, const CXXDestructorDecl &Destructor,
113+
const SourceManager &SM, const LangOptions &LangOpts) {
114+
std::string DestructorString =
115+
(llvm::Twine() + Visibility + ":\n" +
116+
(Visibility == "public" && !Destructor.isVirtual() ? "virtual " : ""))
117+
.str();
118+
119+
std::string OriginalDestructor = getSourceText(Destructor);
120+
if (Visibility == "protected" && Destructor.isVirtualAsWritten())
121+
OriginalDestructor = eraseKeyword(OriginalDestructor, "virtual ");
122+
123+
DestructorString =
124+
(llvm::Twine(DestructorString) + OriginalDestructor +
125+
(Destructor.isExplicitlyDefaulted() ? ";\n" : "") + "private:")
126+
.str();
127+
128+
/// Semicolons ending an explicitly defaulted destructor have to be deleted.
129+
/// Otherwise, the left-over semicolon trails the \c private: access
130+
/// specifier.
131+
SourceLocation EndLocation;
132+
if (Destructor.isExplicitlyDefaulted())
133+
EndLocation =
134+
utils::lexer::findNextTerminator(Destructor.getEndLoc(), SM, LangOpts)
135+
.getLocWithOffset(1);
136+
else
137+
EndLocation = Destructor.getEndLoc().getLocWithOffset(1);
138+
139+
auto OriginalDestructorRange =
140+
CharSourceRange::getCharRange(Destructor.getBeginLoc(), EndLocation);
141+
return FixItHint::CreateReplacement(OriginalDestructorRange,
142+
DestructorString);
143+
}
144+
145+
void VirtualClassDestructorCheck::check(
146+
const MatchFinder::MatchResult &Result) {
147+
148+
const auto *MatchedClassOrStruct =
149+
Result.Nodes.getNodeAs<CXXRecordDecl>("ProblematicClassOrStruct");
150+
151+
const CXXDestructorDecl *Destructor = MatchedClassOrStruct->getDestructor();
152+
if (!Destructor)
153+
return;
154+
155+
if (Destructor->getAccess() == AccessSpecifier::AS_private) {
156+
diag(MatchedClassOrStruct->getLocation(),
157+
"destructor of %0 is private and prevents using the type")
158+
<< MatchedClassOrStruct;
159+
diag(MatchedClassOrStruct->getLocation(),
160+
/*FixDescription=*/"make it public and virtual", DiagnosticIDs::Note)
161+
<< changePrivateDestructorVisibilityTo(
162+
"public", *Destructor, *Result.SourceManager, getLangOpts());
163+
diag(MatchedClassOrStruct->getLocation(),
164+
/*FixDescription=*/"make it protected", DiagnosticIDs::Note)
165+
<< changePrivateDestructorVisibilityTo(
166+
"protected", *Destructor, *Result.SourceManager, getLangOpts());
167+
168+
return;
169+
}
170+
171+
// Implicit destructors are public and non-virtual for classes and structs.
172+
bool ProtectedAndVirtual = false;
173+
FixItHint Fix;
174+
175+
if (MatchedClassOrStruct->hasUserDeclaredDestructor()) {
176+
if (Destructor->getAccess() == AccessSpecifier::AS_public) {
177+
Fix = FixItHint::CreateInsertion(Destructor->getLocation(), "virtual ");
178+
} else if (Destructor->getAccess() == AccessSpecifier::AS_protected) {
179+
ProtectedAndVirtual = true;
180+
Fix = FixItHint::CreateRemoval(getVirtualKeywordRange(
181+
*Destructor, *Result.SourceManager, Result.Context->getLangOpts()));
182+
}
183+
} else {
184+
Fix = generateUserDeclaredDestructor(*MatchedClassOrStruct,
185+
*Result.SourceManager);
186+
}
187+
188+
diag(MatchedClassOrStruct->getLocation(),
189+
"destructor of %0 is %select{public and non-virtual|protected and "
190+
"virtual}1")
191+
<< MatchedClassOrStruct << ProtectedAndVirtual;
192+
diag(MatchedClassOrStruct->getLocation(),
193+
"make it %select{public and virtual|protected and non-virtual}0",
194+
DiagnosticIDs::Note)
195+
<< ProtectedAndVirtual << Fix;
196+
}
197+
198+
} // namespace cppcoreguidelines
199+
} // namespace tidy
200+
} // namespace clang

0 commit comments

Comments
 (0)