Skip to content

Commit

Permalink
LLVM and SPIRV-LLVM-Translator pulldown (WW02 2025)
Browse files Browse the repository at this point in the history
  • Loading branch information
bb-sycl committed Jan 12, 2025
2 parents 2cfe8e6 + 2bae401 commit df9fba6
Show file tree
Hide file tree
Showing 1,447 changed files with 56,335 additions and 23,331 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-ci-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ jobs:

- name: Test Container
run: |
for image in ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}; do
podman run --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
for image in ${{ steps.vars.outputs.container-name-tag }}; do
# Use --pull=never to ensure we are testing the just built image.
podman run --pull=never --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
done
push-ci-container:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/new-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: llvm/actions/issue-labeler@main
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token: ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}
configuration-path: .github/new-issues-labeler.yml
include-title: 1
include-body: 0
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
shell: bash
run: |
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user ${{ github.actor }} --user-token "$USER_TOKEN" check-permissions
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user "$GITHUB_ACTOR" --user-token "$USER_TOKEN" check-permissions
- name: Collect Variables
id: vars
Expand All @@ -102,8 +102,8 @@ jobs:
release_version="$trimmed"
ref="llvmorg-$release_version"
else
release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-${{ github.sha }}"
ref=${{ github.sha }}
release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-$GITHUB_SHA"
ref="$GITHUB_SHA"
fi
if [ -n "${{ inputs.upload }}" ]; then
upload="${{ inputs.upload }}"
Expand All @@ -114,20 +114,20 @@ jobs:
echo "ref=$ref" >> $GITHUB_OUTPUT
echo "upload=$upload" >> $GITHUB_OUTPUT
release_binary_basename="LLVM-$release_version-${{ runner.os }}-${{ runner.arch }}"
release_binary_basename="LLVM-$release_version-$RUNNER_OS-$RUNNER_ARCH"
echo "release-binary-basename=$release_binary_basename" >> $GITHUB_OUTPUT
echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT
# Detect necessary CMake flags
target="${{ runner.os }}-${{ runner.arch }}"
target="$RUNNER_OS-$RUNNER_ARCH"
echo "enable-pgo=false" >> $GITHUB_OUTPUT
target_cmake_flags="-DLLVM_RELEASE_ENABLE_PGO=OFF"
# The macOS builds try to cross compile some libraries so we need to
# add extra CMake args to disable them.
# See https://github.com/llvm/llvm-project/issues/99767
if [ "${{ runner.os }}" = "macOS" ]; then
if [ "$RUNNER_OS" = "macOS" ]; then
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_COMPILER_RT_ENABLE_IOS=OFF"
if [ "${{ runner.arch }}" = "ARM64" ]; then
if [ "$RUNNER_ARCH" = "ARM64" ]; then
arches=arm64
else
arches=x86_64
Expand All @@ -137,7 +137,7 @@ jobs:
build_flang="true"
if [ "${{ runner.os }}" = "Windows" ]; then
if [ "$RUNNER_OS" = "Windows" ]; then
# The build times out on Windows, so we need to disable LTO.
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF"
fi
Expand Down
9 changes: 0 additions & 9 deletions bolt/docs/CommandLineArgumentReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -931,15 +931,6 @@

Remove redundant Address-Size override prefix

### BOLT options in relocation mode:

- `--align-macro-fusion=<value>`

Fix instruction alignment for macro-fusion (x86 relocation mode)
- `none`: do not insert alignment no-ops for macro-fusion
- `hot`: only insert alignment no-ops on hot execution paths (default)
- `all`: always align instructions to allow macro-fusion

### BOLT instrumentation options:

`llvm-bolt <executable> -instrument [-o outputfile] <instrumented-executable>`
Expand Down
5 changes: 5 additions & 0 deletions bolt/include/bolt/Core/BinaryData.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ class BinaryData {
return Parent && (Parent == BD || Parent->isAncestorOf(BD));
}

void updateSize(uint64_t N) {
if (N > Size)
Size = N;
}

void setIsMoveable(bool Flag) { IsMoveable = Flag; }
void setSection(BinarySection &NewSection);
void setOutputSection(BinarySection &NewSection) {
Expand Down
1 change: 1 addition & 0 deletions bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ MCSymbol *BinaryContext::registerNameAtAddress(StringRef Name, uint64_t Address,
BD = GAI->second;
if (!BD->hasName(Name)) {
GlobalSymbols[Name] = BD;
BD->updateSize(Size);
BD->Symbols.push_back(Symbol);
}
}
Expand Down
59 changes: 59 additions & 0 deletions bolt/lib/Rewrite/LinuxKernelRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorOr.h"
#include <regex>

#define DEBUG_TYPE "bolt-linux"

Expand Down Expand Up @@ -89,6 +91,34 @@ static cl::opt<bool>

} // namespace opts

