Skip to content

Commit 2fbe932

Browse files
authored
merge main into amd-staging (#812)
2 parents b74cc7d + 0297af0 commit 2fbe932

File tree

188 files changed

+5993
-5748
lines changed

Some content is hidden

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

188 files changed

+5993
-5748
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ concurrency:
3636
jobs:
3737
stage1:
3838
if: github.repository_owner == 'llvm'
39-
runs-on: llvm-premerge-libcxx-runners
39+
runs-on: llvm-premerge-libcxx-next-runners
4040
continue-on-error: false
4141
strategy:
4242
fail-fast: false
@@ -73,7 +73,7 @@ jobs:
7373
**/crash_diagnostics/*
7474
stage2:
7575
if: github.repository_owner == 'llvm'
76-
runs-on: llvm-premerge-libcxx-runners
76+
runs-on: llvm-premerge-libcxx-next-runners
7777
needs: [ stage1 ]
7878
continue-on-error: false
7979
strategy:
@@ -148,19 +148,19 @@ jobs:
148148
'generic-static',
149149
'bootstrapping-build'
150150
]
151-
machine: [ 'llvm-premerge-libcxx-runners' ]
151+
machine: [ 'llvm-premerge-libcxx-next-runners' ]
152152
include:
153153
- config: 'generic-cxx26'
154-
machine: llvm-premerge-libcxx-runners
154+
machine: llvm-premerge-libcxx-next-runners
155155
- config: 'generic-asan'
156-
machine: llvm-premerge-libcxx-runners
156+
machine: llvm-premerge-libcxx-next-runners
157157
- config: 'generic-tsan'
158-
machine: llvm-premerge-libcxx-runners
158+
machine: llvm-premerge-libcxx-next-runners
159159
- config: 'generic-ubsan'
160-
machine: llvm-premerge-libcxx-runners
160+
machine: llvm-premerge-libcxx-next-runners
161161
# Use a larger machine for MSAN to avoid timeout and memory allocation issues.
162162
- config: 'generic-msan'
163-
machine: llvm-premerge-libcxx-runners
163+
machine: llvm-premerge-libcxx-next-runners
164164
runs-on: ${{ matrix.machine }}
165165
steps:
166166
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,11 +735,12 @@ class BinaryFunction {
735735
Symbols.push_back(BC.Ctx->getOrCreateSymbol(Name));
736736
}
737737

738-
/// This constructor is used to create an injected function
738+
/// This constructor is used to create an injected function, i.e. a function
739+
/// that didn't originate in the input file.
739740
BinaryFunction(const std::string &Name, BinaryContext &BC, bool IsSimple)
740741
: Address(0), Size(0), BC(BC), IsSimple(IsSimple),
741-
CodeSectionName(buildCodeSectionName(Name, BC)),
742-
ColdCodeSectionName(buildColdCodeSectionName(Name, BC)),
742+
CodeSectionName(BC.getInjectedCodeSectionName()),
743+
ColdCodeSectionName(BC.getInjectedColdCodeSectionName()),
743744
FunctionNumber(++Count) {
744745
Symbols.push_back(BC.Ctx->getOrCreateSymbol(Name));
745746
IsInjected = true;
@@ -2582,6 +2583,10 @@ class BinaryFunction {
25822583
/// Return true if the function is an AArch64 linker inserted veneer
25832584
bool isAArch64Veneer() const;
25842585

2586+
/// Return true if the function signature matches veneer or it was established
2587+
/// to be a veneer.
2588+
bool isPossibleVeneer() const;
2589+
25852590
virtual ~BinaryFunction();
25862591
};
25872592

bolt/lib/Core/BinaryContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,6 +2598,10 @@ BinaryContext::createInstructionPatch(uint64_t Address,
25982598
PBF->addBasicBlock()->addInstructions(Instructions);
25992599
PBF->setIsPatch(true);
26002600

2601+
// Patch functions have to be emitted each into their unique section.
2602+
PBF->setCodeSectionName(
2603+
BinaryFunction::buildCodeSectionName(PBF->getOneName(), *this));
2604+
26012605
// Don't create symbol table entry if the name wasn't specified.
26022606
if (Name.str().empty())
26032607
PBF->setAnonymous(true);

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4829,6 +4829,11 @@ bool BinaryFunction::isAArch64Veneer() const {
48294829
return true;
48304830
}
48314831

4832+
bool BinaryFunction::isPossibleVeneer() const {
4833+
return BC.isAArch64() &&
4834+
(isAArch64Veneer() || getOneName().starts_with("__AArch64"));
4835+
}
4836+
48324837
void BinaryFunction::addRelocation(uint64_t Address, MCSymbol *Symbol,
48334838
uint32_t RelType, uint64_t Addend,
48344839
uint64_t Value) {

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,13 +1276,6 @@ Error SimplifyRODataLoads::runOnFunctions(BinaryContext &BC) {
12761276
}
12771277

12781278
Error AssignSections::runOnFunctions(BinaryContext &BC) {
1279-
for (BinaryFunction *Function : BC.getInjectedBinaryFunctions()) {
1280-
if (!Function->isPatch()) {
1281-
Function->setCodeSectionName(BC.getInjectedCodeSectionName());
1282-
Function->setColdCodeSectionName(BC.getInjectedColdCodeSectionName());
1283-
}
1284-
}
1285-
12861279
// In non-relocation mode functions have pre-assigned section names.
12871280
if (!BC.HasRelocations)
12881281
return Error::success();

bolt/lib/Passes/VeneerElimination.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,14 @@ static llvm::cl::opt<bool>
2929
namespace llvm {
3030
namespace bolt {
3131

32-
static bool isPossibleVeneer(const BinaryFunction &BF) {
33-
return BF.isAArch64Veneer() || BF.getOneName().starts_with("__AArch64");
34-
}
35-
3632
Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
3733
if (!opts::EliminateVeneers || !BC.isAArch64())
3834
return Error::success();
3935

4036
std::unordered_map<const MCSymbol *, const MCSymbol *> VeneerDestinations;
4137
uint64_t NumEliminatedVeneers = 0;
4238
for (BinaryFunction &BF : llvm::make_second_range(BC.getBinaryFunctions())) {
43-
if (!isPossibleVeneer(BF))
39+
if (!BF.isPossibleVeneer())
4440
continue;
4541

4642
if (BF.isIgnored())

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3374,6 +3374,11 @@ void RewriteInstance::selectFunctionsToProcess() {
33743374
if (mustSkip(Function))
33753375
return false;
33763376

3377+
// Include veneer functions as we want to replace veneer calls with direct
3378+
// ones.
3379+
if (Function.isPossibleVeneer())
3380+
return true;
3381+
33773382
// If the list is not empty, only process functions from the list.
33783383
if (!opts::ForceFunctionNames.empty() || !ForceFunctionsNR.empty()) {
33793384
// Regex check (-funcs and -funcs-file options).

bolt/test/AArch64/veneer-bolt.s

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## Check that llvm-bolt correctly handles veneers in lite mode.
2+
3+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
4+
# RUN: link_fdata %s %t.o %t.fdata
5+
# RUN: llvm-strip --strip-unneeded %t.o
6+
# RUN: %clang %cflags %t.o -o %t.exe -nostdlib -Wl,-q
7+
# RUN: llvm-bolt %t.exe -o %t.bolt --lite=1 --data %t.fdata \
8+
# RUN: --print-normalized 2>&1 | FileCheck %s --check-prefix=CHECK-VENEER
9+
10+
## Constant islands at the end of functions foo(), bar(), and _start() make each
11+
## one of them ~112MB in size. Thus the total code size exceeds 300MB.
12+
13+
.text
14+
.global foo
15+
.type foo, %function
16+
foo:
17+
bl _start
18+
bl bar
19+
ret
20+
.space 0x7000000
21+
.size foo, .-foo
22+
23+
.global bar
24+
.type bar, %function
25+
bar:
26+
bl foo
27+
bl _start
28+
ret
29+
.space 0x7000000
30+
.size bar, .-bar
31+
32+
.global hot
33+
.type hot, %function
34+
hot:
35+
# FDATA: 0 [unknown] 0 1 hot 0 0 100
36+
bl foo
37+
bl bar
38+
bl _start
39+
ret
40+
.size hot, .-hot
41+
42+
## Check that BOLT sees the call to foo, not to its veneer.
43+
# CHECK-VENEER-LABEL: Binary Function "hot"
44+
# CHECK-VENEER: bl
45+
# CHECK-VENEER-SAME: {{[[:space:]]foo[[:space:]]}}
46+
47+
.global _start
48+
.type _start, %function
49+
_start:
50+
bl foo
51+
bl bar
52+
bl hot
53+
ret
54+
.space 0x7000000
55+
.size _start, .-_start
56+

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

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,58 @@
88

99
#include "RedundantControlFlowCheck.h"
1010
#include "clang/ASTMatchers/ASTMatchFinder.h"
11+
#include "clang/ASTMatchers/ASTMatchersMacros.h"
1112
#include "clang/Lex/Lexer.h"
1213

1314
using namespace clang::ast_matchers;
1415

1516
namespace clang::tidy::readability {
1617

17-
static const char *const RedundantReturnDiag =
18+
namespace {
19+
20+
AST_MATCHER_P(CompoundStmt, hasFinalStmt, StatementMatcher, InnerMatcher) {
21+
return !Node.body_empty() &&
22+
InnerMatcher.matches(*Node.body_back(), Finder, Builder);
23+
}
24+
25+
} // namespace
26+
27+
static constexpr StringRef RedundantReturnDiag =
1828
"redundant return statement at the end "
1929
"of a function with a void return type";
20-
static const char *const RedundantContinueDiag =
30+
static constexpr StringRef RedundantContinueDiag =
2131
"redundant continue statement at the "
2232
"end of loop statement";
2333

24-
static bool isLocationInMacroExpansion(const SourceManager &SM,
25-
SourceLocation Loc) {
26-
return SM.isMacroBodyExpansion(Loc) || SM.isMacroArgExpansion(Loc);
27-
}
28-
2934
void RedundantControlFlowCheck::registerMatchers(MatchFinder *Finder) {
3035
Finder->addMatcher(
31-
functionDecl(isDefinition(), returns(voidType()),
32-
hasBody(compoundStmt(hasAnySubstatement(
33-
returnStmt(unless(has(expr())))))
34-
.bind("return"))),
35-
this);
36-
Finder->addMatcher(
37-
mapAnyOf(forStmt, cxxForRangeStmt, whileStmt, doStmt)
38-
.with(hasBody(compoundStmt(hasAnySubstatement(continueStmt()))
39-
.bind("continue"))),
36+
functionDecl(returns(voidType()),
37+
hasBody(compoundStmt(hasFinalStmt(
38+
returnStmt(unless(has(expr()))).bind("stmt"))))),
4039
this);
40+
Finder->addMatcher(mapAnyOf(forStmt, cxxForRangeStmt, whileStmt, doStmt)
41+
.with(hasBody(compoundStmt(
42+
hasFinalStmt(continueStmt().bind("stmt"))))),
43+
this);
4144
}
4245

4346
void RedundantControlFlowCheck::check(const MatchFinder::MatchResult &Result) {
44-
if (const auto *Return = Result.Nodes.getNodeAs<CompoundStmt>("return"))
45-
checkRedundantReturn(Result, Return);
46-
else if (const auto *Continue =
47-
Result.Nodes.getNodeAs<CompoundStmt>("continue"))
48-
checkRedundantContinue(Result, Continue);
49-
}
50-
51-
void RedundantControlFlowCheck::checkRedundantReturn(
52-
const MatchFinder::MatchResult &Result, const CompoundStmt *Block) {
53-
const CompoundStmt::const_reverse_body_iterator Last = Block->body_rbegin();
54-
if (const auto *Return = dyn_cast<ReturnStmt>(*Last))
55-
issueDiagnostic(Result, Block, Return->getSourceRange(),
56-
RedundantReturnDiag);
57-
}
58-
59-
void RedundantControlFlowCheck::checkRedundantContinue(
60-
const MatchFinder::MatchResult &Result, const CompoundStmt *Block) {
61-
const CompoundStmt::const_reverse_body_iterator Last = Block->body_rbegin();
62-
if (const auto *Continue = dyn_cast<ContinueStmt>(*Last))
63-
issueDiagnostic(Result, Block, Continue->getSourceRange(),
64-
RedundantContinueDiag);
65-
}
47+
const auto &RedundantStmt = *Result.Nodes.getNodeAs<Stmt>("stmt");
48+
const SourceRange StmtRange = RedundantStmt.getSourceRange();
6649

67-
void RedundantControlFlowCheck::issueDiagnostic(
68-
const MatchFinder::MatchResult &Result, const CompoundStmt *const Block,
69-
const SourceRange &StmtRange, const char *const Diag) {
70-
const SourceManager &SM = *Result.SourceManager;
71-
if (isLocationInMacroExpansion(SM, StmtRange.getBegin()))
50+
if (StmtRange.getBegin().isMacroID())
7251
return;
7352

7453
const auto RemovedRange = CharSourceRange::getCharRange(
7554
StmtRange.getBegin(),
76-
Lexer::findLocationAfterToken(StmtRange.getEnd(), tok::semi, SM,
77-
getLangOpts(),
55+
Lexer::findLocationAfterToken(StmtRange.getEnd(), tok::semi,
56+
*Result.SourceManager, getLangOpts(),
7857
/*SkipTrailingWhitespaceAndNewLine=*/true));
7958

