Skip to content

Commit d17364b

Browse files
authored
Merge branch 'main' into pr/riscv-inx-no-x0
2 parents 99a232d + 4995d09 commit d17364b

File tree

1,438 files changed

+71231
-29547
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,438 files changed

+71231
-29547
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Checkout as native, commit as LF except in specific circumstances
2+
* text=auto
3+
*.bat text eol=crlf
4+
*.rc text eol=crlf
5+
*.sln text eol=crlf
6+
*.natvis text eol=crlf
7+
18
libcxx/src/**/*.cpp merge=libcxx-reformat
29
libcxx/include/**/*.h merge=libcxx-reformat
310

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class DIEBuilder {
314314

315315
BC.errs()
316316
<< "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
317-
<< DU.getOffset() << "\n";
317+
<< Twine::utohexstr(DU.getOffset()) << "\n";
318318
return nullptr;
319319
}
320320

bolt/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,8 @@ bool BinaryContext::handleAArch64Veneer(uint64_t Address, bool MatchOnly) {
12941294
Veneer->getOrCreateLocalLabel(Address);
12951295
Veneer->setMaxSize(TotalSize);
12961296
Veneer->updateState(BinaryFunction::State::Disassembled);
1297-
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: handling veneer function at 0x" << Address
1298-
<< "\n");
1297+
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: handling veneer function at 0x"
1298+
<< Twine::utohexstr(Address) << "\n");
12991299
return true;
13001300
};
13011301

