Skip to content

Commit 66652e0

Browse files
committed
Merge branch 'main' into fix-tailcall-medium
2 parents a862a17 + 862074f commit 66652e0

File tree

2,068 files changed

+124767
-40813
lines changed

Some content is hidden

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

2,068 files changed

+124767
-40813
lines changed

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/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-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/clangd/ModulesBuilder.cpp

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "clang/Frontend/FrontendAction.h"
1313
#include "clang/Frontend/FrontendActions.h"
1414
#include "clang/Serialization/ASTReader.h"
15+
#include "clang/Serialization/InMemoryModuleCache.h"
1516

1617
namespace clang {
1718
namespace clangd {
@@ -127,50 +128,68 @@ struct ModuleFile {
127128
std::string ModuleFilePath;
128129
};
129130

130-
bool IsModuleFileUpToDate(
131-
PathRef ModuleFilePath,
132-
const PrerequisiteModules &RequisiteModules) {
133-
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
134-
CompilerInstance::createDiagnostics(new DiagnosticOptions());
135-
131+
bool IsModuleFileUpToDate(PathRef ModuleFilePath,
132+
const PrerequisiteModules &RequisiteModules,
133+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
136134
auto HSOpts = std::make_shared<HeaderSearchOptions>();
137135
RequisiteModules.adjustHeaderSearchOptions(*HSOpts);
138136
HSOpts->ForceCheckCXX20ModulesInputFiles = true;
139137
HSOpts->ValidateASTInputFilesContent = true;
140138

139+
clang::clangd::IgnoreDiagnostics IgnoreDiags;
140+
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
141+
CompilerInstance::createDiagnostics(new DiagnosticOptions, &IgnoreDiags,
142+
/*ShouldOwnClient=*/false);
143+
144+
LangOptions LangOpts;
145+
LangOpts.SkipODRCheckInGMF = true;
146+
147+
FileManager FileMgr(FileSystemOptions(), VFS);
148+
149+
SourceManager SourceMgr(*Diags, FileMgr);
150+
151+
HeaderSearch HeaderInfo(HSOpts, SourceMgr, *Diags, LangOpts,
152+
/*Target=*/nullptr);
153+
154+
TrivialModuleLoader ModuleLoader;
155+
Preprocessor PP(std::make_shared<PreprocessorOptions>(), *Diags, LangOpts,
156+
SourceMgr, HeaderInfo, ModuleLoader);
157+
158+
IntrusiveRefCntPtr<InMemoryModuleCache> ModuleCache = new InMemoryModuleCache;
141159
PCHContainerOperations PCHOperations;
142-
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
143-
ModuleFilePath.str(), PCHOperations.getRawReader(), ASTUnit::LoadASTOnly,
144-
Diags, FileSystemOptions(), std::move(HSOpts));
160+
ASTReader Reader(PP, *ModuleCache, /*ASTContext=*/nullptr,
161+
PCHOperations.getRawReader(), {});
145162

146-
if (!Unit)
147-
return false;
163+
// We don't need any listener here. By default it will use a validator
164+
// listener.
165+
Reader.setListener(nullptr);
148166

149-
auto Reader = Unit->getASTReader();
150-
if (!Reader)
167+
if (Reader.ReadAST(ModuleFilePath, serialization::MK_MainFile,
168+
SourceLocation(),
169+
ASTReader::ARR_None) != ASTReader::Success)
151170
return false;
152171

153172
bool UpToDate = true;
154-
Reader->getModuleManager().visit([&](serialization::ModuleFile &MF) -> bool {
155-
Reader->visitInputFiles(
173+
Reader.getModuleManager().visit([&](serialization::ModuleFile &MF) -> bool {
174+
Reader.visitInputFiles(
156175
MF, /*IncludeSystem=*/false, /*Complain=*/false,
157176
[&](const serialization::InputFile &IF, bool isSystem) {
158177
if (!IF.getFile() || IF.isOutOfDate())
159178
UpToDate = false;
160179
});
161-
162180
return !UpToDate;
163181
});
164-
165182
return UpToDate;
166183
}
167184

168185
bool IsModuleFilesUpToDate(
169186
llvm::SmallVector<PathRef> ModuleFilePaths,
170-
const PrerequisiteModules &RequisiteModules) {
171-
return llvm::all_of(ModuleFilePaths, [&RequisiteModules](auto ModuleFilePath) {
172-
return IsModuleFileUpToDate(ModuleFilePath, RequisiteModules);
173-
});
187+
const PrerequisiteModules &RequisiteModules,
188+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
189+
return llvm::all_of(
190+
ModuleFilePaths, [&RequisiteModules, VFS](auto ModuleFilePath) {
191+
return IsModuleFileUpToDate(ModuleFilePath, RequisiteModules, VFS);
192+
});
174193
}
175194

176195
// StandalonePrerequisiteModules - stands for PrerequisiteModules for which all
@@ -347,7 +366,7 @@ bool StandalonePrerequisiteModules::canReuse(
347366
SmallVector<StringRef> BMIPaths;
348367
for (auto &MF : RequiredModules)
349368
BMIPaths.push_back(MF.ModuleFilePath);
350-
return IsModuleFilesUpToDate(BMIPaths, *this);
369+
return IsModuleFilesUpToDate(BMIPaths, *this, VFS);
351370
}
352371

353372
} // namespace clangd

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ Changes in existing checks
163163
<clang-tidy/checks/bugprone/posix-return>` check to support integer literals
164164
as LHS and posix call as RHS of comparison.
165165

166+
- Improved :doc:`bugprone-return-const-ref-from-parameter
167+
<clang-tidy/checks/bugprone/return-const-ref-from-parameter>` check to
168+
diagnose potential dangling references when returning a ``const &`` parameter
169+
by using the conditional operator ``cond ? var1 : var2``.
170+
166171
- Improved :doc:`bugprone-sizeof-expression
167172
<clang-tidy/checks/bugprone/sizeof-expression>` check to find suspicious
168173
usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or
@@ -216,6 +221,10 @@ Changes in existing checks
216221
a false positive when only an implicit conversion happened inside an
217222
initializer list.
218223

224+
- Improved :doc:`modernize-use-designated-initializers
225+
<clang-tidy/checks/modernize/use-designated-initializers>` check to fix a
226+
crash when a class is declared but not defined.
227+
219228
- Improved :doc:`modernize-use-nullptr
220229
<clang-tidy/checks/modernize/use-nullptr>` check to also recognize
221230
``NULL``/``__null`` (but not ``0``) when used with a templated type.

clang-tools-extra/test/clang-tidy/checkers/bugprone/return-const-ref-from-parameter.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ int const &f3(TConstRef a) { return a; }
2727
int const &f4(TConst &a) { return a; }
2828
// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: returning a constant reference parameter
2929

30+
int const &f5(TConst &a) { return true ? a : a; }
31+
// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: returning a constant reference parameter
32+
// CHECK-MESSAGES: :[[@LINE-2]]:46: warning: returning a constant reference parameter
33+
3034
template <typename T>
3135
const T& tf1(const T &a) { return a; }
3236
// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: returning a constant reference parameter
@@ -47,6 +51,11 @@ template <typename T>
4751
const T& itf4(typename ConstRef<T>::type a) { return a; }
4852
// CHECK-MESSAGES: :[[@LINE-1]]:54: warning: returning a constant reference parameter
4953

54+
template <typename T>
55+
const T& itf5(const T &a) { return true ? a : a; }
56+
// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: returning a constant reference parameter
57+
// CHECK-MESSAGES: :[[@LINE-2]]:47: warning: returning a constant reference parameter
58+
5059
void instantiate(const int &param, const float &paramf, int &mut_param, float &mut_paramf) {
5160
itf1(0);
5261
itf1(param);

clang-tools-extra/test/clang-tidy/checkers/modernize/use-designated-initializers.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,11 @@ DECLARE_S93;
201201
// CHECK-MESSAGES-MACROS: :[[@LINE-1]]:1: warning: use designated initializer list to initialize 'S9' [modernize-use-designated-initializers]
202202
// CHECK-MESSAGES-MACROS: :[[@LINE-4]]:28: note: expanded from macro 'DECLARE_S93'
203203
// CHECK-MESSAGES-MACROS: :[[@LINE-71]]:1: note: aggregate type is defined here
204+
205+
// Issue #113652.
206+
struct S14;
207+
208+
struct S15{
209+
S15(S14& d):d{d}{}
210+
S14& d;
211+
};

clang/Maintainers.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ AST matchers
3333
| aaron\@aaronballman.com (email), aaron.ballman (Phabricator), AaronBallman (GitHub), AaronBallman (Discourse), aaronballman (Discord), AaronBallman (IRC)
3434
3535

36+
AST Visitors
37+
~~~~~~~~~~~~
38+
| Sirraide
39+
| aeternalmail\@gmail.com (email), Sirraide (GitHub), Ætérnal (Discord), Sirraide (Discourse)
40+
41+
3642
Clang LLVM IR generation
3743
~~~~~~~~~~~~~~~~~~~~~~~~
3844
| John McCall
@@ -57,6 +63,12 @@ Analysis & CFG
5763
| sgatev\@google.com (email), sgatev (Phabricator), sgatev (GitHub)
5864
5965

66+
Sema
67+
~~~~
68+
| Sirraide
69+
| aeternalmail\@gmail.com (email), Sirraide (GitHub), Ætérnal (Discord), Sirraide (Discourse)
70+
71+
6072
Experimental new constant interpreter
6173
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6274
| Timm Bäder
@@ -71,13 +83,22 @@ Modules & serialization
7183
| Michael Spencer
7284
| bigcheesegs\@gmail.com (email), Bigcheese (Phabricator), Bigcheese (GitHub)
7385
86+
| Vassil Vassilev
87+
| Vassil.Vassilev\@cern.ch (email), v.g.vassilev (Phabricator), vgvassilev (GitHub)
88+
7489

7590
Templates
7691
~~~~~~~~~
7792
| Erich Keane
7893
| ekeane\@nvidia.com (email), ErichKeane (Phabricator), erichkeane (GitHub)
7994
8095

96+
Lambdas
97+
~~~~~~~
98+
| Corentin Jabot
99+
| corentin.jabot\@gmail.com (email), cor3ntin (Phabricator), cor3ntin (GitHub)
100+
101+
81102
Debug information
82103
~~~~~~~~~~~~~~~~~
83104
| Adrian Prantl
@@ -172,6 +193,12 @@ Attributes
172193
| ekeane\@nvidia.com (email), ErichKeane (Phabricator), erichkeane (GitHub)
173194
174195

196+
Plugins
197+
~~~~~~~
198+
| Vassil Vassilev
199+
| Vassil.Vassilev\@cern.ch (email), v.g.vassilev (Phabricator), vgvassilev (GitHub)
200+
201+
175202
Inline assembly
176203
~~~~~~~~~~~~~~~
177204
| Eric Christopher
@@ -225,6 +252,18 @@ C++ conformance
225252
| Hubert Tong
226253
| hubert.reinterpretcast\@gmail.com (email), hubert.reinterpretcast (Phabricator), hubert-reinterpretcast (GitHub)
227254
255+
| Shafik Yaghmour
256+
| shafik.yaghmour\@intel.com (email), shafik (GitHub), shafik.yaghmour (Discord), shafik (Discourse)
257+
258+
| Vlad Serebrennikov
259+
| serebrennikov.vladislav\@gmail.com (email), Endilll (GitHub), Endill (Discord), Endill (Discourse)
260+
261+
262+
C++ Defect Reports
263+
~~~~~~~~~~~~~~~~~~
264+
| Vlad Serebrennikov
265+
| serebrennikov.vladislav\@gmail.com (email), Endilll (GitHub), Endill (Discord), Endill (Discourse)
266+
228267

229268
Objective-C/C++ conformance
230269
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -244,6 +283,12 @@ OpenCL conformance
244283
| anastasia\@compiler-experts.com (email), Anastasia (Phabricator), AnastasiaStulova (GitHub)
245284
246285

286+
OpenACC
287+
~~~~~~~
288+
| Erich Keane
289+
| ekeane\@nvidia.com (email), ErichKeane (Phabricator), erichkeane (GitHub)
290+
291+
247292
SYCL conformance
248293
~~~~~~~~~~~~~~~~
249294
| Alexey Bader

clang/docs/AddressSanitizer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Typical slowdown introduced by AddressSanitizer is **2x**.
2626
How to build
2727
============
2828

29-
Build LLVM/Clang with `CMake <https://llvm.org/docs/CMake.html>` and enable
29+
Build LLVM/Clang with `CMake <https://llvm.org/docs/CMake.html>`_ and enable
3030
the ``compiler-rt`` runtime. An example CMake configuration that will allow
3131
for the use/testing of AddressSanitizer:
3232

0 commit comments

Comments
 (0)