Skip to content

Commit f17fa58

Browse files
committed
Merge remote-tracking branch 'llvm/main' into onesided_lower_bound
* llvm/main: (500 commits) [docs] Add beginner-focused office hours (llvm#80308) [mlir][sparse] external entry method wrapper for sparse tensors (llvm#80326) [StackSlotColoring] Ignore non-spill objects in RemoveDeadStores. (llvm#80242) [libc][stdbit] fix return types (llvm#80337) Revert "[RISCV] Refine cost on Min/Max reduction" (llvm#80340) [TTI]Add support for strided loads/stores. [analyzer][HTMLRewriter] Cache partial rewrite results. (llvm#80220) [flang][openacc][openmp] Use #0 from hlfir.declare value when generating bound ops (llvm#80317) [AArch64][PAC] Expand blend(reg, imm) operation in aarch64-pauth pass (llvm#74729) [SHT_LLVM_BB_ADDR_MAP][llvm-readobj] Implements llvm-readobj handling for PGOAnalysisMap. (llvm#79520) [libc] add bazel support for most of unistd (llvm#80078) [clang-tidy] Remove enforcement of rule C.48 from cppcoreguidelines-prefer-member-init (llvm#80330) [OpenMP] Fix typo (NFC) (llvm#80332) [BOLT] Enable re-writing of Linux kernel binary (llvm#80228) [BOLT] Adjust section sizes based on file offsets (llvm#80226) [libc] fix stdbit include test when not all entrypoints are available (llvm#80323) [RISCV][GISel] RegBank select and instruction select for vector G_ADD, G_SUB (llvm#74114) [RISCV] Add srmcfg CSR from Ssqosid extension. (llvm#79914) [mlir][sparse] add sparsification options to pretty print and debug s… (llvm#80205) [RISCV][MC] MC layer support for the experimental zalasr extension (llvm#79911) ...
2 parents 24d1d5b + 5d228ea commit f17fa58

File tree

1,658 files changed

+58645
-21347
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,658 files changed

+58645
-21347
lines changed

.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,8 @@ f6d557ee34b6bbdb1dc32f29e34b4a4a8ad35e81
7373

7474
# [libc++] Format the code base (#74334)
7575
9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7
76+
77+
# [RFC] compiler-rt builtins cleanup and refactoring
78+
082b89b25faae3e45a023caf51b65ca0f02f377f
79+
0ba22f51d128bee9d69756c56c4678097270e10b
80+
84da0e1bb75f8666cf222d2f600f37bebb9ea389

.github/new-prs-labeler.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,49 @@ mc:
7575
clang:driver:
7676
- clang/*/Driver/**
7777

78+
compiler-rt:asan:
79+
- compiler-rt/lib/asan/**
80+
- compiler-rt/include/sanitizer/asan_interface.h
81+
- compiler-rt/test/asan/**
82+
- compiler-rt/lib/asan_abi/**
83+
- compiler-rt/test/asan_abi/**
84+
85+
compiler-rt:builtins:
86+
- compiler-rt/lib/builtins/**
87+
- compiler-rt/test/builtins/**
88+
89+
compiler-rt:cfi:
90+
- compiler-rt/lib/cfi/**
91+
- compiler-rt/test/cfi/**
92+
93+
compiler-rt:fuzzer:
94+
- compiler-rt/lib/fuzzer/**
95+
- compiler-rt/include/fuzzer/**
96+
- compiler-rt/test/fuzzer/**
97+
98+
compiler-rt:hwasan:
99+
- compiler-rt/lib/hwasan/**
100+
- compiler-rt/include/sanitizer/hwasan_interface.h
101+
- compiler-rt/test/hwasan/**
102+
103+
compiler-rt:lsan:
104+
- compiler-rt/lib/lsan/**
105+
- compiler-rt/include/sanitizer/lsan_interface.h
106+
- compiler-rt/test/lsan/**
107+
108+
compiler-rt:msan:
109+
- compiler-rt/lib/msan/**
110+
- compiler-rt/include/sanitizer/msan_interface.h
111+
- compiler-rt/test/msan/**
112+
78113
compiler-rt:sanitizer:
79114
- llvm/lib/Transforms/Instrumentation/*Sanitizer*
80115
- compiler-rt/lib/interception/**
81116
- compiler-rt/lib/*san*/**
117+
- compiler-rt/include/sanitizer/**
82118
- compiler-rt/test/*san*/**
83119
- compiler-rt/lib/fuzzer/**
120+
- compiler-rt/include/fuzzer/**
84121
- compiler-rt/test/fuzzer/**
85122
- compiler-rt/lib/scudo/**
86123
- compiler-rt/test/scudo/**
@@ -89,6 +126,19 @@ compiler-rt:scudo:
89126
- compiler-rt/lib/scudo/**
90127
- compiler-rt/test/scudo/**
91128

129+
compiler-rt:tsan:
130+
- compiler-rt/lib/tsan/**
131+
- compiler-rt/include/sanitizer/tsan_interface.h
132+
- compiler-rt/include/sanitizer/tsan_interface_atomic.h
133+
- compiler-rt/test/tsan/**
134+
135+
compiler-rt:ubsan:
136+
- compiler-rt/lib/ubsan/**
137+
- compiler-rt/include/sanitizer/ubsan_interface.h
138+
- compiler-rt/test/ubsan/**
139+
- compiler-rt/lib/ubsan_minimal/**
140+
- compiler-rt/test/ubsan_minimal/**
141+
92142
xray:
93143
- llvm/tools/llvm-xray/**
94144
- compiler-rt/*/xray/**

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,35 @@ FROM docker.io/library/ubuntu:22.04 as base
22
ENV LLVM_SYSROOT=/opt/llvm/
33

44
FROM base as toolchain
5-
ENV LLVM_MAJOR=17
6-
ENV LLVM_VERSION=${LLVM_MAJOR}.0.6
7-
ENV LLVM_DIRNAME=clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-22.04
8-
ENV LLVM_FILENAME=${LLVM_DIRNAME}.tar.xz
5+
ENV LLVM_VERSION=17.0.6
96

107
RUN apt-get update && \
118
apt-get install -y \
12-
curl \
13-
xz-utils
9+
wget \
10+
gcc \
11+
g++ \
12+
cmake \
13+
ninja-build \
14+
python3
15+
16+
RUN wget https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-$LLVM_VERSION.tar.gz && tar -xf llvmorg-$LLVM_VERSION.tar.gz
1417

15-
RUN mkdir -p $LLVM_SYSROOT/bin/ $LLVM_SYSROOT/lib/
18+
WORKDIR /llvm-project-llvmorg-$LLVM_VERSION
1619

17-
RUN curl -O -L https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/$LLVM_FILENAME
20+
RUN mkdir build
1821

19-
RUN tar -C $LLVM_SYSROOT --strip-components=1 -xJf $LLVM_FILENAME \
20-
$LLVM_DIRNAME/bin/clang \
21-
$LLVM_DIRNAME/bin/clang++ \
22-
$LLVM_DIRNAME/bin/clang-cl \
23-
$LLVM_DIRNAME/bin/clang-$LLVM_MAJOR \
24-
$LLVM_DIRNAME/bin/lld \
25-
$LLVM_DIRNAME/bin/ld.lld \
26-
$LLVM_DIRNAME/lib/clang/
22+
RUN cmake -B ./build -G Ninja ./llvm \
23+
-C ./clang/cmake/caches/BOLT-PGO.cmake \
24+
-DBOOTSTRAP_LLVM_ENABLE_LLD=ON \
25+
-DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
26+
-DPGO_INSTRUMENT_LTO=Thin \
27+
-DLLVM_ENABLE_RUNTIMES="compiler-rt" \
28+
-DCMAKE_INSTALL_PREFIX="$LLVM_SYSROOT" \
29+
-DLLVM_ENABLE_PROJECTS="bolt;clang;lld;clang-tools-extra" \
30+
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format" \
31+
-DCLANG_DEFAULT_LINKER="lld"
2732

33+
RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution && rm -rf ./build
2834

2935
FROM base
3036

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
CC: ${{ matrix.cc }}
7676
CXX: ${{ matrix.cxx }}
7777
ENABLE_CLANG_TIDY: ${{ matrix.clang_tidy }}
78-
- uses: actions/upload-artifact@v3
78+
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
7979
if: always()
8080
with:
8181
name: ${{ matrix.config }}-${{ matrix.cxx }}-results
@@ -124,10 +124,10 @@ jobs:
124124
CC: ${{ matrix.cc }}
125125
CXX: ${{ matrix.cxx }}
126126
ENABLE_CLANG_TIDY: ${{ matrix.clang_tidy }}
127-
- uses: actions/upload-artifact@v3
127+
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
128128
if: always() # Upload artifacts even if the build or test suite fails
129129
with:
130-
name: ${{ matrix.config }}-results
130+
name: ${{ matrix.config }}-${{ matrix.cxx }}-results
131131
path: |
132132
**/test-results.xml
133133
**/*.abilist
@@ -189,7 +189,7 @@ jobs:
189189
CC: clang-18
190190
CXX: clang++-18
191191
ENABLE_CLANG_TIDY: "OFF"
192-
- uses: actions/upload-artifact@v3
192+
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
193193
if: always()
194194
with:
195195
name: ${{ matrix.config }}-results

.github/workflows/merged-prs.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Add buildbot information to first PRs from new contributors"
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
# It's safe to use pull_request_target here, because we aren't checking out
8+
# code from the pull request branch.
9+
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
10+
pull_request_target:
11+
types:
12+
- closed
13+
14+
jobs:
15+
buildbot_comment:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
pull-requests: write
19+
if: >-
20+
(github.repository == 'llvm/llvm-project') &&
21+
(github.event.pull_request.merged == true)
22+
steps:
23+
- name: Checkout Automation Script
24+
uses: actions/checkout@v4
25+
with:
26+
sparse-checkout: llvm/utils/git/
27+
ref: main
28+
29+
- name: Setup Automation Script
30+
working-directory: ./llvm/utils/git/
31+
run: |
32+
pip install -r requirements.txt
33+
34+
- name: Add Buildbot information comment
35+
working-directory: ./llvm/utils/git/
36+
run: |
37+
python3 ./github-automation.py \
38+
--token '${{ secrets.GITHUB_TOKEN }}' \
39+
pr-buildbot-information \
40+
--issue-number "${{ github.event.pull_request.number }}" \
41+
--author "${{ github.event.pull_request.user.login }}"

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ class BinaryContext {
554554
/// Huge page size to use.
555555
static constexpr unsigned HugePageSize = 0x200000;
556556

557+
/// Addresses reserved for kernel on x86_64 start at this location.
558+
static constexpr uint64_t KernelStartX86_64 = 0xFFFF'FFFF'8000'0000;
559+
557560
/// Map address to a constant island owner (constant data in code section)
558561
std::map<uint64_t, BinaryFunction *> AddressToConstantIslandMap;
559562

@@ -602,6 +605,9 @@ class BinaryContext {
602605

603606
std::unique_ptr<MCAsmBackend> MAB;
604607

608+
/// Indicates if the binary is Linux kernel.
609+
bool IsLinuxKernel{false};
610+
605611
/// Indicates if relocations are available for usage.
606612
bool HasRelocations{false};
607613

@@ -665,6 +671,11 @@ class BinaryContext {
665671
uint64_t StaleSampleCount{0};
666672
/// the count of matched samples
667673
uint64_t MatchedSampleCount{0};
674+
/// the number of stale functions that have matching number of blocks in
675+
/// the profile
676+
uint64_t NumStaleFuncsWithEqualBlockCount{0};
677+
/// the number of blocks that have matching size but a differing hash
678+
uint64_t NumStaleBlocksWithEqualIcount{0};
668679
} Stats;
669680

670681
// Address of the first allocated segment.

bolt/include/bolt/Rewrite/MetadataManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class MetadataManager {
3636
/// Execute metadata initializers after CFG was constructed for functions.
3737
void runInitializersPostCFG();
3838

39+
/// Run finalization step of rewriters before the binary is emitted.
40+
void runFinalizersPreEmit();
41+
3942
/// Run finalization step of rewriters after code has been emitted.
4043
void runFinalizersAfterEmit();
4144
};

bolt/include/bolt/Rewrite/MetadataRewriter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class MetadataRewriter {
5252
/// Run the rewriter once the functions are in CFG state.
5353
virtual Error postCFGInitializer() { return Error::success(); }
5454

55+
/// Run the pass before the binary is emitted.
56+
virtual Error preEmitFinalizer() { return Error::success(); }
57+
5558
/// Finalize section contents based on the new context after the new code is
5659
/// emitted.
5760
virtual Error postEmitFinalizer() { return Error::success(); }

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ class RewriteInstance {
183183
/// Process metadata in special sections after CFG is built for functions.
184184
void processMetadataPostCFG();
185185

186+
/// Make changes to metadata before the binary is emitted.
187+
void finalizeMetadataPreEmit();
188+
186189
/// Update debug and other auxiliary information in the file.
187190
void updateMetadata();
188191

@@ -261,6 +264,11 @@ class RewriteInstance {
261264
void createPLTBinaryFunction(uint64_t TargetAddress, uint64_t EntryAddress,
262265
uint64_t EntrySize);
263266

267+
/// Disassemble PLT instruction.
268+
void disassemblePLTInstruction(const BinarySection &Section,
269+
uint64_t InstrOffset, MCInst &Instruction,
270+
uint64_t &InstrSize);
271+
264272
/// Disassemble aarch64-specific .plt \p Section auxiliary function
265273
void disassemblePLTSectionAArch64(BinarySection &Section);
266274

bolt/include/bolt/Utils/CommandLineOpts.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
namespace opts {
1919

2020
extern bool HeatmapMode;
21-
extern bool LinuxKernelMode;
2221

2322
extern llvm::cl::OptionCategory BoltCategory;
2423
extern llvm::cl::OptionCategory BoltDiffCategory;

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,12 @@ void PrintProgramStats::runOnFunctions(BinaryContext &BC) {
14201420
if (NumAllStaleFunctions) {
14211421
const float PctStale =
14221422
NumAllStaleFunctions / (float)NumAllProfiledFunctions * 100.0f;
1423+
const float PctStaleFuncsWithEqualBlockCount =
1424+
(float)BC.Stats.NumStaleFuncsWithEqualBlockCount /
1425+
NumAllStaleFunctions * 100.0f;
1426+
const float PctStaleBlocksWithEqualIcount =
1427+
(float)BC.Stats.NumStaleBlocksWithEqualIcount /
1428+
BC.Stats.NumStaleBlocks * 100.0f;
14231429
auto printErrorOrWarning = [&]() {
14241430
if (PctStale > opts::StaleThreshold)
14251431
errs() << "BOLT-ERROR: ";
@@ -1442,6 +1448,16 @@ void PrintProgramStats::runOnFunctions(BinaryContext &BC) {
14421448
<< "%) belong to functions with invalid"
14431449
" (possibly stale) profile.\n";
14441450
}
1451+
outs() << "BOLT-INFO: " << BC.Stats.NumStaleFuncsWithEqualBlockCount
1452+
<< " stale function"
1453+
<< (BC.Stats.NumStaleFuncsWithEqualBlockCount == 1 ? "" : "s")
1454+
<< format(" (%.1f%% of all stale)", PctStaleFuncsWithEqualBlockCount)
1455+
<< " have matching block count.\n";
1456+
outs() << "BOLT-INFO: " << BC.Stats.NumStaleBlocksWithEqualIcount
1457+
<< " stale block"
1458+
<< (BC.Stats.NumStaleBlocksWithEqualIcount == 1 ? "" : "s")
1459+
<< format(" (%.1f%% of all stale)", PctStaleBlocksWithEqualIcount)
1460+
<< " have matching icount.\n";
14451461
if (PctStale > opts::StaleThreshold) {
14461462
errs() << "BOLT-ERROR: stale functions exceed specified threshold of "
14471463
<< opts::StaleThreshold << "%. Exiting.\n";

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
524524
ErrorCallback(ReturnCode, ErrBuf);
525525
};
526526

527-
if (opts::LinuxKernelMode) {
527+
if (BC.IsLinuxKernel) {
528528
// Current MMap parsing logic does not work with linux kernel.
529529
// MMap entries for linux kernel uses PERF_RECORD_MMAP
530530
// format instead of typical PERF_RECORD_MMAP2 format.
@@ -1056,7 +1056,7 @@ ErrorOr<DataAggregator::PerfBranchSample> DataAggregator::parseBranchSample() {
10561056
if (std::error_code EC = PIDRes.getError())
10571057
return EC;
10581058
auto MMapInfoIter = BinaryMMapInfo.find(*PIDRes);
1059-
if (!opts::LinuxKernelMode && MMapInfoIter == BinaryMMapInfo.end()) {
1059+
if (!BC->IsLinuxKernel && MMapInfoIter == BinaryMMapInfo.end()) {
10601060
consumeRestOfLine();
10611061
return make_error_code(errc::no_such_process);
10621062
}
@@ -1277,7 +1277,7 @@ std::error_code DataAggregator::printLBRHeatMap() {
12771277
NamedRegionTimer T("parseBranch", "Parsing branch events", TimerGroupName,
12781278
TimerGroupDesc, opts::TimeAggregator);
12791279

1280-
if (opts::LinuxKernelMode) {
1280+
if (BC->IsLinuxKernel) {
12811281
opts::HeatmapMaxAddress = 0xffffffffffffffff;
12821282
opts::HeatmapMinAddress = KernelBaseAddr;
12831283
}

bolt/lib/Profile/StaleProfileMatching.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ void matchWeightsByHashes(BinaryContext &BC,
418418
if (MatchedBlock == nullptr && YamlBB.Index == 0)
419419
MatchedBlock = Blocks[0];
420420
if (MatchedBlock != nullptr) {
421+
const BinaryBasicBlock *BB = BlockOrder[MatchedBlock->Index - 1];
421422
MatchedBlocks[YamlBB.Index] = MatchedBlock;
422423
BlendedBlockHash BinHash = BlendedHashes[MatchedBlock->Index - 1];
423424
LLVM_DEBUG(dbgs() << "Matched yaml block (bid = " << YamlBB.Index << ")"
@@ -433,6 +434,8 @@ void matchWeightsByHashes(BinaryContext &BC,
433434
} else {
434435
LLVM_DEBUG(dbgs() << " loose match\n");
435436
}
437+
if (YamlBB.NumInstructions == BB->size())
438+
++BC.Stats.NumStaleBlocksWithEqualIcount;
436439
} else {
437440
LLVM_DEBUG(
438441
dbgs() << "Couldn't match yaml block (bid = " << YamlBB.Index << ")"

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,20 @@ bool YAMLProfileReader::parseFunctionProfile(
246246

247247
ProfileMatched &= !MismatchedBlocks && !MismatchedCalls && !MismatchedEdges;
248248

249-
if (ProfileMatched)
250-
BF.markProfiled(YamlBP.Header.Flags);
249+
if (!ProfileMatched) {
250+
if (opts::Verbosity >= 1)
251+
errs() << "BOLT-WARNING: " << MismatchedBlocks << " blocks, "
252+
<< MismatchedCalls << " calls, and " << MismatchedEdges
253+
<< " edges in profile did not match function " << BF << '\n';
251254

252-
if (!ProfileMatched && opts::Verbosity >= 1)
253-
errs() << "BOLT-WARNING: " << MismatchedBlocks << " blocks, "
254-
<< MismatchedCalls << " calls, and " << MismatchedEdges
255-
<< " edges in profile did not match function " << BF << '\n';
255+
if (YamlBF.NumBasicBlocks != BF.size())
256+
++BC.Stats.NumStaleFuncsWithEqualBlockCount;
256257

257-
if (!ProfileMatched && opts::InferStaleProfile) {
258-
if (inferStaleProfile(BF, YamlBF)) {
258+
if (opts::InferStaleProfile && inferStaleProfile(BF, YamlBF))
259259
ProfileMatched = true;
260-
BF.markProfiled(YamlBP.Header.Flags);
261-
}
262260
}
261+
if (ProfileMatched)
262+
BF.markProfiled(YamlBP.Header.Flags);
263263

264264
return ProfileMatched;
265265
}

0 commit comments

Comments
 (0)