Skip to content

Commit e4ad410

Browse files
committed
Merge remote-tracking branch 'origin/sycl-web' into llvmspirv_pulldown
2 parents fdd609a + d9a9f60 commit e4ad410

File tree

3,403 files changed

+184726
-99831
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,403 files changed

+184726
-99831
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ f84bac329ba6c9f0c022bcf77237e912362e247a
5353
dd3c26a045c081620375a878159f536758baba6e
5454
7bfaa0f09d0564f315ea778023b34b8a113ec740
5555
f98ee40f4b5d7474fc67e82824bf6abbaedb7b1c
56+
2238dcc39358353cac21df75c3c3286ab20b8f53
57+
f9008e6366c2496b1ca1785b891d5578174ad63e

.github/workflows/version-check.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77

88
def get_version_from_tag(tag):
9-
m = re.match('llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$', tag)
9+
m = re.match("llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$", tag)
1010
if m:
1111
if m.lastindex == 4:
1212
# We have an rc tag.
13-
return m.group(1,2,3)
13+
return m.group(1, 2, 3)
1414
# We have a final release tag.
1515
return (m.group(1), m.group(2), str(int(m.group(3)) + 1))
1616

17-
m = re.match('llvmorg-([0-9]+)-init', tag)
17+
m = re.match("llvmorg-([0-9]+)-init", tag)
1818
if m:
1919
return (m.group(1), "0", "0")
2020

@@ -25,8 +25,8 @@ def get_version_from_tag(tag):
2525

2626
repo = Repo()
2727

28-
tag = repo.git.describe(tags = True, abbrev=0)
29-
expected_version = '.'.join(get_version_from_tag(tag))
28+
tag = repo.git.describe(tags=True, abbrev=0)
29+
expected_version = ".".join(get_version_from_tag(tag))
3030

3131
if version != expected_version:
3232
print("error: Expected version", expected_version, "but found version", version)

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ class DataAggregator : public DataReader {
199199
/// execution order.
200200
///
201201
/// Return true if the trace is valid, false otherwise.
202-
bool recordTrace(
203-
BinaryFunction &BF, const LBREntry &First, const LBREntry &Second,
204-
uint64_t Count = 1,
205-
SmallVector<std::pair<uint64_t, uint64_t>, 16> *Branches = nullptr) const;
202+
bool
203+
recordTrace(BinaryFunction &BF, const LBREntry &First, const LBREntry &Second,
204+
uint64_t Count,
205+
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const;
206206

207207
/// Return a vector of offsets corresponding to a trace in a function
208208
/// (see recordTrace() above).

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,9 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
838838
}
839839

840840
bool DataAggregator::recordTrace(
841-
BinaryFunction &BF,
842-
const LBREntry &FirstLBR,
843-
const LBREntry &SecondLBR,
841+
BinaryFunction &BF, const LBREntry &FirstLBR, const LBREntry &SecondLBR,
844842
uint64_t Count,
845-
SmallVector<std::pair<uint64_t, uint64_t>, 16> *Branches) const {
843+
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const {
846844
BinaryContext &BC = BF.getBinaryContext();
847845

848846
if (!BF.isSimple())
@@ -902,24 +900,27 @@ bool DataAggregator::recordTrace(
902900
return false;
903901
}
904902

905-
// Record fall-through jumps
906-
BinaryBasicBlock::BinaryBranchInfo &BI = BB->getBranchInfo(*NextBB);
907-
BI.Count += Count;
908-
909-
if (Branches) {
910-
const MCInst *Instr = BB->getLastNonPseudoInstr();
911-
uint64_t Offset = 0;
912-
if (Instr)
913-
Offset = BC.MIB->getOffsetWithDefault(*Instr, 0);
914-
else
915-
Offset = BB->getOffset();
903+
const MCInst *Instr = BB->getLastNonPseudoInstr();
904+
uint64_t Offset = 0;
905+
if (Instr)
906+
Offset = BC.MIB->getOffsetWithDefault(*Instr, 0);
907+
else
908+
Offset = BB->getOffset();
916909

917-
Branches->emplace_back(Offset, NextBB->getOffset());
918-
}
910+
Branches.emplace_back(Offset, NextBB->getOffset());
919911

920912
BB = NextBB;
921913
}
922914

915+
// Record fall-through jumps
916+
for (const auto &[FromOffset, ToOffset] : Branches) {
917+
BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset(FromOffset);
918+
BinaryBasicBlock *ToBB = BF.getBasicBlockAtOffset(ToOffset);
919+
assert(FromBB && ToBB);
920+
BinaryBasicBlock::BinaryBranchInfo &BI = FromBB->getBranchInfo(*ToBB);
921+
BI.Count += Count;
922+
}
923+
923924
return true;
924925
}
925926

@@ -930,7 +931,7 @@ DataAggregator::getFallthroughsInTrace(BinaryFunction &BF,
930931
uint64_t Count) const {
931932
SmallVector<std::pair<uint64_t, uint64_t>, 16> Res;
932933

933-
if (!recordTrace(BF, FirstLBR, SecondLBR, Count, &Res))
934+
if (!recordTrace(BF, FirstLBR, SecondLBR, Count, Res))
934935
return std::nullopt;
935936

936937
return Res;

bolt/lib/Rewrite/BoltDiff.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ static cl::opt<bool> NormalizeByBin1(
8383
"collection time and sampling rate for this to make sense"),
8484
cl::cat(BoltDiffCategory));
8585

86+
static cl::opt<bool>
87+
SkipNonSimple("skip-non-simple",
88+
cl::desc("skip non-simple functions in reporting"),
89+
cl::ReallyHidden, cl::cat(BoltDiffCategory));
90+
8691
} // end namespace opts
8792

