Skip to content

Commit 8803fb9

Browse files
authored
Merge branch 'sycl' into update_configure_script
2 parents acddc8b + 9de1a48 commit 8803fb9

File tree

1,898 files changed

+73784
-27508
lines changed

Some content is hidden

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

1,898 files changed

+73784
-27508
lines changed

.github/workflows/linux_post_commit.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
config: ["Default", "SharedLibs", "Assertions"]
13+
config: ["Default", "SharedLibs", "NoAssertions"]
1414

1515
steps:
1616
- uses: actions/checkout@v2
@@ -28,8 +28,8 @@ jobs:
2828
SharedLibs)
2929
export ARGS="--shared-libs"
3030
;;
31-
Assertiosn)
32-
export ARGS="--assertions"
31+
NoAssertions)
32+
export ARGS="--no-assertions"
3333
;;
3434
esac
3535
mkdir -p $GITHUB_WORKSPACE/build

buildbot/compile.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import argparse
2-
import os
2+
import multiprocessing
33
import subprocess
44
import sys
55

66
DEFAULT_CPU_COUNT = 4
77

88

99
def do_compile(args):
10-
cpu_count = os.cpu_count()
11-
if cpu_count is None:
10+
try:
11+
cpu_count = multiprocessing.cpu_count()
12+
except NotImplementedError:
1213
cpu_count = DEFAULT_CPU_COUNT
1314

1415
make_cmd = ["ninja", "-j", str(cpu_count), "deploy-sycl-toolchain", "deploy-opencl-aot"]

buildbot/configure.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def do_configure(args):
4646
if args.no_werror:
4747
sycl_werror = 'OFF'
4848

49-
if args.assertions:
50-
llvm_enable_assertions = 'ON'
49+
if args.no_assertions:
50+
llvm_enable_assertions = 'OFF'
5151

5252
if args.docs:
5353
llvm_enable_doxygen = 'ON'
@@ -122,7 +122,7 @@ def main():
122122
parser.add_argument("-t", "--build-type",
123123
metavar="BUILD_TYPE", required=True, help="build type, debug or release")
124124
parser.add_argument("--cuda", action='store_true', help="switch from OpenCL to CUDA")
125-
parser.add_argument("--assertions", action='store_true', help="build with assertions")
125+
parser.add_argument("--no-assertions", action='store_true', help="build without assertions")
126126
parser.add_argument("--docs", action='store_true', help="build Doxygen documentation")
127127
parser.add_argument("--system-ocl", action='store_true', help="use OpenCL deps from system (no download)")
128128
parser.add_argument("--no-werror", action='store_true', help="Don't treat warnings as errors")

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

+15-7
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,26 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
143143
llvm::DenseMap<const FileEntry *, std::vector<tooling::Replacement>>
144144
GroupedReplacements;
145145

146-
// Deduplicate identical replacements in diagnostics.
146+
// Deduplicate identical replacements in diagnostics unless they are from the
147+
// same TU.
147148
// FIXME: Find an efficient way to deduplicate on diagnostics level.
148-
llvm::DenseMap<const FileEntry *, std::set<tooling::Replacement>>
149+
llvm::DenseMap<const FileEntry *,
150+
std::map<tooling::Replacement,
151+
const tooling::TranslationUnitDiagnostics *>>
149152
DiagReplacements;
150153

