Skip to content

Commit

Permalink
pick up llvm:main branch change
Browse files Browse the repository at this point in the history
  • Loading branch information
minglotus-6 committed Feb 13, 2024
2 parents 66dbbfe + 5de40c7 commit f56cc62
Show file tree
Hide file tree
Showing 1,894 changed files with 72,502 additions and 38,622 deletions.
5 changes: 4 additions & 1 deletion .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)

windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
# Temporary disable the windows job.
# See https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840
#windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
windows_projects=""

# Generate the appropriate pipeline
if [[ "${linux_projects}" != "" ]]; then
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ f6d557ee34b6bbdb1dc32f29e34b4a4a8ad35e81
082b89b25faae3e45a023caf51b65ca0f02f377f
0ba22f51d128bee9d69756c56c4678097270e10b
84da0e1bb75f8666cf222d2f600f37bebb9ea389

# [NFC] clang-format utils/TableGen (#80973)
b9079baaddfed5e604fbfaa1d81a7a1c38e78c26
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@
/mlir/**/*SparseTensor*/ @aartbik @PeimingLiu @yinying-lisa-li @matthias-springer

# BOLT
/bolt/ @aaupov @maksfb @rafaelauler @dcci
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @dcci
39 changes: 39 additions & 0 deletions .github/workflows/approved-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Prompt reviewers to merge PRs on behalf of authors"

permissions:
contents: read

on:
pull_request_review:
types:
- submitted

jobs:
merge-on-behalf-information-comment:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: >-
(github.repository == 'llvm/llvm-project') &&
(github.event.review.state == 'APPROVED')
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 Merge On Behalf Comment
working-directory: ./llvm/utils/git/
run: |
python3 ./github-automation.py \
--token '${{ secrets.GITHUB_TOKEN }}' \
pr-merge-on-behalf-information \
--issue-number "${{ github.event.pull_request.number }}" \
--author "${{ github.event.pull_request.user.login }}" \
--reviewer "${{ github.event.review.user.login }}"
1 change: 1 addition & 0 deletions .github/workflows/issue-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ jobs:
release-workflow \
--branch-repo-token ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }} \
--issue-number ${{ github.event.issue.number }} \
--requested-by ${{ github.event.issue.user.login }} \
auto
32 changes: 32 additions & 0 deletions .github/workflows/llvm-project-workflow-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will test the llvm-project-tests workflow in PRs
# targetting the main branch. Since this workflow doesn't normally
# run on main PRs, we need some way to test it to ensure new updates
# don't break it.

name: LLVM Workflow Test

permissions:
contents: read

on:
pull_request:
branches:
- 'main'
paths:
- '.github/workflows/llvm-project-tests.yml'
- '.github/workflows/llvm-project-workflow-tests.yml'

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
llvm-test:
if: github.repository_owner == 'llvm'
name: Build and Test
uses: ./.github/workflows/llvm-project-tests.yml
with:
build_target: check-all
projects: clang;lld;libclc;lldb
51 changes: 47 additions & 4 deletions bolt/include/bolt/Core/BinaryContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,35 @@ class FilterIterator {
}
};

/// BOLT-exclusive errors generated in core BOLT libraries, optionally holding a
/// string message and whether it is fatal or not. In case it is fatal and if
/// BOLT is running as a standalone process, the process might be killed as soon
/// as the error is checked.
class BOLTError : public ErrorInfo<BOLTError> {
public:
static char ID;

BOLTError(bool IsFatal, const Twine &S = Twine());
void log(raw_ostream &OS) const override;
bool isFatal() const { return IsFatal; }

const std::string &getMessage() const { return Msg; }
std::error_code convertToErrorCode() const override;

private:
bool IsFatal;
std::string Msg;
};

/// Streams used by BOLT to log regular or error events
struct JournalingStreams {
raw_ostream &Out;
raw_ostream &Err;
};

Error createNonFatalBOLTError(const Twine &S);
Error createFatalBOLTError(const Twine &S);