8893
namespace llvm {
@@ -428,8 +433,10 @@ class RewriteInstanceDiff {
428433
llvm::make_second_range(llvm::reverse(LargestDiffs))) {
429434
const double Score2 = getNormalizedScore(*BB2, RI2);
430435
const double Score1 = getNormalizedScore(*BBMap[BB2], RI1);
431-
outs() << "BB " << BB2->getName() << " from "
432-
<< BBToFuncMap[BB2]->getDemangledName()
436+
const BinaryFunction *Func = BBToFuncMap[BB2];
437+
if (opts::SkipNonSimple && !Func->isSimple())
438+
continue;
439+
outs() << "BB " << BB2->getName() << " from " << Func->getDemangledName()
433440
<< "\n\tScore bin1 = " << format("%.4f", Score1 * 100.0)
434441
<< "%\n\tScore bin2 = " << format("%.4f", Score2 * 100.0);
435442
outs() << "%\t(Difference: ";
@@ -460,9 +467,12 @@ class RewriteInstanceDiff {
460467
EdgeTy &Edge1 = EI.second;
461468
const double Score2 = std::get<2>(Edge2);
462469
const double Score1 = std::get<2>(Edge1);
470+
const BinaryFunction *Func = BBToFuncMap[std::get<0>(Edge2)];
471+
if (opts::SkipNonSimple && !Func->isSimple())
472+
continue;
463473
outs() << "Edge (" << std::get<0>(Edge2)->getName() << " -> "
464474
<< std::get<1>(Edge2)->getName() << ") in "
465-
<< BBToFuncMap[std::get<0>(Edge2)]->getDemangledName()
475+
<< Func->getDemangledName()
466476
<< "\n\tScore bin1 = " << format("%.4f", Score1 * 100.0)
467477
<< "%\n\tScore bin2 = " << format("%.4f", Score2 * 100.0);
468478
outs() << "%\t(Difference: ";
@@ -537,6 +547,8 @@ class RewriteInstanceDiff {
537547
Score2 = LTOAggregatedScore2[Iter2->second];
538548
if (Score1 == 0.0 || Score2 == 0.0)
539549
continue;
550+
if (opts::SkipNonSimple && !Func1->isSimple() && !Func2->isSimple())
551+
continue;
540552
LargestDiffs.insert(
541553
std::make_pair<>(std::abs(Score1 - Score2), MapEntry));
542554
ScoreMap[Func2] = std::make_pair<>(Score1, Score2);

bolt/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13.4)
1+
cmake_minimum_required(VERSION 3.20.0)
22
include(CheckIncludeFiles)
33
include(GNUInstallDirs)
44

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include "UndelegatedConstructorCheck.h"
7474
#include "UnhandledExceptionAtNewCheck.h"
7575
#include "UnhandledSelfAssignmentCheck.h"
76+
#include "UniquePtrArrayMismatchCheck.h"
7677
#include "UnsafeFunctionsCheck.h"
7778
#include "UnusedRaiiCheck.h"
7879
#include "UnusedReturnValueCheck.h"
@@ -207,6 +208,8 @@ class BugproneModule : public ClangTidyModule {
207208
"bugprone-unhandled-self-assignment");
208209
CheckFactories.registerCheck<UnhandledExceptionAtNewCheck>(
209210
"bugprone-unhandled-exception-at-new");
211+
CheckFactories.registerCheck<UniquePtrArrayMismatchCheck>(
212+
"bugprone-unique-ptr-array-mismatch");
210213
CheckFactories.registerCheck<UnsafeFunctionsCheck>(
211214
"bugprone-unsafe-functions");
212215
CheckFactories.registerCheck<UnusedRaiiCheck>("bugprone-unused-raii");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ add_clang_library(clangTidyBugproneModule
6969
UndelegatedConstructorCheck.cpp
7070
UnhandledExceptionAtNewCheck.cpp
7171
UnhandledSelfAssignmentCheck.cpp
72+
UniquePtrArrayMismatchCheck.cpp
7273
UnsafeFunctionsCheck.cpp
7374
UnusedRaiiCheck.cpp
7475
UnusedReturnValueCheck.cpp
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===--- UniquePtrArrayMismatchCheck.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 "UniquePtrArrayMismatchCheck.h"
10+
11+
using namespace clang::ast_matchers;
12+
13+
namespace clang::tidy::bugprone {
14+
15+
UniquePtrArrayMismatchCheck::UniquePtrArrayMismatchCheck(
16+
StringRef Name, ClangTidyContext *Context)
17+
: SmartPtrArrayMismatchCheck(Name, Context, "unique") {}
18+
19+
UniquePtrArrayMismatchCheck::SmartPtrClassMatcher
20+
UniquePtrArrayMismatchCheck::getSmartPointerClassMatcher() const {
21+
auto DeleterDecl = classTemplateSpecializationDecl(
22+
hasName("::std::default_delete"), templateArgumentCountIs(1),
23+
hasTemplateArgument(0, templateArgument(refersToType(
24+
qualType(equalsBoundNode(PointerTypeN))))));
25+
return classTemplateSpecializationDecl(
26+
hasName("::std::unique_ptr"), templateArgumentCountIs(2),
27+
hasTemplateArgument(
28+
0, templateArgument(refersToType(qualType().bind(PointerTypeN)))),
29+
hasTemplateArgument(1, templateArgument(refersToType(
30+
qualType(hasDeclaration(DeleterDecl))))));
31+
}
32+
33+
} // namespace clang::tidy::bugprone
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===--- UniquePtrArrayMismatchCheck.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_UNIQUEPTRARRAYMISMATCHCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNIQUEPTRARRAYMISMATCHCHECK_H
11+
12+
#include "SmartPtrArrayMismatchCheck.h"
13+
14+
namespace clang::tidy::bugprone {
15+
16+
/// Finds initializations of C++ unique pointers to non-array type that are
17+
/// initialized with an array.
18+
///
19+
/// Example:
20+
///
21+
/// \code
22+
/// std::unique_ptr<int> PtrArr{new int[10]};
23+
/// \endcode
24+
class UniquePtrArrayMismatchCheck : public SmartPtrArrayMismatchCheck {
25+
public:
26+
UniquePtrArrayMismatchCheck(StringRef Name, ClangTidyContext *Context);
27+
28+
protected:
29+
SmartPtrClassMatcher getSmartPointerClassMatcher() const override;
30+
};
31+
32+
} // namespace clang::tidy::bugprone
33+
34+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNIQUEPTRARRAYMISMATCHCHECK_H

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "UnusedReturnValueCheck.h"
10+
#include "../utils/Matchers.h"
1011
#include "../utils/OptionsUtils.h"
1112
#include "clang/AST/ASTContext.h"
1213
#include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -27,7 +28,6 @@ AST_MATCHER_P(FunctionDecl, isInstantiatedFrom, Matcher<FunctionDecl>,
2728
return InnerMatcher.matches(InstantiatedFrom ? *InstantiatedFrom : Node,
2829
Finder, Builder);
2930
}
30-
3131
} // namespace
3232

3333
UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
@@ -124,19 +124,31 @@ UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
124124
"::sigismember;"
125125
"::strcasecmp;"
126126
"::strsignal;"
127-
"::ttyname")) {}
127+
"::ttyname")),
128+
CheckedReturnTypes(utils::options::parseStringList(
129+
Options.get("CheckedReturnTypes", "::std::error_code;"
130+
"::std::error_condition;"
131+
"::std::errc;"
132+
"::std::expected;"
133+
"::boost::system::error_code"))) {}
128134

