Skip to content

Commit

Permalink
Merge remote-tracking branch 'llvm/main' into onesided_lower_bound
Browse files Browse the repository at this point in the history
* 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)
  ...
  • Loading branch information
ichaer committed Feb 1, 2024
2 parents 24d1d5b + 5d228ea commit f17fa58
Show file tree
Hide file tree
Showing 1,658 changed files with 58,645 additions and 21,347 deletions.
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ f6d557ee34b6bbdb1dc32f29e34b4a4a8ad35e81

# [libc++] Format the code base (#74334)
9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7

# [RFC] compiler-rt builtins cleanup and refactoring
082b89b25faae3e45a023caf51b65ca0f02f377f
0ba22f51d128bee9d69756c56c4678097270e10b
84da0e1bb75f8666cf222d2f600f37bebb9ea389
50 changes: 50 additions & 0 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,49 @@ mc:
clang:driver:
- clang/*/Driver/**

compiler-rt:asan:
- compiler-rt/lib/asan/**
- compiler-rt/include/sanitizer/asan_interface.h
- compiler-rt/test/asan/**
- compiler-rt/lib/asan_abi/**
- compiler-rt/test/asan_abi/**

compiler-rt:builtins:
- compiler-rt/lib/builtins/**
- compiler-rt/test/builtins/**

compiler-rt:cfi:
- compiler-rt/lib/cfi/**
- compiler-rt/test/cfi/**

compiler-rt:fuzzer:
- compiler-rt/lib/fuzzer/**
- compiler-rt/include/fuzzer/**
- compiler-rt/test/fuzzer/**

compiler-rt:hwasan:
- compiler-rt/lib/hwasan/**
- compiler-rt/include/sanitizer/hwasan_interface.h
- compiler-rt/test/hwasan/**

compiler-rt:lsan:
- compiler-rt/lib/lsan/**
- compiler-rt/include/sanitizer/lsan_interface.h
- compiler-rt/test/lsan/**

compiler-rt:msan:
- compiler-rt/lib/msan/**
- compiler-rt/include/sanitizer/msan_interface.h
- compiler-rt/test/msan/**

compiler-rt:sanitizer:
- llvm/lib/Transforms/Instrumentation/*Sanitizer*
- compiler-rt/lib/interception/**
- compiler-rt/lib/*san*/**
- compiler-rt/include/sanitizer/**
- compiler-rt/test/*san*/**
- compiler-rt/lib/fuzzer/**
- compiler-rt/include/fuzzer/**
- compiler-rt/test/fuzzer/**
- compiler-rt/lib/scudo/**
- compiler-rt/test/scudo/**
Expand All @@ -89,6 +126,19 @@ compiler-rt:scudo:
- compiler-rt/lib/scudo/**
- compiler-rt/test/scudo/**

compiler-rt:tsan:
- compiler-rt/lib/tsan/**
- compiler-rt/include/sanitizer/tsan_interface.h
- compiler-rt/include/sanitizer/tsan_interface_atomic.h
- compiler-rt/test/tsan/**

compiler-rt:ubsan:
- compiler-rt/lib/ubsan/**
- compiler-rt/include/sanitizer/ubsan_interface.h
- compiler-rt/test/ubsan/**
- compiler-rt/lib/ubsan_minimal/**
- compiler-rt/test/ubsan_minimal/**

xray:
- llvm/tools/llvm-xray/**
- compiler-rt/*/xray/**
Expand Down
38 changes: 22 additions & 16 deletions .github/workflows/containers/github-action-ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@ FROM docker.io/library/ubuntu:22.04 as base
ENV LLVM_SYSROOT=/opt/llvm/

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

RUN apt-get update && \
apt-get install -y \
curl \
xz-utils
wget \
gcc \
g++ \
cmake \
ninja-build \
python3

RUN wget https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-$LLVM_VERSION.tar.gz && tar -xf llvmorg-$LLVM_VERSION.tar.gz

RUN mkdir -p $LLVM_SYSROOT/bin/ $LLVM_SYSROOT/lib/
WORKDIR /llvm-project-llvmorg-$LLVM_VERSION

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

RUN tar -C $LLVM_SYSROOT --strip-components=1 -xJf $LLVM_FILENAME \
$LLVM_DIRNAME/bin/clang \
$LLVM_DIRNAME/bin/clang++ \
$LLVM_DIRNAME/bin/clang-cl \
$LLVM_DIRNAME/bin/clang-$LLVM_MAJOR \
$LLVM_DIRNAME/bin/lld \
$LLVM_DIRNAME/bin/ld.lld \
$LLVM_DIRNAME/lib/clang/
RUN cmake -B ./build -G Ninja ./llvm \
-C ./clang/cmake/caches/BOLT-PGO.cmake \
-DBOOTSTRAP_LLVM_ENABLE_LLD=ON \
-DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
-DPGO_INSTRUMENT_LTO=Thin \
-DLLVM_ENABLE_RUNTIMES="compiler-rt" \
-DCMAKE_INSTALL_PREFIX="$LLVM_SYSROOT" \
-DLLVM_ENABLE_PROJECTS="bolt;clang;lld;clang-tools-extra" \
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format" \
-DCLANG_DEFAULT_LINKER="lld"

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

FROM base

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
ENABLE_CLANG_TIDY: ${{ matrix.clang_tidy }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
if: always()
with:
name: ${{ matrix.config }}-${{ matrix.cxx }}-results
Expand Down Expand Up @@ -124,10 +124,10 @@ jobs:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
ENABLE_CLANG_TIDY: ${{ matrix.clang_tidy }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
if: always() # Upload artifacts even if the build or test suite fails
with:
name: ${{ matrix.config }}-results
name: ${{ matrix.config }}-${{ matrix.cxx }}-results
path: |
**/test-results.xml
**/*.abilist
Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:
CC: clang-18
CXX: clang++-18
ENABLE_CLANG_TIDY: "OFF"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
if: always()
with:
name: ${{ matrix.config }}-results
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/merged-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Add buildbot information to first PRs from new contributors"

permissions:
contents: read

on:
# It's safe to use pull_request_target here, because we aren't checking out
# code from the pull request branch.
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
pull_request_target:
types:
- closed

jobs:
buildbot_comment:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: >-
(github.repository == 'llvm/llvm-project') &&
(github.event.pull_request.merged == true)
steps:
- name: Checkout Automation Script
uses: actions/checkout@v4
with:
sparse-checkout: llvm/utils/git/
ref: main

- name: Setup Automation Script
working-directory: ./llvm/utils/git/
run: |
pip install -r requirements.txt
- name: Add Buildbot information comment
working-directory: ./llvm/utils/git/
run: |
python3 ./github-automation.py \
--token '${{ secrets.GITHUB_TOKEN }}' \
pr-buildbot-information \
--issue-number "${{ github.event.pull_request.number }}" \
--author "${{ github.event.pull_request.user.login }}"
11 changes: 11 additions & 0 deletions bolt/include/bolt/Core/BinaryContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ class BinaryContext {
/// Huge page size to use.
static constexpr unsigned HugePageSize = 0x200000;

/// Addresses reserved for kernel on x86_64 start at this location.
static constexpr uint64_t KernelStartX86_64 = 0xFFFF'FFFF'8000'0000;

/// Map address to a constant island owner (constant data in code section)
std::map<uint64_t, BinaryFunction *> AddressToConstantIslandMap;

Expand Down Expand Up @@ -602,6 +605,9 @@ class BinaryContext {

std::unique_ptr<MCAsmBackend> MAB;

/// Indicates if the binary is Linux kernel.
bool IsLinuxKernel{false};

/// Indicates if relocations are available for usage.
bool HasRelocations{false};

Expand Down Expand Up @@ -665,6 +671,11 @@ class BinaryContext {
uint64_t StaleSampleCount{0};
/// the count of matched samples
uint64_t MatchedSampleCount{0};
/// the number of stale functions that have matching number of blocks in
/// the profile
uint64_t NumStaleFuncsWithEqualBlockCount{0};
/// the number of blocks that have matching size but a differing hash
uint64_t NumStaleBlocksWithEqualIcount{0};
} Stats;

// Address of the first allocated segment.
Expand Down
3 changes: 3 additions & 0 deletions bolt/include/bolt/Rewrite/MetadataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class MetadataManager {
/// Execute metadata initializers after CFG was constructed for functions.
void runInitializersPostCFG();

/// Run finalization step of rewriters before the binary is emitted.
void runFinalizersPreEmit();

/// Run finalization step of rewriters after code has been emitted.
void runFinalizersAfterEmit();
};
Expand Down
3 changes: 3 additions & 0 deletions bolt/include/bolt/Rewrite/MetadataRewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class MetadataRewriter {
/// Run the rewriter once the functions are in CFG state.
virtual Error postCFGInitializer() { return Error::success(); }

/// Run the pass before the binary is emitted.
virtual Error preEmitFinalizer() { return Error::success(); }

/// Finalize section contents based on the new context after the new code is
/// emitted.
virtual Error postEmitFinalizer() { return Error::success(); }
Expand Down
8 changes: 8 additions & 0 deletions bolt/include/bolt/Rewrite/RewriteInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ class RewriteInstance {
/// Process metadata in special sections after CFG is built for functions.
void processMetadataPostCFG();

/// Make changes to metadata before the binary is emitted.
void finalizeMetadataPreEmit();

/// Update debug and other auxiliary information in the file.
void updateMetadata();

Expand Down Expand Up @@ -261,6 +264,11 @@ class RewriteInstance {
void createPLTBinaryFunction(uint64_t TargetAddress, uint64_t EntryAddress,
uint64_t EntrySize);

/// Disassemble PLT instruction.
void disassemblePLTInstruction(const BinarySection &Section,
uint64_t InstrOffset, MCInst &Instruction,
uint64_t &InstrSize);

/// Disassemble aarch64-specific .plt \p Section auxiliary function
void disassemblePLTSectionAArch64(BinarySection &Section);

Expand Down
1 change: 0 additions & 1 deletion bolt/include/bolt/Utils/CommandLineOpts.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
namespace opts {

extern bool HeatmapMode;
extern bool LinuxKernelMode;

extern llvm::cl::OptionCategory BoltCategory;
extern llvm::cl::OptionCategory BoltDiffCategory;
Expand Down
16 changes: 16 additions & 0 deletions bolt/lib/Passes/BinaryPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,12 @@ void PrintProgramStats::runOnFunctions(BinaryContext &BC) {
if (NumAllStaleFunctions) {
const float PctStale =
NumAllStaleFunctions / (float)NumAllProfiledFunctions * 100.0f;
const float PctStaleFuncsWithEqualBlockCount =
(float)BC.Stats.NumStaleFuncsWithEqualBlockCount /
NumAllStaleFunctions * 100.0f;
const float PctStaleBlocksWithEqualIcount =
(float)BC.Stats.NumStaleBlocksWithEqualIcount /
BC.Stats.NumStaleBlocks * 100.0f;
auto printErrorOrWarning = [&]() {
if (PctStale > opts::StaleThreshold)
errs() << "BOLT-ERROR: ";
Expand All @@ -1442,6 +1448,16 @@ void PrintProgramStats::runOnFunctions(BinaryContext &BC) {
<< "%) belong to functions with invalid"
" (possibly stale) profile.\n";
}
outs() << "BOLT-INFO: " << BC.Stats.NumStaleFuncsWithEqualBlockCount
<< " stale function"
<< (BC.Stats.NumStaleFuncsWithEqualBlockCount == 1 ? "" : "s")
<< format(" (%.1f%% of all stale)", PctStaleFuncsWithEqualBlockCount)
<< " have matching block count.\n";
outs() << "BOLT-INFO: " << BC.Stats.NumStaleBlocksWithEqualIcount
<< " stale block"
<< (BC.Stats.NumStaleBlocksWithEqualIcount == 1 ? "" : "s")
<< format(" (%.1f%% of all stale)", PctStaleBlocksWithEqualIcount)
<< " have matching icount.\n";
if (PctStale > opts::StaleThreshold) {
errs() << "BOLT-ERROR: stale functions exceed specified threshold of "
<< opts::StaleThreshold << "%. Exiting.\n";
Expand Down
6 changes: 3 additions & 3 deletions bolt/lib/Profile/DataAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
ErrorCallback(ReturnCode, ErrBuf);
};

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

if (opts::LinuxKernelMode) {
if (BC->IsLinuxKernel) {
opts::HeatmapMaxAddress = 0xffffffffffffffff;
opts::HeatmapMinAddress = KernelBaseAddr;
}
Expand Down
3 changes: 3 additions & 0 deletions bolt/lib/Profile/StaleProfileMatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ void matchWeightsByHashes(BinaryContext &BC,
if (MatchedBlock == nullptr && YamlBB.Index == 0)
MatchedBlock = Blocks[0];
if (MatchedBlock != nullptr) {
const BinaryBasicBlock *BB = BlockOrder[MatchedBlock->Index - 1];
MatchedBlocks[YamlBB.Index] = MatchedBlock;
BlendedBlockHash BinHash = BlendedHashes[MatchedBlock->Index - 1];
LLVM_DEBUG(dbgs() << "Matched yaml block (bid = " << YamlBB.Index << ")"
Expand All @@ -433,6 +434,8 @@ void matchWeightsByHashes(BinaryContext &BC,
} else {
LLVM_DEBUG(dbgs() << " loose match\n");
}
if (YamlBB.NumInstructions == BB->size())
++BC.Stats.NumStaleBlocksWithEqualIcount;
} else {
LLVM_DEBUG(
dbgs() << "Couldn't match yaml block (bid = " << YamlBB.Index << ")"
Expand Down
20 changes: 10 additions & 10 deletions bolt/lib/Profile/YAMLProfileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,20 @@ bool YAMLProfileReader::parseFunctionProfile(

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

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

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

if (!ProfileMatched && opts::InferStaleProfile) {
if (inferStaleProfile(BF, YamlBF)) {
if (opts::InferStaleProfile && inferStaleProfile(BF, YamlBF))
ProfileMatched = true;
BF.markProfiled(YamlBP.Header.Flags);
}
}
if (ProfileMatched)
BF.markProfiled(YamlBP.Header.Flags);

return ProfileMatched;
}
Expand Down
Loading

0 comments on commit f17fa58

Please sign in to comment.