Skip to content

Commit b6c823f

Browse files
committed
Merge branch 'main' into bi-prefetchw
2 parents e1331b2 + 332fda8 commit b6c823f

File tree

5,180 files changed

+196694
-79151
lines changed

Some content is hidden

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

5,180 files changed

+196694
-79151
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ env:
4949
jobs:
5050
stage1:
5151
if: github.repository_owner == 'llvm'
52-
runs-on: libcxx-runners-8-set
52+
runs-on: libcxx-runners-set
53+
container: ghcr.io/libcxx/actions-builder:testing-2024-09-21
5354
continue-on-error: false
5455
strategy:
5556
fail-fast: false
@@ -79,12 +80,14 @@ jobs:
7980
path: |
8081
**/test-results.xml
8182
**/*.abilist
83+
**/CMakeConfigureLog.yaml
8284
**/CMakeError.log
8385
**/CMakeOutput.log
8486
**/crash_diagnostics/*
8587
stage2:
8688
if: github.repository_owner == 'llvm'
87-
runs-on: libcxx-runners-8-set
89+
runs-on: libcxx-runners-set
90+
container: ghcr.io/libcxx/actions-builder:testing-2024-09-21
8891
needs: [ stage1 ]
8992
continue-on-error: false
9093
strategy:
@@ -123,6 +126,7 @@ jobs:
123126
path: |
124127
**/test-results.xml
125128
**/*.abilist
129+
**/CMakeConfigureLog.yaml
126130
**/CMakeError.log
127131
**/CMakeOutput.log
128132
**/crash_diagnostics/*
@@ -160,20 +164,21 @@ jobs:
160164
'benchmarks',
161165
'bootstrapping-build'
162166
]
163-
machine: [ 'libcxx-runners-8-set' ]
167+
machine: [ 'libcxx-runners-set' ]
164168
include:
165169
- config: 'generic-cxx26'
166-
machine: libcxx-runners-8-set
170+
machine: libcxx-runners-set
167171
- config: 'generic-asan'
168-
machine: libcxx-runners-8-set
172+
machine: libcxx-runners-set
169173
- config: 'generic-tsan'
170-
machine: libcxx-runners-8-set
174+
machine: libcxx-runners-set
171175
- config: 'generic-ubsan'
172-
machine: libcxx-runners-8-set
176+
machine: libcxx-runners-set
173177
# Use a larger machine for MSAN to avoid timeout and memory allocation issues.
174178
- config: 'generic-msan'
175-
machine: libcxx-runners-8-set
179+
machine: libcxx-runners-set
176180
runs-on: ${{ matrix.machine }}
181+
container: ghcr.io/libcxx/actions-builder:testing-2024-09-21
177182
steps:
178183
- uses: actions/checkout@v4
179184
- name: ${{ matrix.config }}
@@ -188,6 +193,7 @@ jobs:
188193
path: |
189194
**/test-results.xml
190195
**/*.abilist
196+
**/CMakeConfigureLog.yaml
191197
**/CMakeError.log
192198
**/CMakeOutput.log
193199
**/crash_diagnostics/*
@@ -230,6 +236,7 @@ jobs:
230236
path: |
231237
**/test-results.xml
232238
**/*.abilist
239+
**/CMakeConfigureLog.yaml
233240
**/CMakeError.log
234241
**/CMakeOutput.log
235242
**/crash_diagnostics/*

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,7 @@ struct CFISnapshot {
25772577
case MCCFIInstruction::OpAdjustCfaOffset:
25782578
case MCCFIInstruction::OpWindowSave:
25792579
case MCCFIInstruction::OpNegateRAState:
2580+
case MCCFIInstruction::OpNegateRAStateWithPC:
25802581
case MCCFIInstruction::OpLLVMDefAspaceCfa:
25812582
case MCCFIInstruction::OpLabel:
25822583
llvm_unreachable("unsupported CFI opcode");
@@ -2715,6 +2716,7 @@ struct CFISnapshotDiff : public CFISnapshot {
27152716
case MCCFIInstruction::OpAdjustCfaOffset:
27162717
case MCCFIInstruction::OpWindowSave:
27172718
case MCCFIInstruction::OpNegateRAState:
2719+
case MCCFIInstruction::OpNegateRAStateWithPC:
27182720
case MCCFIInstruction::OpLLVMDefAspaceCfa:
27192721
case MCCFIInstruction::OpLabel:
27202722
llvm_unreachable("unsupported CFI opcode");
@@ -2864,6 +2866,7 @@ BinaryFunction::unwindCFIState(int32_t FromState, int32_t ToState,
28642866
case MCCFIInstruction::OpAdjustCfaOffset:
28652867
case MCCFIInstruction::OpWindowSave:
28662868
case MCCFIInstruction::OpNegateRAState:
2869+
case MCCFIInstruction::OpNegateRAStateWithPC:
28672870
case MCCFIInstruction::OpLLVMDefAspaceCfa:
28682871
case MCCFIInstruction::OpLabel:
28692872
llvm_unreachable("unsupported CFI opcode");

bolt/lib/Core/HashUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ std::string hashBlockLoose(BinaryContext &BC, const BinaryBasicBlock &BB) {
145145
continue;
146146
}
147147

148-
std::string Mnemonic = BC.InstPrinter->getMnemonic(&Inst).first;
148+
std::string Mnemonic = BC.InstPrinter->getMnemonic(Inst).first;
149149
llvm::erase_if(Mnemonic, [](unsigned char ch) { return std::isspace(ch); });
150150
Opcodes.insert(Mnemonic);
151151
}

bolt/test/X86/pre-aggregated-perf.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ REQUIRES: system-linux
1111

1212
RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
1313
RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated.txt -w %t.new \
14+
RUN: --show-density \
1415
RUN: --profile-density-threshold=9 --profile-density-cutoff-hot=970000 \
1516
RUN: --profile-use-dfs | FileCheck %s --check-prefix=CHECK-P2B
1617

1718
CHECK-P2B: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
1819
CHECK-P2B: BOLT-INFO: Functions with density >= 21.7 account for 97.00% total sample counts.
1920

2021
RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated.txt -w %t.new \
22+
RUN: --show-density \
2123
RUN: --profile-density-cutoff-hot=970000 \
2224
RUN: --profile-use-dfs 2>&1 | FileCheck %s --check-prefix=CHECK-WARNING
2325

clang-tools-extra/clang-query/Query.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ bool HelpQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
4444
" set bind-root (true|false) "
4545
"Set whether to bind the root matcher to \"root\".\n"
4646
" set print-matcher (true|false) "
47-
"Set whether to print the current matcher,\n"
47+
"Set whether to print the current matcher.\n"
48+
" set enable-profile (true|false) "
49+
"Set whether to enable matcher profiling.\n"
4850
" set traversal <kind> "
4951
"Set traversal kind of clang-query session. Available kinds are:\n"
5052
" AsIs "
@@ -82,27 +84,53 @@ namespace {
8284

8385
struct CollectBoundNodes : MatchFinder::MatchCallback {
8486
std::vector<BoundNodes> &Bindings;
85-
CollectBoundNodes(std::vector<BoundNodes> &Bindings) : Bindings(Bindings) {}
87+
StringRef Unit;
88+
CollectBoundNodes(std::vector<BoundNodes> &Bindings, StringRef Unit)
89+
: Bindings(Bindings), Unit(Unit) {}
8690
void run(const MatchFinder::MatchResult &Result) override {
8791
Bindings.push_back(Result.Nodes);
8892
}
93+
StringRef getID() const override { return Unit; }
94+
};
95+
96+
struct QueryProfiler {
97+
llvm::StringMap<llvm::TimeRecord> Records;
98+
99+
~QueryProfiler() {
100+
llvm::TimerGroup TG("clang-query", "clang-query matcher profiling",
101+
Records);
102+
TG.print(llvm::errs());
103+
llvm::errs().flush();
104+
}
89105
};
90106

91107
} // namespace
92108

93109
bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
94110
unsigned MatchCount = 0;
95111

112+
std::optional<QueryProfiler> Profiler;
113+
if (QS.EnableProfile)
114+
Profiler.emplace();
115+
96116
for (auto &AST : QS.ASTs) {
97-
MatchFinder Finder;
117+
ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
118+
std::optional<llvm::StringMap<llvm::TimeRecord>> Records;
119+
if (QS.EnableProfile) {
120+
Records.emplace();
121+
FinderOptions.CheckProfiling.emplace(*Records);
122+
}
123+
124+
MatchFinder Finder(FinderOptions);
98125
std::vector<BoundNodes> Matches;
99126
DynTypedMatcher MaybeBoundMatcher = Matcher;
100127
if (QS.BindRoot) {
101128
std::optional<DynTypedMatcher> M = Matcher.tryBind("root");
102129
if (M)
103130
MaybeBoundMatcher = *M;
104131
}
105-
CollectBoundNodes Collect(Matches);
132+
StringRef OrigSrcName = AST->getOriginalSourceFileName();
133+
CollectBoundNodes Collect(Matches, OrigSrcName);
106134
if (!Finder.addDynamicMatcher(MaybeBoundMatcher, &Collect)) {
107135
OS << "Not a valid top-level matcher.\n";
108136
return false;
@@ -111,6 +139,8 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
111139
ASTContext &Ctx = AST->getASTContext();
112140
Ctx.getParentMapContext().setTraversalKind(QS.TK);
113141
Finder.matchAST(Ctx);
142+
if (QS.EnableProfile)
143+
Profiler->Records[OrigSrcName] += (*Records)[OrigSrcName];
114144

115145
if (QS.PrintMatcher) {
116146
SmallVector<StringRef, 4> Lines;

clang-tools-extra/clang-query/QueryParser.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ enum ParsedQueryVariable {
182182
PQV_Output,
183183
PQV_BindRoot,
184184
PQV_PrintMatcher,
185+
PQV_EnableProfile,
185186
PQV_Traversal
186187
};
187188

@@ -285,6 +286,7 @@ QueryRef QueryParser::doParse() {
285286
.Case("output", PQV_Output)
286287
.Case("bind-root", PQV_BindRoot)
287288
.Case("print-matcher", PQV_PrintMatcher)
289+
.Case("enable-profile", PQV_EnableProfile)
288290
.Case("traversal", PQV_Traversal)
289291
.Default(PQV_Invalid);
290292
if (VarStr.empty())
@@ -303,6 +305,9 @@ QueryRef QueryParser::doParse() {
303305
case PQV_PrintMatcher:
304306
Q = parseSetBool(&QuerySession::PrintMatcher);
305307
break;
308+
case PQV_EnableProfile:
309+
Q = parseSetBool(&QuerySession::EnableProfile);
310+
break;
306311
case PQV_Traversal:
307312
Q = parseSetTraversalKind(&QuerySession::TK);
308313
break;

clang-tools-extra/clang-query/QuerySession.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class QuerySession {
2626
QuerySession(llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs)
2727
: ASTs(ASTs), PrintOutput(false), DiagOutput(true),
2828
DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
29-
Terminate(false), TK(TK_AsIs) {}
29+
EnableProfile(false), Terminate(false), TK(TK_AsIs) {}
3030

3131
llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs;
3232

@@ -36,6 +36,7 @@ class QuerySession {
3636

3737
bool BindRoot;
3838
bool PrintMatcher;
39+
bool EnableProfile;
3940
bool Terminate;
4041

4142
TraversalKind TK;

clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,44 @@ void IdDependentBackwardBranchCheck::registerMatchers(MatchFinder *Finder) {
7878

7979
IdDependentBackwardBranchCheck::IdDependencyRecord *
8080
IdDependentBackwardBranchCheck::hasIdDepVar(const Expr *Expression) {
81+
if (!Expression)
82+
return nullptr;
83+
8184
if (const auto *Declaration = dyn_cast<DeclRefExpr>(Expression)) {
8285
// It is a DeclRefExpr, so check if it's an ID-dependent variable.
83-
const auto *CheckVariable = dyn_cast<VarDecl>(Declaration->getDecl());
86+
const auto *CheckVariable =
87+
dyn_cast_if_present<VarDecl>(Declaration->getDecl());
88+
if (!CheckVariable)
89+
return nullptr;
8490
auto FoundVariable = IdDepVarsMap.find(CheckVariable);
8591
if (FoundVariable == IdDepVarsMap.end())
8692
return nullptr;
8793
return &(FoundVariable->second);
8894
}
8995
for (const auto *Child : Expression->children())
90-
if (const auto *ChildExpression = dyn_cast<Expr>(Child))
96+
if (const auto *ChildExpression = dyn_cast_if_present<Expr>(Child))
9197
if (IdDependencyRecord *Result = hasIdDepVar(ChildExpression))
9298
return Result;
9399
return nullptr;
94100
}
95101

96102
IdDependentBackwardBranchCheck::IdDependencyRecord *
97103
IdDependentBackwardBranchCheck::hasIdDepField(const Expr *Expression) {
104+
if (!Expression)
105+
return nullptr;
106+
98107
if (const auto *MemberExpression = dyn_cast<MemberExpr>(Expression)) {
99108
const auto *CheckField =
100-
dyn_cast<FieldDecl>(MemberExpression->getMemberDecl());
109+
dyn_cast_if_present<FieldDecl>(MemberExpression->getMemberDecl());
110+
if (!CheckField)
111+
return nullptr;
101112
auto FoundField = IdDepFieldsMap.find(CheckField);
102113
if (FoundField == IdDepFieldsMap.end())
103114
return nullptr;
104115
return &(FoundField->second);
105116
}
106117
for (const auto *Child : Expression->children())
107-
if (const auto *ChildExpression = dyn_cast<Expr>(Child))
118+
if (const auto *ChildExpression = dyn_cast_if_present<Expr>(Child))
108119
if (IdDependencyRecord *Result = hasIdDepField(ChildExpression))
109120
return Result;
110121
return nullptr;

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

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

99
#include "ReturnConstRefFromParameterCheck.h"
10+
#include "clang/AST/Expr.h"
1011
#include "clang/ASTMatchers/ASTMatchFinder.h"
1112
#include "clang/ASTMatchers/ASTMatchers.h"
1213

@@ -15,19 +16,24 @@ using namespace clang::ast_matchers;
1516
namespace clang::tidy::bugprone {
1617

1718
void ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) {
19+
const auto DRef = ignoringParens(
20+
declRefExpr(
21+
to(parmVarDecl(hasType(hasCanonicalType(
22+
qualType(lValueReferenceType(pointee(
23+
qualType(isConstQualified()))))
24+
.bind("type"))))
25+
.bind("param")))
26+
.bind("dref"));
27+
const auto Func =
28+
functionDecl(hasReturnTypeLoc(loc(
29+
qualType(hasCanonicalType(equalsBoundNode("type"))))))
30+
.bind("func");
31+
32+
Finder->addMatcher(returnStmt(hasReturnValue(DRef), hasAncestor(Func)), this);
1833
Finder->addMatcher(
19-
returnStmt(
20-
hasReturnValue(declRefExpr(
21-
to(parmVarDecl(hasType(hasCanonicalType(
22-
qualType(lValueReferenceType(pointee(
23-
qualType(isConstQualified()))))
24-
.bind("type"))))
25-
.bind("param")))),
26-
hasAncestor(
27-
functionDecl(hasReturnTypeLoc(loc(qualType(
28-
hasCanonicalType(equalsBoundNode("type"))))))
29-
.bind("func")))
30-
.bind("ret"),
34+
returnStmt(hasReturnValue(ignoringParens(conditionalOperator(
35+
eachOf(hasTrueExpression(DRef), hasFalseExpression(DRef)),
36+
hasAncestor(Func))))),
3137
this);
3238
}
3339

@@ -85,8 +91,8 @@ void ReturnConstRefFromParameterCheck::check(
8591
const MatchFinder::MatchResult &Result) {
8692
const auto *FD = Result.Nodes.getNodeAs<FunctionDecl>("func");
8793
const auto *PD = Result.Nodes.getNodeAs<ParmVarDecl>("param");
88-
const auto *R = Result.Nodes.getNodeAs<ReturnStmt>("ret");
89-
const SourceRange Range = R->getRetValue()->getSourceRange();
94+
const auto *DRef = Result.Nodes.getNodeAs<DeclRefExpr>("dref");
95+
const SourceRange Range = DRef->getSourceRange();
9096
if (Range.isInvalid())
9197
return;
9298

clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,13 @@ unsigned getNumberOfDesignated(const InitListExpr *SyntacticInitList) {
8080
});
8181
}
8282

83-
AST_MATCHER(CXXRecordDecl, isAggregate) { return Node.isAggregate(); }
83+
AST_MATCHER(CXXRecordDecl, isAggregate) {
84+
return Node.hasDefinition() && Node.isAggregate();
85+
}
8486

85-
AST_MATCHER(CXXRecordDecl, isPOD) { return Node.isPOD(); }
87+
AST_MATCHER(CXXRecordDecl, isPOD) {
88+
return Node.hasDefinition() && Node.isPOD();
89+
}
8690

8791
AST_MATCHER(InitListExpr, isFullyDesignated) {
8892
if (const InitListExpr *SyntacticForm =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct CognitiveComplexity final {
126126
// Limit of 25 is the "upstream"'s default.
127127
static constexpr unsigned DefaultLimit = 25U;
128128

129-
// Based on the publicly-avaliable numbers for some big open-source projects
129+
// Based on the publicly-available numbers for some big open-source projects
130130
// https://sonarcloud.io/projects?languages=c%2Ccpp&size=5 we can estimate:
131131
// value ~20 would result in no allocs for 98% of functions, ~12 for 96%, ~10
132132
// for 91%, ~8 for 88%, ~6 for 84%, ~4 for 77%, ~2 for 64%, and ~1 for 37%.

0 commit comments

Comments
 (0)