class BinaryContext {
BinaryContext() = delete;

Expand Down Expand Up @@ -237,7 +266,8 @@ class BinaryContext {
public:
static Expected<std::unique_ptr<BinaryContext>>
createBinaryContext(const ObjectFile *File, bool IsPIC,
std::unique_ptr<DWARFContext> DwCtx);
std::unique_ptr<DWARFContext> DwCtx,
JournalingStreams Logger);

/// Superset of compiler units that will contain overwritten code that needs
/// new debug info. In a few cases, functions may end up not being
Expand Down Expand Up @@ -605,6 +635,10 @@ class BinaryContext {

std::unique_ptr<MCAsmBackend> MAB;

/// Allows BOLT to print to log whenever it is necessary (with or without
/// const references)
mutable JournalingStreams Logger;

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

Expand Down Expand Up @@ -737,7 +771,8 @@ class BinaryContext {
std::unique_ptr<const MCInstrAnalysis> MIA,
std::unique_ptr<MCPlusBuilder> MIB,
std::unique_ptr<const MCRegisterInfo> MRI,
std::unique_ptr<MCDisassembler> DisAsm);
std::unique_ptr<MCDisassembler> DisAsm,
JournalingStreams Logger);

~BinaryContext();

Expand Down Expand Up @@ -1349,8 +1384,12 @@ class BinaryContext {
return Offset;
}

void exitWithBugReport(StringRef Message,
const BinaryFunction &Function) const;
/// Log BOLT errors to journaling streams and quit process with non-zero error
/// code 1 if error is fatal.
void logBOLTErrorsAndQuitOnFatal(Error E);

std::string generateBugReportMessage(StringRef Message,
const BinaryFunction &Function) const;

struct IndependentCodeEmitter {
std::unique_ptr<MCObjectFileInfo> LocalMOFI;
Expand Down Expand Up @@ -1398,6 +1437,10 @@ class BinaryContext {
assert(IOAddressMap && "Address map not set yet");
return *IOAddressMap;
}

raw_ostream &outs() const { return Logger.Out; }

raw_ostream &errs() const { return Logger.Err; }
};

template <typename T, typename = std::enable_if_t<sizeof(T) == 1>>
Expand Down
21 changes: 11 additions & 10 deletions bolt/include/bolt/Core/BinaryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1910,12 +1910,11 @@ class BinaryFunction {

/// Support dynamic relocations in constant islands, which may happen if
/// binary is linked with -z notext option.
void markIslandDynamicRelocationAtAddress(uint64_t Address) {
if (!isInConstantIsland(Address)) {
errs() << "BOLT-ERROR: dynamic relocation found for text section at 0x"
<< Twine::utohexstr(Address) << "\n";
exit(1);
}
Error markIslandDynamicRelocationAtAddress(uint64_t Address) {
if (!isInConstantIsland(Address))
return createFatalBOLTError(
Twine("dynamic relocation found for text section at 0x") +
Twine::utohexstr(Address) + Twine("\n"));

// Mark island to have dynamic relocation
Islands->HasDynamicRelocations = true;
Expand All @@ -1924,6 +1923,7 @@ class BinaryFunction {
// move binary data during updateOutputValues, making us emit
// dynamic relocation with the right offset value.
getOrCreateIslandAccess(Address);
return Error::success();
}

bool hasDynamicRelocationAtIsland() const {
Expand Down Expand Up @@ -2054,9 +2054,10 @@ class BinaryFunction {
/// state to State:Disassembled.
///
/// Returns false if disassembly failed.
bool disassemble();
Error disassemble();

void handlePCRelOperand(MCInst &Instruction, uint64_t Address, uint64_t Size);
Error handlePCRelOperand(MCInst &Instruction, uint64_t Address,
uint64_t Size);

MCSymbol *handleExternalReference(MCInst &Instruction, uint64_t Size,
uint64_t Offset, uint64_t TargetAddress,
Expand Down Expand Up @@ -2100,7 +2101,7 @@ class BinaryFunction {
///
/// Returns true on success and update the current function state to
/// State::CFG. Returns false if CFG cannot be built.
bool buildCFG(MCPlusBuilder::AllocatorIdTy);
Error buildCFG(MCPlusBuilder::AllocatorIdTy);

/// Perform post-processing of the CFG.
void postProcessCFG();
Expand Down Expand Up @@ -2217,7 +2218,7 @@ class BinaryFunction {
}

/// Process LSDA information for the function.
void parseLSDA(ArrayRef<uint8_t> LSDAData, uint64_t LSDAAddress);
Error parseLSDA(ArrayRef<uint8_t> LSDAData, uint64_t LSDAAddress);

/// Update exception handling ranges for the function.
void updateEHRanges();
Expand Down
4 changes: 2 additions & 2 deletions bolt/include/bolt/Core/BinarySection.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class BinarySection {
static StringRef getName(SectionRef Section) {
return cantFail(Section.getName());
}
static StringRef getContents(SectionRef Section) {
static StringRef getContentsOrQuit(SectionRef Section) {
if (Section.getObject()->isELF() &&
ELFSectionRef(Section).getType() == ELF::SHT_NOBITS)
return StringRef();
Expand Down Expand Up @@ -159,7 +159,7 @@ class BinarySection {

BinarySection(BinaryContext &BC, SectionRef Section)
: BC(BC), Name(getName(Section)), Section(Section),
Contents(getContents(Section)), Address(Section.getAddress()),
Contents(getContentsOrQuit(Section)), Address(Section.getAddress()),
Size(Section.getSize()), Alignment(Section.getAlignment().value()),
OutputName(Name), SectionNumber(++Count) {
if (isELF()) {
Expand Down
17 changes: 11 additions & 6 deletions bolt/include/bolt/Core/DIEBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef BOLT_CORE_DIE_BUILDER_H
#define BOLT_CORE_DIE_BUILDER_H

#include "bolt/Core/BinaryContext.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
Expand All @@ -32,6 +33,7 @@
namespace llvm {

namespace bolt {

class DIEStreamer;
class DebugStrOffsetsWriter;

Expand Down Expand Up @@ -120,6 +122,7 @@ class DIEBuilder {
std::unique_ptr<State> BuilderState;
FoldingSet<DIEAbbrev> AbbreviationsSet;
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
BinaryContext &BC;
DWARFContext *DwarfContext{nullptr};
bool IsDWO{false};
uint64_t UnitSize{0};
Expand Down Expand Up @@ -219,9 +222,10 @@ class DIEBuilder {
if (getState().CloneUnitCtxMap[UnitId].DieInfoVector.size() > DIEId)
return *getState().CloneUnitCtxMap[UnitId].DieInfoVector[DIEId].get();

errs() << "BOLT-WARNING: [internal-dwarf-error]: The DIE is not allocated "
"before looking up, some"
<< "unexpected corner cases happened.\n";
BC.errs()
<< "BOLT-WARNING: [internal-dwarf-error]: The DIE is not allocated "
"before looking up, some"
<< "unexpected corner cases happened.\n";
return *getState().CloneUnitCtxMap[UnitId].DieInfoVector.front().get();
}

Expand Down Expand Up @@ -261,7 +265,7 @@ class DIEBuilder {
DIE *constructDIEFast(DWARFDie &DDie, DWARFUnit &U, uint32_t UnitId);

public:
DIEBuilder(DWARFContext *DwarfContext, bool IsDWO = false);
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);

/// Returns enum to what we are currently processing.
ProcessingType getCurrentProcessingState() { return getState().Type; }
Expand Down Expand Up @@ -295,8 +299,9 @@ class DIEBuilder {
if (getState().TypeDIEMap.count(&DU))
return getState().TypeDIEMap[&DU];

errs() << "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
<< DU.getOffset() << "\n";
BC.errs()
<< "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
<< DU.getOffset() << "\n";
return nullptr;
}

Expand Down
15 changes: 8 additions & 7 deletions bolt/include/bolt/Core/DynoStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ inline DynoStats getDynoStats(FuncsType &Funcs, bool IsAArch64) {

/// Call a function with optional before and after dynostats printing.
template <typename FnType, typename FuncsType>
inline void callWithDynoStats(FnType &&Func, FuncsType &Funcs, StringRef Phase,
const bool Flag, bool IsAArch64) {
inline void callWithDynoStats(raw_ostream &OS, FnType &&Func, FuncsType &Funcs,
StringRef Phase, const bool Flag,
bool IsAArch64) {
DynoStats DynoStatsBefore(IsAArch64);
if (Flag)
DynoStatsBefore = getDynoStats(Funcs, IsAArch64);
Expand All @@ -170,12 +171,12 @@ inline void callWithDynoStats(FnType &&Func, FuncsType &Funcs, StringRef Phase,
if (Flag) {
const DynoStats DynoStatsAfter = getDynoStats(Funcs, IsAArch64);
const bool Changed = (DynoStatsAfter != DynoStatsBefore);
outs() << "BOLT-INFO: program-wide dynostats after running " << Phase
<< (Changed ? "" : " (no change)") << ":\n\n"
<< DynoStatsBefore << '\n';
OS << "BOLT-INFO: program-wide dynostats after running " << Phase
<< (Changed ? "" : " (no change)") << ":\n\n"
<< DynoStatsBefore << '\n';
if (Changed)
DynoStatsAfter.print(outs(), &DynoStatsBefore);
outs() << '\n';
DynoStatsAfter.print(OS, &DynoStatsBefore);
OS << '\n';
}
}

Expand Down
4 changes: 3 additions & 1 deletion bolt/include/bolt/Core/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ class FDE;

namespace bolt {

class BinaryContext;
class BinaryFunction;

/// \brief Wraps up information to read all CFI instructions and feed them to a
/// BinaryFunction, as well as rewriting CFI sections.
class CFIReaderWriter {
public:
explicit CFIReaderWriter(const DWARFDebugFrame &EHFrame);
explicit CFIReaderWriter(BinaryContext &BC, const DWARFDebugFrame &EHFrame);

bool fillCFIInfoFor(BinaryFunction &Function) const;

Expand All @@ -59,6 +60,7 @@ class CFIReaderWriter {
const FDEsMap &getFDEs() const { return FDEs; }

private:
BinaryContext &BC;
FDEsMap FDEs;
};

Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/ADRRelaxationPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ADRRelaxationPass : public BinaryFunctionPass {
const char *getName() const override { return "adr-relaxation"; }

/// Pass entry point
void runOnFunctions(BinaryContext &BC) override;
Error runOnFunctions(BinaryContext &BC) override;
void runOnFunction(BinaryFunction &BF);
};

Expand Down
Loading

0 comments on commit f56cc62

Please sign in to comment.