129135
void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
130136
Options.store(Opts, "CheckedFunctions", CheckedFunctions);
137+
Options.store(Opts, "CheckedReturnTypes",
138+
utils::options::serializeStringList(CheckedReturnTypes));
131139
}
132140

133141
void UnusedReturnValueCheck::registerMatchers(MatchFinder *Finder) {
134142
auto FunVec = utils::options::parseStringList(CheckedFunctions);
143+
135144
auto MatchedCallExpr = expr(ignoringImplicit(ignoringParenImpCasts(
136145
callExpr(callee(functionDecl(
137146
// Don't match void overloads of checked functions.
138147
unless(returns(voidType())),
139-
isInstantiatedFrom(hasAnyName(FunVec)))))
148+
anyOf(isInstantiatedFrom(hasAnyName(FunVec)),
149+
returns(hasCanonicalType(hasDeclaration(
150+
namedDecl(matchers::matchesAnyListedName(
151+
CheckedReturnTypes)))))))))
140152
.bind("match"))));
141153

142154
auto UnusedInCompoundStmt =

clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class UnusedReturnValueCheck : public ClangTidyCheck {
2727

2828
private:
2929
std::string CheckedFunctions;
30+
const std::vector<StringRef> CheckedReturnTypes;
3031
};
3132

3233
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace clang::tidy::llvm_libc {
1818
/// are tagged with the LIBC_INLINE macro.
1919
///
2020
/// For more information about the LIBC_INLINE macro, see
21-
/// https://libc.llvm.org/code_style.html.
21+
/// https://libc.llvm.org/dev/code_style.html.
2222
///
2323
/// For the user-facing documentation see:
2424
/// http://clang.llvm.org/extra/clang-tidy/checks/llvmlibc/inline-function-decl-check.html

0 commit comments

Comments
 (0)