bolt/lib/Passes/LongJmp.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,8 @@ uint64_t LongJmpPass::tentativeLayoutRelocColdPart(
324324
uint64_t LongJmpPass::tentativeLayoutRelocMode(
325325
const BinaryContext &BC, std::vector<BinaryFunction *> &SortedFunctions,
326326
uint64_t DotAddress) {
327-
328327
// Compute hot cold frontier
329-
uint32_t LastHotIndex = -1u;
328+
int64_t LastHotIndex = -1u;
330329
uint32_t CurrentIndex = 0;
331330
if (opts::HotFunctionsAtEnd) {
332331
for (BinaryFunction *BF : SortedFunctions) {
@@ -351,19 +350,20 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
351350
// Hot
352351
CurrentIndex = 0;
353352
bool ColdLayoutDone = false;
353+
auto runColdLayout = [&]() {
354+
DotAddress = tentativeLayoutRelocColdPart(BC, SortedFunctions, DotAddress);
355+
ColdLayoutDone = true;
356+
if (opts::HotFunctionsAtEnd)
357+
DotAddress = alignTo(DotAddress, opts::AlignText);
358+
};
354359
for (BinaryFunction *Func : SortedFunctions) {
355360
if (!BC.shouldEmit(*Func)) {
356361
HotAddresses[Func] = Func->getAddress();
357362
continue;
358363
}
359364

360-
if (!ColdLayoutDone && CurrentIndex >= LastHotIndex) {
361-
DotAddress =
362-
tentativeLayoutRelocColdPart(BC, SortedFunctions, DotAddress);
363-
ColdLayoutDone = true;
364-
if (opts::HotFunctionsAtEnd)
365-
DotAddress = alignTo(DotAddress, opts::AlignText);
366-
}
365+
if (!ColdLayoutDone && CurrentIndex >= LastHotIndex)
366+
runColdLayout();
367367

368368
DotAddress = alignTo(DotAddress, Func->getMinAlignment());
369369
uint64_t Pad =
@@ -382,6 +382,11 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
382382
DotAddress += Func->estimateConstantIslandSize();
383383
++CurrentIndex;
384384
}
385+
386+
// Ensure that tentative code layout always runs for cold blocks.
387+
if (!ColdLayoutDone)
388+
runColdLayout();
389+
385390
// BBs
386391
for (BinaryFunction *Func : SortedFunctions)
387392
tentativeBBLayout(*Func);

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ void DWARFRewriter::updateDWARFObjectAddressRanges(
13621362
Die.getTag() == dwarf::DW_TAG_compile_unit)) {
13631363
if (opts::Verbosity >= 1)
13641364
errs() << "BOLT-WARNING: cannot update ranges for DIE in Unit offset 0x"
1365-
<< Unit.getOffset() << '\n';
1365+
<< Twine::utohexstr(Unit.getOffset()) << '\n';
13661366
}
13671367
}
13681368

bolt/test/AArch64/split-funcs-lite.s

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This test checks that tentative code layout for cold blocks always runs.
2+
# It commonly happens when using lite mode with split functions.
3+
4+
# REQUIRES: system-linux, asserts
5+
6+
# RUN: %clang %cflags -o %t %s
7+
# RUN: %clang %s %cflags -Wl,-q -o %t
8+
# RUN: link_fdata --no-lbr %s %t %t.fdata
9+
# RUN: llvm-bolt %t -o %t.bolt --data %t.fdata -split-functions \
10+
# RUN: -debug 2>&1 | FileCheck %s
11+
12+
.text
13+
.globl foo
14+
.type foo, %function
15+
foo:
16+
.entry_bb:
17+
# FDATA: 1 foo #.entry_bb# 10
18+
cmp x0, #0
19+
b.eq .Lcold_bb1
20+
ret
21+
.Lcold_bb1:
22+
ret
23+
24+
## Force relocation mode.
25+
.reloc 0, R_AARCH64_NONE
26+
27+
# CHECK: foo{{.*}} cold tentative: {{.*}}

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ ClangTidyASTConsumerFactory::createASTConsumer(
458458
if (!AnalyzerOptions.CheckersAndPackages.empty()) {
459459
setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
460460
AnalyzerOptions.AnalysisDiagOpt = PD_NONE;
461-
AnalyzerOptions.eagerlyAssumeBinOpBifurcation = true;
462461
std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer =
463462
ento::CreateAnalysisConsumer(Compiler);
464463
AnalysisConsumer->AddDiagnosticConsumer(

clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88

99
#include "UseInternalLinkageCheck.h"
1010
#include "../utils/FileExtensionsUtils.h"
11+
#include "../utils/LexerUtils.h"
1112
#include "clang/AST/Decl.h"
1213
#include "clang/ASTMatchers/ASTMatchFinder.h"
1314
#include "clang/ASTMatchers/ASTMatchers.h"
1415
#include "clang/ASTMatchers/ASTMatchersMacros.h"
1516
#include "clang/Basic/SourceLocation.h"
1617
#include "clang/Basic/Specifiers.h"
18+
#include "clang/Basic/TokenKinds.h"
19+
#include "clang/Lex/Token.h"
1720
#include "llvm/ADT/STLExtras.h"
1821

1922
using namespace clang::ast_matchers;
@@ -113,7 +116,7 @@ static constexpr StringRef Message =
113116
void UseInternalLinkageCheck::check(const MatchFinder::MatchResult &Result) {
114117
if (const auto *FD = Result.Nodes.getNodeAs<FunctionDecl>("fn")) {
115118
DiagnosticBuilder DB = diag(FD->getLocation(), Message) << "function" << FD;
116-
SourceLocation FixLoc = FD->getTypeSpecStartLoc();
119+
const SourceLocation FixLoc = FD->getInnerLocStart();
117120
if (FixLoc.isInvalid() || FixLoc.isMacroID())
118121
return;
119122
if (FixMode == FixModeKind::UseStatic)
@@ -128,7 +131,7 @@ void UseInternalLinkageCheck::check(const MatchFinder::MatchResult &Result) {
128131
return;
129132

130133
DiagnosticBuilder DB = diag(VD->getLocation(), Message) << "variable" << VD;
131-
SourceLocation FixLoc = VD->getTypeSpecStartLoc();
134+
const SourceLocation FixLoc = VD->getInnerLocStart();
132135
if (FixLoc.isInvalid() || FixLoc.isMacroID())
133136
return;
134137
if (FixMode == FixModeKind::UseStatic)

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

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#include "UseStartsEndsWithCheck.h"
1010

1111
#include "../utils/ASTUtils.h"
12-
#include "../utils/OptionsUtils.h"
12+
#include "../utils/Matchers.h"
13+
#include "clang/ASTMatchers/ASTMatchers.h"
1314
#include "clang/Lex/Lexer.h"
1415

1516
#include <string>
@@ -82,60 +83,53 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef Name,
8283
void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
8384
const auto ZeroLiteral = integerLiteral(equals(0));
8485

85-
const auto HasStartsWithMethodWithName = [](const std::string &Name) {
86-
return hasMethod(
87-
cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
88-
.bind("starts_with_fun"));
86+
const auto ClassTypeWithMethod = [](const StringRef MethodBoundName,
87+
const auto... Methods) {
88+
return cxxRecordDecl(anyOf(
89+
hasMethod(cxxMethodDecl(isConst(), parameterCountIs(1),
90+
returns(booleanType()), hasAnyName(Methods))
91+
.bind(MethodBoundName))...));
8992
};
90-
const auto HasStartsWithMethod =
91-
anyOf(HasStartsWithMethodWithName("starts_with"),
92-
HasStartsWithMethodWithName("startsWith"),
93-
HasStartsWithMethodWithName("startswith"));
93+
9494
const auto OnClassWithStartsWithFunction =
95-
on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
96-
anyOf(HasStartsWithMethod,
97-
hasAnyBase(hasType(hasCanonicalType(
98-
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)))))))))));
99-
100-
const auto HasEndsWithMethodWithName = [](const std::string &Name) {
101-
return hasMethod(
102-
cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
103-
.bind("ends_with_fun"));
104-
};
105-
const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
106-
HasEndsWithMethodWithName("endsWith"),
107-
HasEndsWithMethodWithName("endswith"));
108-
const auto OnClassWithEndsWithFunction =
109-
on(expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
110-
anyOf(HasEndsWithMethod,
111-
hasAnyBase(hasType(hasCanonicalType(hasDeclaration(
112-
cxxRecordDecl(HasEndsWithMethod)))))))))))
113-
.bind("haystack"));
95+
ClassTypeWithMethod("starts_with_fun", "starts_with", "startsWith",
96+
"startswith", "StartsWith");
97+
98+
const auto OnClassWithEndsWithFunction = ClassTypeWithMethod(
99+
"ends_with_fun", "ends_with", "endsWith", "endswith", "EndsWith");
114100

