Skip to content

Commit

Permalink
Enable LLVM optimizations
Browse files Browse the repository at this point in the history
This enables a set of LLVM optimization passes for the "balanced" and
"aggressive" profiles. Both are based on the "default<O2>" pipeline,
with the removal of some irrelevant passes. In the case of the
"balanced" profile we also remove some additional passes that aren't
likely to be useful in most cases.

This fixes #595.

Changelog: added
  • Loading branch information
yorickpeterse committed Jan 14, 2025
1 parent 63280d0 commit 571ba8f
Show file tree
Hide file tree
Showing 7 changed files with 345 additions and 79 deletions.
127 changes: 85 additions & 42 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,49 +63,65 @@ jobs:
- name: Check the formatting
run: 'cd std && cargo run -- fmt --check'

amd64-linux-gnu:
compiler-linux:
strategy:
matrix:
include:
- image: 'ci:fedora'
target: amd64-linux-gnu
- image: 'ci:alpine'
target: amd64-linux-musl
name: ${{ matrix.target }} compiler
timeout-minutes: 15
runs-on: ubuntu-24.04
container:
image: ghcr.io/inko-lang/ci:fedora
image: ghcr.io/inko-lang/${{ matrix.image }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: '${{ env.CARGO_HOME }}'
key: amd64-linux-gnu-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
key: ${{ matrix.target }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
- name: Run compiler tests
run: cargo test
- name: Run stdlib tests with default optimizations
run: 'cd std && cargo run -- test'
- name: Run stdlib tests without optimizations
run: 'cd std && cargo run -- test --opt=none'
- name: Run stdlib tests with aggressive optimizations
run: 'cd std && cargo run -- test --opt=aggressive'

amd64-linux-musl:
std-linux:
strategy:
matrix:
level:
- none
- balanced
- aggressive
include:
- image: 'ci:fedora'
target: amd64-linux-gnu
- image: 'ci:alpine'
target: amd64-linux-musl
name: ${{ matrix.target }} std --opt=${{ matrix.level }}
timeout-minutes: 15
runs-on: ubuntu-24.04
container:
image: ghcr.io/inko-lang/ci:alpine
image: ghcr.io/inko-lang/${{ matrix.image }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: '${{ env.CARGO_HOME }}'
key: amd64-linux-musl-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
- name: Run compiler tests
run: cargo test
- name: Run stdlib tests with default optimizations
run: 'cd std && cargo run -- test'
- name: Run stdlib tests without optimizations
run: 'cd std && cargo run -- test --opt=none'
- name: Run stdlib tests with aggressive optimizations
run: 'cd std && cargo run -- test --opt=aggressive'
key: ${{ matrix.target }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
- name: Run tests
run: 'cd std && cargo run -- test --opt=${{ matrix.level }}'

amd64-mac-native:
compiler-mac:
strategy:
matrix:
include:
- runner: macos-13
target: amd64-mac-native
- runner: macos-14
target: arm64-mac-native
name: ${{ matrix.target }} compiler
timeout-minutes: 15
runs-on: macos-13
runs-on: ${{ matrix.runner }}
env:
RUSTUP_HOME: ${{ github.workspace }}/.rustup-home
steps:
Expand All @@ -115,21 +131,27 @@ jobs:
path: |
${{ env.CARGO_HOME }}
${{ env.RUSTUP_HOME }}
key: amd64-mac-native-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
key: ${{ matrix.target }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
- name: Install dependencies
run: ./ci/mac.sh
- name: Run compiler tests
run: cargo test
- name: Run stdlib tests with default optimizations
run: 'cd std && cargo run -- test'
- name: Run stdlib tests without optimizations
run: 'cd std && cargo run -- test --opt=none'
- name: Run stdlib tests with aggressive optimizations
run: 'cd std && cargo run -- test --opt=aggressive'

arm64-mac-native:
std-mac:
strategy:
matrix:
level:
- none
- balanced
- aggressive
include:
- runner: macos-13
target: amd64-mac-native
- runner: macos-14
target: arm64-mac-native
name: ${{ matrix.target }} std --opt=${{ matrix.level }}
timeout-minutes: 15
runs-on: macos-14
runs-on: ${{ matrix.runner }}
env:
RUSTUP_HOME: ${{ github.workspace }}/.rustup-home
steps:
Expand All @@ -139,19 +161,40 @@ jobs:
path: |
${{ env.CARGO_HOME }}
${{ env.RUSTUP_HOME }}
key: arm64-mac-native-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
key: ${{ matrix.target }}-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
- name: Install dependencies
run: ./ci/mac.sh
- name: Run compiler tests
run: cargo test
- name: Run stdlib tests with default optimizations
run: 'cd std && cargo run -- test'
- name: Run stdlib tests without optimizations
run: 'cd std && cargo run -- test --opt=none'
- name: Run stdlib tests with aggressive optimizations
run: 'cd std && cargo run -- test --opt=aggressive'
- name: Run tests
run: 'cd std && cargo run -- test --opt=${{ matrix.level }}'

compiler-freebsd:
name: amd64-freebsd-native compiler
timeout-minutes: 15
runs-on: ubuntu-24.04
env:
RUSTUP_HOME: ${{ github.workspace }}/.rustup-home
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
${{ env.CARGO_HOME }}
${{ env.RUSTUP_HOME }}
key: amd64-freebsd-native-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}
- name: Run tests
uses: cross-platform-actions/[email protected]
with:
operating_system: freebsd
version: '14.0'
memory: 8G
environment_variables: 'CARGO_HOME RUSTUP_HOME'
image_url: 'https://github.com/inko-lang/freebsd-builder/releases/download/v0.8.0/freebsd-14.0-x86-64.qcow2'
run: ./ci/freebsd.sh compiler

amd64-freebsd-native:
# FreeBSD builds are a bit slow due to the use of a VM, so we only run the
# stdlib tests using the default optimization level.
std-freebsd:
name: amd64-freebsd-native std
timeout-minutes: 15
runs-on: ubuntu-24.04
env:
Expand All @@ -172,4 +215,4 @@ jobs:
memory: 8G
environment_variables: 'CARGO_HOME RUSTUP_HOME'
image_url: 'https://github.com/inko-lang/freebsd-builder/releases/download/v0.8.0/freebsd-14.0-x86-64.qcow2'
run: ./ci/freebsd.sh
run: ./ci/freebsd.sh std
19 changes: 11 additions & 8 deletions ci/freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ echo "::endgroup::"

export PATH="${CARGO_HOME}/bin:${PATH}"

echo "::group::Run compiler tests"
cargo test
echo "::endgroup::"

echo "::group::Run stdlib tests"
cd std
cargo run -- test
echo "::endgroup::"
if [ "$1" = "compiler" ]
then
echo "::group::Run compiler tests"
cargo test
echo "::endgroup::"
else
echo "::group::Run stdlib tests"
cd std
cargo run -- test
echo "::endgroup::"
fi
1 change: 1 addition & 0 deletions compiler/src/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ pub(crate) mod layouts;
pub(crate) mod method_hasher;
pub(crate) mod methods;
pub(crate) mod module;
pub(crate) mod opt;
pub(crate) mod passes;
pub(crate) mod runtime_function;
Loading

0 comments on commit 571ba8f

Please sign in to comment.