/// Linux kernel version
struct LKVersion {
LKVersion() {}
LKVersion(unsigned Major, unsigned Minor, unsigned Rev)
: Major(Major), Minor(Minor), Rev(Rev) {}

bool operator<(const LKVersion &Other) const {
return std::make_tuple(Major, Minor, Rev) <
std::make_tuple(Other.Major, Other.Minor, Other.Rev);
}

bool operator>(const LKVersion &Other) const { return Other < *this; }

bool operator<=(const LKVersion &Other) const { return !(*this > Other); }

bool operator>=(const LKVersion &Other) const { return !(*this < Other); }

bool operator==(const LKVersion &Other) const {
return Major == Other.Major && Minor == Other.Minor && Rev == Other.Rev;
}

bool operator!=(const LKVersion &Other) const { return !(*this == Other); }

unsigned Major{0};
unsigned Minor{0};
unsigned Rev{0};
};

/// Linux Kernel supports stack unwinding using ORC (oops rewind capability).
/// ORC state at every IP can be described by the following data structure.
struct ORCState {
Expand Down Expand Up @@ -148,6 +178,8 @@ class AddressExtractor : public DataExtractor {
};

class LinuxKernelRewriter final : public MetadataRewriter {
LKVersion LinuxKernelVersion;

/// Information required for updating metadata referencing an instruction.
struct InstructionFixup {
BinarySection &Section; // Section referencing the instruction.
Expand Down Expand Up @@ -249,6 +281,8 @@ class LinuxKernelRewriter final : public MetadataRewriter {
ErrorOr<BinarySection &> PCIFixupSection = std::errc::bad_address;
static constexpr size_t PCI_FIXUP_ENTRY_SIZE = 16;

Error detectLinuxKernelVersion();

/// Process linux kernel special sections and their relocations.
void processLKSections();

Expand Down Expand Up @@ -314,6 +348,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
: MetadataRewriter("linux-kernel-rewriter", BC) {}

Error preCFGInitializer() override {
if (Error E = detectLinuxKernelVersion())
return E;

processLKSections();

if (Error E = processSMPLocks())
Expand Down Expand Up @@ -394,6 +431,28 @@ class LinuxKernelRewriter final : public MetadataRewriter {
}
};

Error LinuxKernelRewriter::detectLinuxKernelVersion() {
if (BinaryData *BD = BC.getBinaryDataByName("linux_banner")) {
const BinarySection &Section = BD->getSection();
const std::string S =
Section.getContents().substr(BD->getOffset(), BD->getSize()).str();

const std::regex Re(R"---(Linux version ((\d+)\.(\d+)(\.(\d+))?))---");
std::smatch Match;
if (std::regex_search(S, Match, Re)) {
const unsigned Major = std::stoi(Match[2].str());
const unsigned Minor = std::stoi(Match[3].str());
const unsigned Rev = Match[5].matched ? std::stoi(Match[5].str()) : 0;
LinuxKernelVersion = LKVersion(Major, Minor, Rev);
BC.outs() << "BOLT-INFO: Linux kernel version is " << Match[1].str()
<< "\n";
return Error::success();
}
}
return createStringError(errc::executable_format_error,
"Linux kernel version is unknown");
}

void LinuxKernelRewriter::processLKSections() {
processLKKSymtab();
processLKKSymtab(true);
Expand Down
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-alt-instruction.s
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ _start:
.section .orc_unwind_ip
.long .L0 + 2 - .

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-bug-table.s
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ _start:
.long .L1 - . # instruction
.org 2b + 12

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-exceptions.s
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ foo:
.long .LF0 - . # fixup
.long 0 # data

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-orc.s
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ bar:
.section .orc_unwind_ip
.long .L4 - .

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-parainstructions.s
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ _start:
.byte 1 # type
.byte 7 # length

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-pci-fixup.s
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ _start:
.long 0x0 # class shift
.long .L0 - . # fixup

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-smp-locks.s
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ _start:
.long .L0 - .
.long .L1 - .

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-static-calls.s
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ __start_static_call_sites:
.type __stop_static_call_sites, %object
__stop_static_call_sites:

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
9 changes: 9 additions & 0 deletions bolt/test/X86/linux-static-keys.s
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ __stop___jump_table:
fake_static_key:
.quad 0

## Linux kernel version
.rodata
.align 16
.globl linux_banner
.type linux_banner, @object
linux_banner:
.string "Linux version 6.6.61\n"
.size linux_banner, . - linux_banner

## Fake Linux Kernel sections.
.section __ksymtab,"a",@progbits
.section __ksymtab_gpl,"a",@progbits
Loading

0 comments on commit df9fba6

Please sign in to comment.