115101
// Case 1: X.find(Y) [!=]= 0 -> starts_with.
116102
const auto FindExpr = cxxMemberCallExpr(
117103
anyOf(argumentCountIs(1), hasArgument(1, ZeroLiteral)),
118-
callee(cxxMethodDecl(hasName("find")).bind("find_fun")),
119-
OnClassWithStartsWithFunction, hasArgument(0, expr().bind("needle")));
104+
callee(
105+
cxxMethodDecl(hasName("find"), ofClass(OnClassWithStartsWithFunction))
106+
.bind("find_fun")),
107+
hasArgument(0, expr().bind("needle")));
120108

121109
// Case 2: X.rfind(Y, 0) [!=]= 0 -> starts_with.
122110
const auto RFindExpr = cxxMemberCallExpr(
123111
hasArgument(1, ZeroLiteral),
124-
callee(cxxMethodDecl(hasName("rfind")).bind("find_fun")),
125-
OnClassWithStartsWithFunction, hasArgument(0, expr().bind("needle")));
112+
callee(cxxMethodDecl(hasName("rfind"),
113+
ofClass(OnClassWithStartsWithFunction))
114+
.bind("find_fun")),
115+
hasArgument(0, expr().bind("needle")));
126116

127117
// Case 3: X.compare(0, LEN(Y), Y) [!=]= 0 -> starts_with.
128118
const auto CompareExpr = cxxMemberCallExpr(
129119
argumentCountIs(3), hasArgument(0, ZeroLiteral),
130-
callee(cxxMethodDecl(hasName("compare")).bind("find_fun")),
131-
OnClassWithStartsWithFunction, hasArgument(2, expr().bind("needle")),
120+
callee(cxxMethodDecl(hasName("compare"),
121+
ofClass(OnClassWithStartsWithFunction))
122+
.bind("find_fun")),
123+
hasArgument(2, expr().bind("needle")),
132124
hasArgument(1, lengthExprForStringNode("needle")));
133125

