Skip to content

Commit 6716605

Browse files
authored
Merge branch 'main' into kbelochapka/main/refactor-the-DTLTO-code
2 parents 5275bba + b87f23a commit 6716605

864 files changed

Lines changed: 28102 additions & 11676 deletions

File tree

Some content is hidden

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

.ci/compute_projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"mlir",
4949
"polly",
5050
"flang",
51+
"cross-project-tests",
5152
},
5253
"lld": {"bolt", "cross-project-tests"},
5354
"clang": {"clang-tools-extra", "cross-project-tests", "lldb"},
@@ -94,7 +95,6 @@
9495
}
9596

9697
EXCLUDE_LINUX = {
97-
"cross-project-tests", # TODO(issues/132796): Tests are failing.
9898
"openmp", # https://github.com/google/llvm-premerge-checks/issues/410
9999
}
100100

.ci/compute_projects_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def test_llvm(self):
1515
)
1616
self.assertEqual(
1717
env_variables["projects_to_build"],
18-
"bolt;clang;clang-tools-extra;flang;lld;lldb;llvm;mlir;polly",
18+
"bolt;clang;clang-tools-extra;cross-project-tests;flang;lld;lldb;llvm;mlir;polly",
1919
)
2020
self.assertEqual(
2121
env_variables["project_check_targets"],
22-
"check-bolt check-clang check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
22+
"check-bolt check-clang check-clang-tools check-cross-project check-flang check-lld check-lldb check-llvm check-mlir check-polly",
2323
)
2424
self.assertEqual(
2525
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
@@ -83,11 +83,11 @@ def test_clang(self):
8383
)
8484
self.assertEqual(
8585
env_variables["projects_to_build"],
86-
"clang;clang-tools-extra;lld;lldb;llvm",
86+
"clang;clang-tools-extra;cross-project-tests;lld;lldb;llvm",
8787
)
8888
self.assertEqual(
8989
env_variables["project_check_targets"],
90-
"check-clang check-clang-tools check-lldb",
90+
"check-clang check-clang-tools check-cross-project check-lldb",
9191
)
9292
self.assertEqual(
9393
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
@@ -158,11 +158,11 @@ def test_cir(self):
158158
)
159159
self.assertEqual(
160160
env_variables["projects_to_build"],
161-
"clang;clang-tools-extra;lld;lldb;llvm;mlir",
161+
"clang;clang-tools-extra;cross-project-tests;lld;lldb;llvm;mlir",
162162
)
163163
self.assertEqual(
164164
env_variables["project_check_targets"],
165-
"check-clang check-clang-cir check-clang-tools check-lldb",
165+
"check-clang check-clang-cir check-clang-tools check-cross-project check-lldb",
166166
)
167167
self.assertEqual(
168168
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
@@ -432,11 +432,11 @@ def test_lit(self):
432432
)
433433
self.assertEqual(
434434
env_variables["projects_to_build"],
435-
"bolt;clang;clang-tools-extra;flang;lld;lldb;llvm;mlir;polly",
435+
"bolt;clang;clang-tools-extra;cross-project-tests;flang;lld;lldb;llvm;mlir;polly",
436436
)
437437
self.assertEqual(
438438
env_variables["project_check_targets"],
439-
"check-bolt check-clang check-clang-tools check-flang check-lit check-lld check-lldb check-llvm check-mlir check-polly",
439+
"check-bolt check-clang check-clang-tools check-cross-project check-flang check-lit check-lld check-lldb check-llvm check-mlir check-polly",
440440
)
441441
self.assertEqual(
442442
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@
157157
# MLIR Index Dialect
158158
/mlir/**/Index* @mogball
159159

160+
# MLIR Shard Dialect
161+
/mlir/**/*shard* @fschlimb
162+
/mlir/**/*Shard* @fschlimb
163+
160164
# MLIR Python Bindings
161165
/mlir/test/python/ @ftynse @makslevental @stellaraccident @rolfmorel
162166
/mlir/python/ @ftynse @makslevental @stellaraccident @rolfmorel

bolt/include/bolt/Core/MCPlus.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,20 @@ template <typename ValueType> class MCSimpleAnnotation : public MCAnnotation {
113113
ValueType Value;
114114
};
115115

116+
/// Return true if \p Op is the annotation sentinel: a null MCInst operand
117+
/// that marks the start of BOLT annotations. Non-null MCInst operands
118+
/// (e.g. Hexagon duplex sub-instructions) are legitimate prime operands.
119+
inline bool isAnnotationSentinel(const MCOperand &Op) {
120+
return Op.isInst() && Op.getInst() == nullptr;
121+
}
122+
116123
/// Return a number of operands in \Inst excluding operands representing
117124
/// annotations.
118125
inline unsigned getNumPrimeOperands(const MCInst &Inst) {
119126
for (signed I = Inst.getNumOperands() - 1; I >= 0; --I) {
120-
if (Inst.getOperand(I).isInst())
127+
if (isAnnotationSentinel(Inst.getOperand(I)))
121128
return I;
122-
if (!Inst.getOperand(I).isImm())
129+
if (!Inst.getOperand(I).isInst() && !Inst.getOperand(I).isImm())
123130
return Inst.getNumOperands();
124131
}
125132
return Inst.getNumOperands();

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,8 @@ class MCPlusBuilder {
138138

139139
MCInst::iterator getAnnotationInstOp(MCInst &Inst) const {
140140
for (MCInst::iterator Iter = Inst.begin(); Iter != Inst.end(); ++Iter) {
141-
if (Iter->isInst()) {
142-
assert(Iter->getInst() == nullptr && "Empty instruction expected.");
141+
if (MCPlus::isAnnotationSentinel(*Iter))
143142
return Iter;
144-
}
145143
}
146144
return Inst.end();
147145
}

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

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ namespace clang::tidy::bugprone {
3131
using matchers::hasUnevaluatedContext;
3232

3333
namespace {
34+
AST_MATCHER_P(Expr, hasParentIgnoringParenImpCasts,
35+
ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
36+
const Expr *E = &Node;
37+
do {
38+
const DynTypedNodeList Parents = Finder->getASTContext().getParents(*E);
39+
if (Parents.size() != 1)
40+
return false;
41+
E = Parents[0].get<Expr>();
42+
if (!E)
43+
return false;
44+
} while (isa<ImplicitCastExpr, ParenExpr>(E));
45+
46+
return InnerMatcher.matches(*E, Finder, Builder);
47+
}
3448

3549
/// Contains information about a use-after-move.
3650
struct UseAfterMove {
@@ -52,7 +66,8 @@ class UseAfterMoveFinder {
5266
public:
5367
UseAfterMoveFinder(ASTContext *TheContext,
5468
llvm::ArrayRef<StringRef> InvalidationFunctions,
55-
llvm::ArrayRef<StringRef> ReinitializationFunctions);
69+
llvm::ArrayRef<StringRef> ReinitializationFunctions,
70+
const CXXRecordDecl *MovedAs);
5671

5772
// Within the given code block, finds the first use of 'MovedVariable' that
5873
// occurs after 'MovingCall' (the expression that performs the move). If a
@@ -77,26 +92,12 @@ class UseAfterMoveFinder {
7792
ASTContext *Context;
7893
llvm::ArrayRef<StringRef> InvalidationFunctions;
7994
llvm::ArrayRef<StringRef> ReinitializationFunctions;
95+
const CXXRecordDecl *MovedAs;
8096
std::unique_ptr<ExprSequence> Sequence;
8197
std::unique_ptr<StmtToBlockMap> BlockMap;
8298
llvm::SmallPtrSet<const CFGBlock *, 8> Visited;
8399
};
84100

85-
AST_MATCHER_P(Expr, hasParentIgnoringParenImpCasts,
86-
ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
87-
const Expr *E = &Node;
88-
do {
89-
const DynTypedNodeList Parents = Finder->getASTContext().getParents(*E);
90-
if (Parents.size() != 1)
91-
return false;
92-
E = Parents[0].get<Expr>();
93-
if (!E)
94-
return false;
95-
} while (isa<ImplicitCastExpr, ParenExpr>(E));
96-
97-
return InnerMatcher.matches(*E, Finder, Builder);
98-
}
99-
100101
} // namespace
101102

102103
static auto getNameMatcher(llvm::ArrayRef<StringRef> InvalidationFunctions) {
@@ -193,9 +194,10 @@ static StatementMatcher inDecltypeOrTemplateArg() {
193194

194195
UseAfterMoveFinder::UseAfterMoveFinder(
195196
ASTContext *TheContext, llvm::ArrayRef<StringRef> InvalidationFunctions,
196-
llvm::ArrayRef<StringRef> ReinitializationFunctions)
197+
llvm::ArrayRef<StringRef> ReinitializationFunctions,
198+
const CXXRecordDecl *MovedAs)
197199
: Context(TheContext), InvalidationFunctions(InvalidationFunctions),
198-
ReinitializationFunctions(ReinitializationFunctions) {}
200+
ReinitializationFunctions(ReinitializationFunctions), MovedAs(MovedAs) {}
199201

200202
std::optional<UseAfterMove>
201203
UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
@@ -405,7 +407,13 @@ void UseAfterMoveFinder::getDeclRefs(
405407
DeclRefs](const ArrayRef<BoundNodes> Matches) {
406408
for (const auto &Match : Matches) {
407409
const auto *DeclRef = Match.getNodeAs<DeclRefExpr>("declref");
410+
const auto *Member = Match.getNodeAs<MemberExpr>("member-expr");
408411
const auto *Operator = Match.getNodeAs<CXXOperatorCallExpr>("operator");
412+
// Non-moved member as the move only implies a base class.
413+
if (Member && MovedAs && !isa<CXXMethodDecl>(Member->getMemberDecl()) &&
414+
!MovedAs->hasMemberName(Member->getMemberDecl()->getIdentifier())) {
415+
continue;
416+
}
409417
if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
410418
// Ignore uses of a standard smart pointer or classes annotated as
411419
// "null_after_move" (smart-pointer-like behavior) that don't
@@ -420,7 +428,9 @@ void UseAfterMoveFinder::getDeclRefs(
420428
declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
421429
unless(inDecltypeOrTemplateArg()),
422430
unless(hasParentIgnoringParenImpCasts(
423-
memberExpr(hasDeclaration(cxxDestructorDecl())))))
431+
memberExpr(hasDeclaration(cxxDestructorDecl())))),
432+
optionally(hasParentIgnoringParenImpCasts(
433+
memberExpr().bind("member-expr"))))
424434
.bind("declref");
425435

426436
AddDeclRefs(match(traverse(TK_AsIs, findAll(DeclRefMatcher)), *S->getStmt(),
@@ -540,25 +550,27 @@ void UseAfterMoveCheck::registerMatchers(MatchFinder *Finder) {
540550
cxxMemberCallExpr(callee(cxxMethodDecl(hasName("try_emplace"))));
541551
auto Arg = declRefExpr().bind("arg");
542552
auto IsMemberCallee = callee(functionDecl(unless(isStaticStorageClass())));
543-
auto CallMoveMatcher =
544-
callExpr(callee(functionDecl(getNameMatcher(InvalidationFunctions))
545-
.bind("move-decl")),
546-
anyOf(cxxMemberCallExpr(IsMemberCallee, on(Arg)),
547-
callExpr(unless(cxxMemberCallExpr(IsMemberCallee)),
548-
hasArgument(0, Arg))),
549-
unless(inDecltypeOrTemplateArg()),
550-
unless(hasParent(TryEmplaceMatcher)), expr().bind("call-move"),
551-
anyOf(hasAncestor(compoundStmt(
552-
hasParent(lambdaExpr().bind("containing-lambda")))),
553-
hasAncestor(functionDecl(anyOf(
554-
cxxConstructorDecl(
555-
hasAnyConstructorInitializer(withInitializer(
556-
expr(anyOf(equalsBoundNode("call-move"),
557-
hasDescendant(expr(
558-
equalsBoundNode("call-move")))))
559-
.bind("containing-ctor-init"))))
560-
.bind("containing-ctor"),
561-
functionDecl().bind("containing-func"))))));
553+
auto CallMoveMatcher = callExpr(
554+
callee(functionDecl(getNameMatcher(InvalidationFunctions))
555+
.bind("move-decl")),
556+
anyOf(cxxMemberCallExpr(IsMemberCallee, on(Arg)),
557+
callExpr(unless(cxxMemberCallExpr(IsMemberCallee)),
558+
hasArgument(0, Arg))),
559+
unless(inDecltypeOrTemplateArg()), unless(hasParent(TryEmplaceMatcher)),
560+
expr().bind("call-move"),
561+
optionally(hasParent(implicitCastExpr(hasCastKind(CK_DerivedToBase))
562+
.bind("optional-cast"))),
563+
anyOf(hasAncestor(compoundStmt(
564+
hasParent(lambdaExpr().bind("containing-lambda")))),
565+
hasAncestor(functionDecl(
566+
anyOf(cxxConstructorDecl(
567+
hasAnyConstructorInitializer(withInitializer(
568+
expr(anyOf(equalsBoundNode("call-move"),
569+
hasDescendant(expr(
570+
equalsBoundNode("call-move")))))
571+
.bind("containing-ctor-init"))))
572+
.bind("containing-ctor"),
573+
functionDecl().bind("containing-func"))))));
562574

563575
Finder->addMatcher(
564576
traverse(
@@ -593,6 +605,8 @@ void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
593605
const auto *MovingCall = Result.Nodes.getNodeAs<Expr>("moving-call");
594606
const auto *Arg = Result.Nodes.getNodeAs<DeclRefExpr>("arg");
595607
const auto *MoveDecl = Result.Nodes.getNodeAs<FunctionDecl>("move-decl");
608+
const auto *ParentCast =
609+
Result.Nodes.getNodeAs<ImplicitCastExpr>("optional-cast");
596610

597611
if (!MovingCall || !MovingCall->getExprLoc().isValid())
598612
MovingCall = CallMove;
@@ -623,9 +637,12 @@ void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
623637
CodeBlocks.push_back(ContainingFunc->getBody());
624638
}
625639

640+
const CXXRecordDecl *MovedAs =
641+
ParentCast ? ParentCast->getType()->getAsCXXRecordDecl() : nullptr;
642+
626643
for (Stmt *CodeBlock : CodeBlocks) {
627644
UseAfterMoveFinder Finder(Result.Context, InvalidationFunctions,
628-
ReinitializationFunctions);
645+
ReinitializationFunctions, MovedAs);
629646
if (auto Use = Finder.find(CodeBlock, MovingCall, Arg))
630647
emitDiagnostic(MovingCall, Arg, *Use, this, Result.Context,
631648
determineMoveType(MoveDecl), MoveDecl);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "../utils/LexerUtils.h"
1212
#include "clang/AST/ASTContext.h"
13+
#include "clang/AST/StmtObjC.h"
1314
#include "clang/AST/Type.h"
1415
#include "clang/ASTMatchers/ASTMatchFinder.h"
1516
#include "clang/Lex/Preprocessor.h"
@@ -21,6 +22,9 @@ namespace clang::tidy::cppcoreguidelines {
2122

2223
namespace {
2324
AST_MATCHER(VarDecl, isLocalVarDecl) { return Node.isLocalVarDecl(); }
25+
AST_MATCHER(Stmt, isObjCForCollectionStmt) {
26+
return isa<ObjCForCollectionStmt>(&Node);
27+
}
2428
} // namespace
2529

2630
InitVariablesCheck::InitVariablesCheck(StringRef Name,
@@ -42,6 +46,7 @@ void InitVariablesCheck::registerMatchers(MatchFinder *Finder) {
4246
varDecl(unless(hasInitializer(anything())), unless(isInstantiated()),
4347
isLocalVarDecl(), unless(isStaticLocal()), isDefinition(),
4448
unless(hasParent(cxxCatchStmt())),
49+
unless(hasParent(declStmt(hasParent(isObjCForCollectionStmt())))),
4550
optionally(hasParent(declStmt(hasParent(
4651
cxxForRangeStmt(hasLoopVariable(varDecl().bind(BadDecl))))))),
4752
unless(equalsBoundNode(BadDecl)))

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ add_clang_library(clangTidyReadabilityModule STATIC
4444
RedundantControlFlowCheck.cpp
4545
RedundantDeclarationCheck.cpp
4646
RedundantFunctionPtrDereferenceCheck.cpp
47+
RedundantLambdaParameterListCheck.cpp
4748
RedundantMemberInitCheck.cpp
4849
RedundantParenthesesCheck.cpp
4950
RedundantPreprocessorCheck.cpp

clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "RedundantDeclarationCheck.h"
4747
#include "RedundantFunctionPtrDereferenceCheck.h"
4848
#include "RedundantInlineSpecifierCheck.h"
49+
#include "RedundantLambdaParameterListCheck.h"
4950
#include "RedundantMemberInitCheck.h"
5051
#include "RedundantParenthesesCheck.h"
5152
#include "RedundantPreprocessorCheck.h"
@@ -143,6 +144,8 @@ class ReadabilityModule : public ClangTidyModule {
143144
"readability-redundant-casting");
144145
CheckFactories.registerCheck<RedundantFunctionPtrDereferenceCheck>(
145146
"readability-redundant-function-ptr-dereference");
147+
CheckFactories.registerCheck<RedundantLambdaParameterListCheck>(
148+
"readability-redundant-lambda-parameter-list");
146149
CheckFactories.registerCheck<RedundantMemberInitCheck>(
147150
"readability-redundant-member-init");
148151
CheckFactories.registerCheck<RedundantParenthesesCheck>(

0 commit comments

Comments
 (0)