Skip to content

Commit

Permalink
LLVM and SPIRV-LLVM-Translator pulldown (WW18 2024)
Browse files Browse the repository at this point in the history
  • Loading branch information
bb-sycl committed May 3, 2024
2 parents 67f3bf2 + cc0a77e commit 5cc0417
Show file tree
Hide file tree
Showing 2,508 changed files with 266,831 additions and 121,806 deletions.
2 changes: 1 addition & 1 deletion .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function add-dependencies() {
echo "${project}"
case ${project} in
bolt)
for p in lld llvm; do
for p in clang lld llvm; do
echo $p
done
;;
Expand Down
1 change: 0 additions & 1 deletion .ci/monolithic-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
-D LLVM_LIT_ARGS="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --timeout=1200 --time-tests" \
-D LLVM_ENABLE_LLD=ON \
-D CMAKE_CXX_FLAGS=-gmlt \
-D BOLT_CLANG_EXE=/usr/bin/clang \
-D LLVM_CCACHE_BUILD=ON \
-D MLIR_ENABLE_BINDINGS_PYTHON=ON

Expand Down
4 changes: 4 additions & 0 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
BOLT:
- bolt/**/*

ClangIR:
- clang/include/clang/CIR/**/*
- clang/lib/CIR/**/*
Expand Down Expand Up @@ -467,6 +470,7 @@ backend:m68k:

