Skip to content

Commit 71157ae

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:5bd1b93cb220 into amd-gfx:18b1fa897044
Local branch amd-gfx 18b1fa8 Merged main:455bf3d1ccd6 into amd-gfx:c7691189ce5b Remote branch main 5bd1b93 Move CallInst::CreateFree to IRBuilderBase
2 parents 18b1fa8 + 5bd1b93 commit 71157ae

File tree

1,299 files changed

+43848
-14506
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,299 files changed

+43848
-14506
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/libcxx/ @llvm/reviewers-libcxx
2+
/libcxxabi/ @llvm/reviewers-libcxxabi
3+
/libunwind/ @llvm/reviewers-libunwind
4+
/runtimes/ @llvm/reviewers-libcxx

.github/new-issues-labeler.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
'new issue':
2-
- '/.*/'
3-
41
'clang':
52
- '/\bclang(?!\-)\b/i'
63

.github/new-prs-labeler.yml

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,26 @@ mlir:
110110
- mlir/**
111111

112112
mlir:core:
113-
- mlir/**/Support/**
114-
- mlir/**/Parser/**
115-
- mlir/**/IR/**
116-
- mlir/**/Bytecode/**
117-
- mlir/**/AsmParser/**
118-
- mlir/**/Pass/**
119-
- mlir/**/tools/**
120-
- mlir/**/Reducer/**
121-
- mlir/**/Transforms/**
122-
- mlir/**/Debug/**
113+
- mlir/include/mlir/Support/**
114+
- mlir/lib/Support/**
115+
- mlir/include/mlir/Parser/**
116+
- mlir/lib/Parser/**
117+
- mlir/include/mlir/IR/**
118+
- mlir/lib/IR/**
119+
- mlir/include/mlir/Bytecode/**
120+
- mlir/lib/Bytecode/**
121+
- mlir/include/mlir/AsmParser/**
122+
- mlir/lib/AsmParser/**
123+
- mlir/include/mlir/Pass/**
124+
- mlir/lib/Pass/**
125+
- mlir/include/mlir/Tools/**
126+
- mlir/lib/Tools/**
127+
- mlir/include/mlir/Reducer/**
128+
- mlir/lib/Reducer/**
129+
- mlir/include/mlir/Transforms/**
130+
- mlir/lib/Transforms/**
131+
- mlir/include/mlir/Debug/**
132+
- mlir/lib/Debug/**
123133
- mlir/tools/**
124134

125135
mlir:ods:
@@ -300,7 +310,10 @@ vectorizers:
300310
- llvm/include/llvm/Transforms/Vectorize/**
301311

302312
clang:
303-
- clang/**
313+
- any:
314+
- clang/**
315+
- '!clang/**/Format/**'
316+
- '!clang/tools/clang-format/**'
304317

305318
testing-tools:
306319
- llvm/include/llvm/FileCheck/**
@@ -510,6 +523,12 @@ llvm:analysis:
510523
- llvm/test/Analysis/**
511524
- llvm/unittests/Analysis/**
512525

526+
llvm:adt:
527+
- llvm/**/ADT/*
528+
529+
llvm:support:
530+
- llvm/**/Support/**
531+
513532
llvm:transforms:
514533
- llvm/lib/Transforms/**
515534
- llvm/include/llvm/Transforms/**
@@ -554,6 +573,13 @@ backend:DirectX:
554573
- '**/*DXIL*/**'
555574
- '**/*dxil*/**'
556575

576+
backend:SPIR-V:
577+
- clang/lib/Driver/ToolChains/SPIRV.*
578+
- llvm/lib/Target/SPIRV/**
579+
- llvm/test/CodeGen/SPIRV/**
580+
- llvm/test/Frontend/HLSL/**
581+
- llvm/docs/SPIRVUsage.rst
582+
557583
mlgo:
558584
- llvm/lib/Analysis/ML*
559585
- llvm/include/llvm/Analysis/ML*

.github/workflows/new-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
if: github.repository == 'llvm/llvm-project'
1515
steps:
16-
- uses: github/issue-labeler@v3.2
16+
- uses: llvm/actions/issue-labeler@main
1717
with:
1818
repo-token: ${{ secrets.GITHUB_TOKEN }}
1919
configuration-path: .github/new-issues-labeler.yml

.github/workflows/pr-receive.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ permissions:
1010
jobs:
1111
pr-target:
1212
runs-on: ubuntu-latest
13-
if: github.repository == 'llvm/llvm-project'
13+
# Ignore PRs with more than 10 commits. Pull requests with a lot of
14+
# commits tend to be accidents usually when someone made a mistake while trying
15+
# to rebase. We want to ignore these pull requests to avoid excessive
16+
# notifications.
17+
if: github.repository == 'llvm/llvm-project' &&
18+
github.event.pull_request.commits < 10
1419
steps:
1520
- name: Store PR Information
1621
run: |

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ class MCPlusBuilder {
437437
virtual bool isUnsupportedBranch(const MCInst &Inst) const { return false; }
438438

439439
/// Return true of the instruction is of pseudo kind.
440-
bool isPseudo(const MCInst &Inst) const {
440+
virtual bool isPseudo(const MCInst &Inst) const {
441441
return Info->get(Inst.getOpcode()).isPseudo();
442442
}
443443

bolt/include/bolt/Passes/FixRISCVCallsPass.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file declares the FixRISCVCallsPass class, which sets the JALR immediate
10-
// to 0 for AUIPC/JALR pairs with a R_RISCV_CALL(_PLT) relocation. This is
11-
// necessary since MC expects it to be zero in order to or-in fixups.
9+
// This file declares the FixRISCVCallsPass class, which replaces all types of
10+
// calls with PseudoCALL pseudo instructions. This ensures that relaxed calls
11+
// get expanded to auipc/jalr pairs so that BOLT can freely reassign function
12+
// addresses without having to worry about the limited range of relaxed calls.
13+
// Using PseudoCALL also ensures that the RISC-V backend inserts the necessary
14+
// relaxation-related relocations to allow JITLink to relax instruction back to
15+
// shorter versions where possible.
1216
//===----------------------------------------------------------------------===//
1317

1418
#ifndef BOLT_PASSES_FIXRISCVCALLSPASS_H

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ BinaryContext::createBinaryContext(const ObjectFile *File, bool IsPIC,
131131
case llvm::Triple::riscv64:
132132
ArchName = "riscv64";
133133
// RV64GC
134-
FeaturesStr = "+m,+a,+f,+d,+zicsr,+zifencei,+c";
134+
FeaturesStr = "+m,+a,+f,+d,+zicsr,+zifencei,+c,+relax";
135135
break;
136136
default:
137137
return createStringError(std::errc::not_supported,

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3156,6 +3156,10 @@ void BinaryFunction::dumpGraphToFile(std::string Filename) const {
31563156
}
31573157

31583158
bool BinaryFunction::validateCFG() const {
3159+
// Skip the validation of CFG after it is finalized
3160+
if (CurrentState == State::CFG_Finalized)
3161+
return true;
3162+
31593163
bool Valid = true;
31603164
for (BinaryBasicBlock *BB : BasicBlocks)
31613165
Valid &= BB->validateSuccessorInvariants();

bolt/lib/Core/Relocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static uint64_t encodeValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
352352
assert(isInt<28>(Value) && "only PC +/- 128MB is allowed for direct call");
353353
// Immediate goes in bits 25:0 of BL.
354354
// OP 1001_01 goes in bits 31:26 of BL.
355-
Value = (Value >> 2) | 0x94000000ULL;
355+
Value = ((Value >> 2) & 0x3ffffff) | 0x94000000ULL;
356356
break;
357357
}
358358
return Value;

bolt/lib/Passes/FixRISCVCallsPass.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,42 @@ namespace bolt {
1010

1111
void FixRISCVCallsPass::runOnFunction(BinaryFunction &BF) {
1212
auto &BC = BF.getBinaryContext();
13+
auto &MIB = BC.MIB;
14+
auto *Ctx = BC.Ctx.get();
1315

1416
for (auto &BB : BF) {
15-
for (auto II = BB.begin(), IE = BB.end(); II != IE; ++II) {
17+
for (auto II = BB.begin(); II != BB.end();) {
18+
if (MIB->isCall(*II) && !MIB->isIndirectCall(*II)) {
19+
auto *Target = MIB->getTargetSymbol(*II);
20+
assert(Target && "Cannot find call target");
21+
22+
auto L = BC.scopeLock();
23+
24+
if (MIB->isTailCall(*II))
25+
MIB->createTailCall(*II, Target, Ctx);
26+
else
27+
MIB->createCall(*II, Target, Ctx);
28+
29+
++II;
30+
continue;
31+
}
32+
1633
auto NextII = std::next(II);
1734

18-
if (NextII == IE)
35+
if (NextII == BB.end())
1936
break;
2037

21-
if (!BC.MIB->isRISCVCall(*II, *NextII))
22-
continue;
38+
if (MIB->isRISCVCall(*II, *NextII)) {
39+
auto *Target = MIB->getTargetSymbol(*II);
40+
assert(Target && "Cannot find call target");
2341

24-
auto L = BC.scopeLock();
42+
auto L = BC.scopeLock();
43+
MIB->createCall(*II, Target, Ctx);
44+
II = BB.eraseInstruction(NextII);
45+
continue;
46+
}
2547

26-
// The MC layer handles R_RISCV_CALL_PLT but assumes that the immediate
27-
// in the JALR is zero (fixups are or'ed into instructions). Note that
28-
// NextII is guaranteed to point to a JALR by isRISCVCall.
29-
NextII->getOperand(2).setImm(0);
48+
++II;
3049
}
3150
}
3251
}

bolt/lib/Passes/TailDuplication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ TailDuplication::aggressiveDuplicate(BinaryBasicBlock &BB,
303303
if (isInCacheLine(BB, Tail))
304304
return BlocksToDuplicate;
305305

306-
BinaryBasicBlock *CurrBB = &BB;
306+
BinaryBasicBlock *CurrBB = &Tail;
307307
while (CurrBB) {
308308
LLVM_DEBUG(dbgs() << "Aggressive tail duplication: adding "
309309
<< CurrBB->getName() << " to duplication list\n";);

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,19 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext &BC) {
294294
buildNameMaps(BC);
295295

296296
// Preliminary assign function execution count.
297-
for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs))
298-
if (BF)
297+
for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs)) {
298+
if (!BF)
299+
continue;
300+
if (!BF->hasProfile()) {
299301
BF->setExecutionCount(YamlBF.ExecCount);
302+
} else {
303+
if (opts::Verbosity >= 1) {
304+
errs() << "BOLT-WARNING: dropping duplicate profile for " << YamlBF.Name
305+
<< '\n';
306+
}
307+
BF = nullptr;
308+
}
309+
}
300310

301311
return Error::success();
302312
}

bolt/lib/Rewrite/JITLinkLinker.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "bolt/Rewrite/JITLinkLinker.h"
99
#include "bolt/Core/BinaryData.h"
1010
#include "bolt/Rewrite/RewriteInstance.h"
11+
#include "llvm/ExecutionEngine/JITLink/ELF_riscv.h"
1112
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
1213
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
1314
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h"
@@ -93,6 +94,18 @@ struct JITLinkLinker::Context : jitlink::JITLinkContext {
9394
Error modifyPassConfig(jitlink::LinkGraph &G,
9495
jitlink::PassConfiguration &Config) override {
9596
Config.PrePrunePasses.push_back(markSectionsLive);
97+
Config.PostAllocationPasses.push_back([this](auto &G) {
98+
MapSections([&G](const BinarySection &Section, uint64_t Address) {
99+
reassignSectionAddress(G, Section, Address);
100+
});
101+
return Error::success();
102+
});
103+
104+
if (G.getTargetTriple().isRISCV()) {
105+
Config.PostAllocationPasses.push_back(
106+
jitlink::createRelaxationPass_ELF_riscv());
107+
}
108+
96109
return Error::success();
97110
}
98111

@@ -137,10 +150,6 @@ struct JITLinkLinker::Context : jitlink::JITLinkContext {
137150
}
138151

139152
Error notifyResolved(jitlink::LinkGraph &G) override {
140-
MapSections([&G](const BinarySection &Section, uint64_t Address) {
141-
reassignSectionAddress(G, Section, Address);
142-
});
143-
144153
for (auto *Symbol : G.defined_symbols()) {
145154
SymbolInfo Info{Symbol->getAddress().getValue(), Symbol->getSize()};
146155
Linker.Symtab.insert({Symbol->getName().str(), Info});

bolt/lib/Rewrite/MachORewriteInstance.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,10 @@ void MachORewriteInstance::rewriteFile() {
564564
writeInstrumentationSection("I__literal16", OS);
565565

566566
Out->keep();
567-
EC = sys::fs::setPermissions(opts::OutputFilename,
568-
sys::fs::perms::all_all);
567+
EC = sys::fs::setPermissions(
568+
opts::OutputFilename,
569+
static_cast<sys::fs::perms>(sys::fs::perms::all_all &
570+
~sys::fs::getUmask()));
569571
check_error(EC, "cannot set permissions of output file");
570572
}
571573

0 commit comments

Comments
 (0)