134126
// Case 4: X.compare(LEN(X) - LEN(Y), LEN(Y), Y) [!=]= 0 -> ends_with.
135127
const auto CompareEndsWithExpr = cxxMemberCallExpr(
136128
argumentCountIs(3),
137-
callee(cxxMethodDecl(hasName("compare")).bind("find_fun")),
138-
OnClassWithEndsWithFunction, hasArgument(2, expr().bind("needle")),
129+
callee(cxxMethodDecl(hasName("compare"),
130+
ofClass(OnClassWithEndsWithFunction))
131+
.bind("find_fun")),
132+
on(expr().bind("haystack")), hasArgument(2, expr().bind("needle")),
139133
hasArgument(1, lengthExprForStringNode("needle")),
140134
hasArgument(0,
141135
binaryOperator(hasOperatorName("-"),
@@ -145,7 +139,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
145139
// All cases comparing to 0.
146140
Finder->addMatcher(
147141
binaryOperator(
148-
hasAnyOperatorName("==", "!="),
142+
matchers::isEqualityOperator(),
149143
hasOperands(cxxMemberCallExpr(anyOf(FindExpr, RFindExpr, CompareExpr,
150144
CompareEndsWithExpr))
151145
.bind("find_expr"),
@@ -156,7 +150,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
156150
// Case 5: X.rfind(Y) [!=]= LEN(X) - LEN(Y) -> ends_with.
157151
Finder->addMatcher(
158152
binaryOperator(
159-
hasAnyOperatorName("==", "!="),
153+
matchers::isEqualityOperator(),
160154
hasOperands(
161155
cxxMemberCallExpr(
162156
anyOf(
@@ -166,8 +160,10 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
166160
1,
167161
anyOf(declRefExpr(to(varDecl(hasName("npos")))),
168162
memberExpr(member(hasName("npos"))))))),
169-
callee(cxxMethodDecl(hasName("rfind")).bind("find_fun")),
170-
OnClassWithEndsWithFunction,
163+
callee(cxxMethodDecl(hasName("rfind"),
164+
ofClass(OnClassWithEndsWithFunction))
165+
.bind("find_fun")),
166+
on(expr().bind("haystack")),
171167
hasArgument(0, expr().bind("needle")))
172168
.bind("find_expr"),
173169
binaryOperator(hasOperatorName("-"),
@@ -190,9 +186,8 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) {
190186
const CXXMethodDecl *ReplacementFunction =
191187
StartsWithFunction ? StartsWithFunction : EndsWithFunction;
192188

193-
if (ComparisonExpr->getBeginLoc().isMacroID()) {
189+
if (ComparisonExpr->getBeginLoc().isMacroID())
194190
return;
195-
}
196191

197192
const bool Neg = ComparisonExpr->getOpcode() == BO_NE;
198193

@@ -220,9 +215,8 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) {
220215
(ReplacementFunction->getName() + "(").str());
221216

222217
// Add possible negation '!'.
223-
if (Neg) {
218+
if (Neg)
224219
Diagnostic << FixItHint::CreateInsertion(FindExpr->getBeginLoc(), "!");
225-
}
226220
}
227221

228222
} // namespace clang::tidy::modernize

clang-tools-extra/clang-tidy/utils/LexerUtils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ getPreviousTokenAndStart(SourceLocation Location, const SourceManager &SM,
2424
if (Location.isInvalid())
2525
return {Token, Location};
2626

27-
auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
27+
const auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
2828
while (Location != StartOfFile) {
2929
Location = Lexer::GetBeginningOfToken(Location, SM, LangOpts);
3030
if (!Lexer::getRawToken(Location, Token, SM, LangOpts) &&
3131
(!SkipComments || !Token.is(tok::comment))) {
3232
break;
3333
}
34+
if (Location == StartOfFile)
35+
return {Token, Location};
3436
Location = Location.getLocWithOffset(-1);
3537
}
3638
return {Token, Location};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
input-mirror.test text eol=crlf
2+
too_large.test text eol=crlf
3+
protocol.test text eol=crlf
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# RUN: clangd -pretty -sync -input-mirror-file %t < %s
2-
# Note that we have to use '-b' as -input-mirror-file does not have a newline at the end of file.
3-
# RUN: diff -b %t %s
4-
# It is absolutely vital that this file has CRLF line endings.
5-
#
6-
Content-Length: 125
7-
8-
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
9-
Content-Length: 172
10-
11-
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}}
12-
Content-Length: 44
13-
14-
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
15-
Content-Length: 33
16-
17-
{"jsonrpc":"2.0","method":"exit"}
1+
# RUN: clangd -pretty -sync -input-mirror-file %t < %s
2+
# Note that we have to use '-b' as -input-mirror-file does not have a newline at the end of file.
3+
# RUN: diff -b %t %s
4+
# It is absolutely vital that this file has CRLF line endings.
5+
#
6+
Content-Length: 125
7+
8+
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
9+
Content-Length: 172
10+
11+
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}}
12+
Content-Length: 44
13+
14+
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
15+
Content-Length: 33
16+
17+
{"jsonrpc":"2.0","method":"exit"}

0 commit comments

Comments
 (0)