80-
diag(StmtRange.getBegin(), Diag) << FixItHint::CreateRemoval(RemovedRange);
59+
diag(StmtRange.getBegin(), isa<ReturnStmt>(RedundantStmt)
60+
? RedundantReturnDiag
61+
: RedundantContinueDiag)
62+
<< FixItHint::CreateRemoval(RemovedRange);
8163
}
8264

8365
} // namespace clang::tidy::readability

clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,6 @@ class RedundantControlFlowCheck : public ClangTidyCheck {
3030
std::optional<TraversalKind> getCheckTraversalKind() const override {
3131
return TK_IgnoreUnlessSpelledInSource;
3232
}
33-
34-
private:
35-
void
36-
checkRedundantReturn(const ast_matchers::MatchFinder::MatchResult &Result,
37-
const CompoundStmt *Block);
38-
39-
void
40-
checkRedundantContinue(const ast_matchers::MatchFinder::MatchResult &Result,
41-
const CompoundStmt *Block);
42-
43-
void issueDiagnostic(const ast_matchers::MatchFinder::MatchResult &Result,
44-
const CompoundStmt *Block, const SourceRange &StmtRange,
45-
const char *Diag);
4633
};
4734

4835
} // namespace clang::tidy::readability

0 commit comments

Comments
 (0)