151-
auto AddToGroup = [&](const tooling::Replacement &R, bool FromDiag) {
154+
auto AddToGroup = [&](const tooling::Replacement &R,
155+
const tooling::TranslationUnitDiagnostics *SourceTU) {
152156
// Use the file manager to deduplicate paths. FileEntries are
153157
// automatically canonicalized.
154158
if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
155-
if (FromDiag) {
159+
if (SourceTU) {
156160
auto &Replaces = DiagReplacements[*Entry];
157-
if (!Replaces.insert(R).second)
161+
auto It = Replaces.find(R);
162+
if (It == Replaces.end())
163+
Replaces.emplace(R, SourceTU);
164+
else if (It->second != SourceTU)
165+
// This replacement is a duplicate of one suggested by another TU.
158166
return;
159167
}
160168
GroupedReplacements[*Entry].push_back(R);
@@ -166,14 +174,14 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
166174

167175
for (const auto &TU : TUs)
168176
for (const tooling::Replacement &R : TU.Replacements)
169-
AddToGroup(R, false);
177+
AddToGroup(R, nullptr);
170178

171179
for (const auto &TU : TUDs)
172180
for (const auto &D : TU.Diagnostics)
173181
if (const auto *ChoosenFix = tooling::selectFirstFix(D)) {
174182
for (const auto &Fix : *ChoosenFix)
175183
for (const tooling::Replacement &R : Fix.second)
176-
AddToGroup(R, true);
184+
AddToGroup(R, &TU);
177185
}
178186

179187
// Sort replacements per file to keep consistent behavior when

clang-tools-extra/clang-tidy/ClangTidyForceLinker.h

+33-33
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
namespace clang {
1616
namespace tidy {
1717

18-
// This anchor is used to force the linker to link the CERTModule.
19-
extern volatile int CERTModuleAnchorSource;
20-
static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
21-
CERTModuleAnchorSource;
22-
2318
// This anchor is used to force the linker to link the AbseilModule.
2419
extern volatile int AbseilModuleAnchorSource;
2520
static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
2621
AbseilModuleAnchorSource;
2722

23+
// This anchor is used to force the linker to link the AndroidModule.
24+
extern volatile int AndroidModuleAnchorSource;
25+
static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
26+
AndroidModuleAnchorSource;
27+
2828
// This anchor is used to force the linker to link the BoostModule.
2929
extern volatile int BoostModuleAnchorSource;
3030
static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
@@ -35,20 +35,10 @@ extern volatile int BugproneModuleAnchorSource;
3535
static int LLVM_ATTRIBUTE_UNUSED BugproneModuleAnchorDestination =
3636
BugproneModuleAnchorSource;
3737

38-
// This anchor is used to force the linker to link the LinuxKernelModule.
39-
extern volatile int LinuxKernelModuleAnchorSource;
40-
static int LLVM_ATTRIBUTE_UNUSED LinuxKernelModuleAnchorDestination =
41-
LinuxKernelModuleAnchorSource;
42-
43-
// This anchor is used to force the linker to link the LLVMModule.
44-
extern volatile int LLVMModuleAnchorSource;
45-
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
46-
LLVMModuleAnchorSource;
47-
48-
// This anchor is used to force the linker to link the LLVMLibcModule.
49-
extern volatile int LLVMLibcModuleAnchorSource;
50-
static int LLVM_ATTRIBUTE_UNUSED LLVMLibcModuleAnchorDestination =
51-
LLVMLibcModuleAnchorSource;
38+
// This anchor is used to force the linker to link the CERTModule.
39+
extern volatile int CERTModuleAnchorSource;
40+
static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
41+
CERTModuleAnchorSource;
5242

5343
// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
5444
extern volatile int CppCoreGuidelinesModuleAnchorSource;
@@ -70,10 +60,25 @@ extern volatile int GoogleModuleAnchorSource;
7060
static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
7161
GoogleModuleAnchorSource;
7262

73-
// This anchor is used to force the linker to link the AndroidModule.
74-
extern volatile int AndroidModuleAnchorSource;
75-
static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
76-
AndroidModuleAnchorSource;
63+
// This anchor is used to force the linker to link the HICPPModule.
64+
extern volatile int HICPPModuleAnchorSource;
65+
static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
66+
HICPPModuleAnchorSource;
67+
68+
// This anchor is used to force the linker to link the LinuxKernelModule.
69+
extern volatile int LinuxKernelModuleAnchorSource;
70+
static int LLVM_ATTRIBUTE_UNUSED LinuxKernelModuleAnchorDestination =
71+
LinuxKernelModuleAnchorSource;
72+
73+
// This anchor is used to force the linker to link the LLVMModule.
74+
extern volatile int LLVMModuleAnchorSource;
75+
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
76+
LLVMModuleAnchorSource;
77+
78+
// This anchor is used to force the linker to link the LLVMLibcModule.
79+
extern volatile int LLVMLibcModuleAnchorSource;
80+
static int LLVM_ATTRIBUTE_UNUSED LLVMLibcModuleAnchorDestination =
81+
LLVMLibcModuleAnchorSource;
7782

7883
// This anchor is used to force the linker to link the MiscModule.
7984
extern volatile int MiscModuleAnchorSource;
@@ -93,6 +98,11 @@ static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
9398
MPIModuleAnchorSource;
9499
#endif
95100

101+
// This anchor is used to force the linker to link the ObjCModule.
102+
extern volatile int ObjCModuleAnchorSource;
103+
static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
104+
ObjCModuleAnchorSource;
105+
96106
// This anchor is used to force the linker to link the OpenMPModule.
97107
extern volatile int OpenMPModuleAnchorSource;
98108
static int LLVM_ATTRIBUTE_UNUSED OpenMPModuleAnchorDestination =
@@ -113,16 +123,6 @@ extern volatile int ReadabilityModuleAnchorSource;
113123
static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
114124
ReadabilityModuleAnchorSource;
115125

116-
// This anchor is used to force the linker to link the ObjCModule.
117-
extern volatile int ObjCModuleAnchorSource;
118-
static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
119-
ObjCModuleAnchorSource;
120-
121-
// This anchor is used to force the linker to link the HICPPModule.
122-
extern volatile int HICPPModuleAnchorSource;
123-
static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
124-
HICPPModuleAnchorSource;
125-
126126
// This anchor is used to force the linker to link the ZirconModule.
127127
extern volatile int ZirconModuleAnchorSource;
128128
static int LLVM_ATTRIBUTE_UNUSED ZirconModuleAnchorDestination =

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

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "SignedCharMisuseCheck.h"
4242
#include "SizeofContainerCheck.h"
4343
#include "SizeofExpressionCheck.h"
44+
#include "SpuriouslyWakeUpFunctionsCheck.h"
4445
#include "StringConstructorCheck.h"
4546
#include "StringIntegerAssignmentCheck.h"
4647
#include "StringLiteralWithEmbeddedNulCheck.h"
@@ -133,6 +134,8 @@ class BugproneModule : public ClangTidyModule {
133134
"bugprone-sizeof-container");
134135
CheckFactories.registerCheck<SizeofExpressionCheck>(
135136
"bugprone-sizeof-expression");
137+
CheckFactories.registerCheck<SpuriouslyWakeUpFunctionsCheck>(
138+
"bugprone-spuriously-wake-up-functions");
136139
CheckFactories.registerCheck<StringConstructorCheck>(
137140
"bugprone-string-constructor");
138141
CheckFactories.registerCheck<StringIntegerAssignmentCheck>(

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

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ add_clang_library(clangTidyBugproneModule
3333
SignedCharMisuseCheck.cpp
3434
SizeofContainerCheck.cpp
3535
SizeofExpressionCheck.cpp
36+
SpuriouslyWakeUpFunctionsCheck.cpp
3637
StringConstructorCheck.cpp
3738
StringIntegerAssignmentCheck.cpp
3839
StringLiteralWithEmbeddedNulCheck.cpp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//===--- SpuriouslyWakeUpFunctionsCheck.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 "SpuriouslyWakeUpFunctionsCheck.h"
10+
#include "clang/AST/ASTContext.h"
11+
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
13+
using namespace clang::ast_matchers;
14+
15+
namespace clang {
16+
namespace tidy {
17+
namespace bugprone {
18+
19+
void SpuriouslyWakeUpFunctionsCheck::registerMatchers(MatchFinder *Finder) {
20+
21+
auto hasUniqueLock = hasDescendant(declRefExpr(
22+
hasDeclaration(varDecl(hasType(recordDecl(classTemplateSpecializationDecl(
23+
hasName("::std::unique_lock"),
24+
hasTemplateArgument(
25+
0, templateArgument(refersToType(qualType(hasDeclaration(
26+
cxxRecordDecl(hasName("::std::mutex"))))))))))))));
27+
28+
auto hasWaitDescendantCPP = hasDescendant(
29+
cxxMemberCallExpr(
30+
anyOf(
31+
allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
32+
allOf(hasName("::std::condition_variable::wait"),
33+
parameterCountIs(1)))))),
34+
onImplicitObjectArgument(
35+
declRefExpr(to(varDecl(hasType(references(recordDecl(
36+
hasName("::std::condition_variable")))))))),
37+
hasUniqueLock),
38+
allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
39+
allOf(hasName("::std::condition_variable::wait_for"),
40+
parameterCountIs(2)))))),
41+
onImplicitObjectArgument(
42+
declRefExpr(to(varDecl(hasType(references(recordDecl(
43+
hasName("::std::condition_variable")))))))),
44+
hasUniqueLock),
45+
allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl(
46+
allOf(hasName("::std::condition_variable::wait_until"),
47+
parameterCountIs(2)))))),
48+
onImplicitObjectArgument(
49+
declRefExpr(to(varDecl(hasType(references(recordDecl(
50+
hasName("::std::condition_variable")))))))),
51+
hasUniqueLock)
52+
53+
))
54+
.bind("wait"));
55+
56+
auto hasWaitDescendantC = hasDescendant(
57+
callExpr(callee(functionDecl(
58+
anyOf(hasName("cnd_wait"), hasName("cnd_timedwait")))))
59+
.bind("wait"));
60+
if (getLangOpts().CPlusPlus) {
61+
// Check for `CON54-CPP`
62+
Finder->addMatcher(
63+
ifStmt(
64+
65+
allOf(hasWaitDescendantCPP,
66+
unless(anyOf(hasDescendant(ifStmt(hasWaitDescendantCPP)),
67+
hasDescendant(whileStmt(hasWaitDescendantCPP)),
68+
hasDescendant(forStmt(hasWaitDescendantCPP)),
69+
hasDescendant(doStmt(hasWaitDescendantCPP)))))
70+
71+
),
72+
this);
73+
} else {
74+
// Check for `CON36-C`
75+
Finder->addMatcher(
76+
77+
ifStmt(
78+
allOf(hasWaitDescendantC,
79+
unless(anyOf(hasDescendant(ifStmt(hasWaitDescendantC)),
80+
hasDescendant(whileStmt(hasWaitDescendantC)),
81+
hasDescendant(forStmt(hasWaitDescendantC)),
82+
hasDescendant(doStmt(hasWaitDescendantC)),
83+
hasParent(whileStmt()),
84+
hasParent(compoundStmt(hasParent(whileStmt()))),
85+
hasParent(forStmt()),
86+
hasParent(compoundStmt(hasParent(forStmt()))),
87+
hasParent(doStmt()),
88+
hasParent(compoundStmt(hasParent(doStmt())))))
89+
90+
))
91+
92+
,
93+
this);
94+
}
95+
}
96+
97+
void SpuriouslyWakeUpFunctionsCheck::check(
98+
const MatchFinder::MatchResult &Result) {
99+
const auto *MatchedWait = Result.Nodes.getNodeAs<CallExpr>("wait");
100+
StringRef WaitName = MatchedWait->getDirectCallee()->getName();
101+
diag(MatchedWait->getExprLoc(),
102+
"'%0' should be placed inside a while statement %select{|or used with a "
103+
"conditional parameter}1")
104+
<< WaitName << (WaitName != "cnd_wait" && WaitName != "cnd_timedwait");
105+
}
106+
} // namespace bugprone
107+
} // namespace tidy
108+
} // namespace clang
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===--- SpuriouslyWakeUpFunctionsCheck.h - clang-tidy ----------*- C++ -*-===//
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+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPURIOUSLYWAKEUPFUNCTIONSCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPURIOUSLYWAKEUPFUNCTIONSCHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace bugprone {
17+
18+
/// Finds ``cnd_wait``, ``cnd_timedwait``, ``wait``, ``wait_for``, or
19+
/// ``wait_until`` function calls when the function is not invoked from a loop
20+
/// that checks whether a condition predicate holds or the function has a
21+
/// condition parameter.
22+
///
23+
/// For the user-facing documentation see:
24+
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-spuriously-wake-up-functions.html
25+
class SpuriouslyWakeUpFunctionsCheck : public ClangTidyCheck {
26+
public:
27+
SpuriouslyWakeUpFunctionsCheck(StringRef Name, ClangTidyContext *Context)
28+
: ClangTidyCheck(Name, Context) {}
29+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
30+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
31+
};
32+
33+
} // namespace bugprone
34+
} // namespace tidy
35+
} // namespace clang
36+
37+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPURIOUSLYWAKEUPFUNCTIONSCHECK_H

0 commit comments

Comments
 (0)