libc++:
- libcxx/**
- .github/workflows/libcxx-*

libc++abi:
- libcxxabi/**
Expand Down
3 changes: 1 addition & 2 deletions bolt/include/bolt/Passes/BinaryPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ class PrintProfileStats : public BinaryFunctionPass {
/// dyno stats categories.
class PrintProgramStats : public BinaryFunctionPass {
public:
explicit PrintProgramStats(const cl::opt<bool> &PrintPass)
: BinaryFunctionPass(PrintPass) {}
explicit PrintProgramStats() : BinaryFunctionPass(false) {}

const char *getName() const override { return "print-stats"; }
bool shouldPrint(const BinaryFunction &) const override { return false; }
Expand Down
11 changes: 11 additions & 0 deletions bolt/include/bolt/Rewrite/RewriteInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,18 @@ class RewriteInstance {
/// Section name used for extra BOLT code in addition to .text.
static StringRef getBOLTTextSectionName() { return ".bolt.text"; }

/// Symbol markers for BOLT reserved area.
static StringRef getBOLTReservedStart() { return "__bolt_reserved_start"; }
static StringRef getBOLTReservedEnd() { return "__bolt_reserved_end"; }

/// Common section names.
static StringRef getEHFrameSectionName() { return ".eh_frame"; }
static StringRef getEHFrameHdrSectionName() { return ".eh_frame_hdr"; }
static StringRef getRelaDynSectionName() { return ".rela.dyn"; }

/// FILE symbol name used for local fragments of global functions.
static StringRef getBOLTFileSymbolName() { return "bolt-pseudo.o"; }

/// An instance of the input binary we are processing, externally owned.
llvm::object::ELFObjectFileBase *InputFile;

Expand Down Expand Up @@ -490,6 +498,9 @@ class RewriteInstance {
/// Store all non-zero symbols in this map for a quick address lookup.
std::map<uint64_t, llvm::object::SymbolRef> FileSymRefs;

/// FILE symbols used for disambiguating split function parents.
std::vector<ELFSymbolRef> FileSymbols;

std::unique_ptr<DWARFRewriter> DebugInfoRewriter;

std::unique_ptr<BoltAddressTranslation> BAT;
Expand Down
17 changes: 15 additions & 2 deletions bolt/include/bolt/Utils/NameResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,23 @@ class NameResolver {
static constexpr char Sep = '/';

public:
/// Return unique version of the \p Name in the form "Name<Sep><Number>".
/// Return the number of uniquified versions of a given \p Name.
uint64_t getUniquifiedNameCount(StringRef Name) const {
if (Counters.contains(Name))
return Counters.at(Name);
return 0;
}

/// Return unique version of the \p Name in the form "Name<Sep><ID>".
std::string getUniqueName(StringRef Name, const uint64_t ID) const {
return (Name + Twine(Sep) + Twine(ID)).str();
}

/// Register new version of \p Name and return unique version in the form
/// "Name<Sep><Number>".
std::string uniquify(StringRef Name) {
const uint64_t ID = ++Counters[Name];
return (Name + Twine(Sep) + Twine(ID)).str();
return getUniqueName(Name, ID);
}

/// For uniquified \p Name, return the original form (that may no longer be
Expand Down
2 changes: 2 additions & 0 deletions bolt/lib/Profile/DataAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "bolt/Profile/DataAggregator.h"
#include "bolt/Core/BinaryContext.h"
#include "bolt/Core/BinaryFunction.h"
#include "bolt/Passes/BinaryPasses.h"
#include "bolt/Profile/BoltAddressTranslation.h"
#include "bolt/Profile/Heatmap.h"
#include "bolt/Profile/YAMLProfileWriter.h"
Expand Down Expand Up @@ -611,6 +612,7 @@ Error DataAggregator::readProfile(BinaryContext &BC) {
if (std::error_code EC = writeBATYAML(BC, opts::SaveProfile))
report_error("cannot create output data file", EC);
}
BC.logBOLTErrorsAndQuitOnFatal(PrintProgramStats().runOnFunctions(BC));
}

return Error::success();
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Rewrite/BinaryPassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
// order they're registered.

// Run this pass first to use stats for the original functions.
Manager.registerPass(std::make_unique<PrintProgramStats>(NeverPrint));
Manager.registerPass(std::make_unique<PrintProgramStats>());

if (opts::PrintProfileStats)
Manager.registerPass(std::make_unique<PrintProfileStats>(NeverPrint));
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Rewrite/BoltDiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class RewriteInstanceDiff {
}
}
}
PrintProgramStats PPS(opts::NeverPrint);
PrintProgramStats PPS;
outs() << "* BOLT-DIFF: Starting print program stats pass for binary 1\n";
RI1.BC->logBOLTErrorsAndQuitOnFatal(PPS.runOnFunctions(*RI1.BC));
outs() << "* BOLT-DIFF: Starting print program stats pass for binary 2\n";
Expand Down
32 changes: 32 additions & 0 deletions bolt/lib/Rewrite/LinuxKernelRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
/// Update ORC data in the binary.
Error rewriteORCTables();

/// Validate written ORC tables after binary emission.
Error validateORCTables();

/// Static call table handling.
Error readStaticCalls();
Error rewriteStaticCalls();
Expand Down Expand Up @@ -358,6 +361,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
if (Error E = updateStaticKeysJumpTablePostEmit())
return E;

if (Error E = validateORCTables())
return E;

return Error::success();
}
};
Expand Down Expand Up @@ -837,6 +843,32 @@ Error LinuxKernelRewriter::rewriteORCTables() {
return Error::success();
}

Error LinuxKernelRewriter::validateORCTables() {
if (!ORCUnwindIPSection)
return Error::success();

const uint64_t IPSectionAddress = ORCUnwindIPSection->getAddress();
DataExtractor IPDE = DataExtractor(ORCUnwindIPSection->getOutputContents(),
BC.AsmInfo->isLittleEndian(),
BC.AsmInfo->getCodePointerSize());
DataExtractor::Cursor IPCursor(0);
uint64_t PrevIP = 0;
for (uint32_t Index = 0; Index < NumORCEntries; ++Index) {
const uint64_t IP =
IPSectionAddress + IPCursor.tell() + (int32_t)IPDE.getU32(IPCursor);
if (!IPCursor)
return createStringError(errc::executable_format_error,
"out of bounds while reading ORC IP table: %s",
toString(IPCursor.takeError()).c_str());

assert(IP >= PrevIP && "Unsorted ORC table detected");
(void)PrevIP;
PrevIP = IP;
}

return Error::success();
}

/// The static call site table is created by objtool and contains entries in the
/// following format:
///
Expand Down
Loading

0 comments on commit 5cc0417

Please sign in to comment.