Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
091c62b
triagebot: Enable the range-diff feature
tgross35 Dec 4, 2025
382e9fa
ci: Update the default branch name
tgross35 Dec 2, 2025
1cfe358
bench: Update the benchmark runner to gungraun 0.17
tgross35 Dec 4, 2025
c8f0d64
bench: Add `strip = false` to the bench profile
tgross35 Dec 5, 2025
b09903f
bench: Disambiguate benchmark names in `mem_icount`
tgross35 Dec 5, 2025
15d03de
ci: bench: Enable all `icount` benches in CI
tgross35 Dec 5, 2025
5f39763
require some basic operators in trait DInt
quaternic Aug 12, 2025
3a93154
Implement accelerated computation of (x << e) % y in unsigned integers
quaternic Aug 12, 2025
21b89a9
Remove remaining traces of AT&T assembly syntax
TDecking May 8, 2025
ec65d89
Document the purpose of a helper module
quaternic Dec 5, 2025
e2ee56b
libm: Optimize `fmod`
quaternic Jul 31, 2025
2261a50
Remove incorrectly placed preserves_flags, and other inline asm fixes
quaternic Dec 6, 2025
65a4f94
libm: Implement `exp` and its variants for i586 with inline assembly
quaternic Dec 6, 2025
e87befc
ci: Enable benchmarks on Aarch64
tgross35 Dec 6, 2025
6b159bd
Update Cargo.toml `authors` fields
tgross35 Jul 24, 2025
b3e2074
ci: Simplify untar path list output
tgross35 Dec 6, 2025
0173568
ci: Update the default branch name in remaining workflow files
tgross35 Dec 7, 2025
19b809e
ci: Print CPU information for benchmarks
tgross35 Dec 7, 2025
d6139b1
ci: Switch the x86 Apple job to the `macos-15-intel` runner
tgross35 Dec 7, 2025
2422c1d
Remove `[no-mentions]` handler in our triagebot config
Urgau Dec 8, 2025
fe79161
Prepare for merging from rust-lang/rust
invalid-email-address Dec 17, 2025
18067a7
Merge ref '2dc30247c5d8' from rust-lang/rust
invalid-email-address Dec 17, 2025
bd06672
apply the rename to aarch64_outline_atomics in builtins-test
quaternic Dec 16, 2025
5faeb43
remove uses of Ord::clamp in scalbn (#1047)
quaternic Dec 17, 2025
a9fa80c
Fix `expm1f` overflow threshold
quaternic Dec 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions library/compiler-builtins/.github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI
on:
push: { branches: [master] }
push: { branches: [main] }
pull_request:

concurrency:
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
- target: x86_64-unknown-linux-gnu
os: ubuntu-24.04
- target: x86_64-apple-darwin
os: macos-13
os: macos-15-intel
- target: i686-pc-windows-msvc
os: windows-2025
- target: x86_64-pc-windows-msvc
Expand Down Expand Up @@ -239,6 +239,8 @@ jobs:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-24.04
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
Expand All @@ -247,13 +249,13 @@ jobs:
- name: Set up dependencies
run: |
sudo apt-get update
sudo apt-get install -y valgrind gdb libc6-dbg # Needed for iai-callgrind
sudo apt-get install -y valgrind gdb libc6-dbg # Needed for gungraun
rustup update "$BENCHMARK_RUSTC" --no-self-update
rustup default "$BENCHMARK_RUSTC"
# Install the version of iai-callgrind-runner that is specified in Cargo.toml
iai_version="$(cargo metadata --format-version=1 --features icount |
jq -r '.packages[] | select(.name == "iai-callgrind").version')"
cargo binstall -y iai-callgrind-runner --version "$iai_version"
# Install the version of gungraun-runner that is specified in Cargo.toml
gungraun_version="$(cargo metadata --format-version=1 --features icount |
jq -r '.packages[] | select(.name == "gungraun").version')"
cargo binstall -y gungraun-runner --version "$gungraun_version"
sudo apt-get install valgrind
- uses: Swatinem/rust-cache@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion library/compiler-builtins/.github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ permissions:
contents: write

on:
push: { branches: [master] }
push: { branches: [main] }

jobs:
release-plz:
Expand Down
2 changes: 1 addition & 1 deletion library/compiler-builtins/.github/workflows/rustc-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
zulip-stream-id: 219381
zulip-topic: 'compiler-builtins subtree sync automation'
zulip-bot-email: "[email protected]"
pr-base-branch: master
pr-base-branch: main
branch-name: rustc-pull
secrets:
zulip-api-token: ${{ secrets.ZULIP_API_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions library/compiler-builtins/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ compiler-rt
# Benchmark cache
baseline-*
iai-home
gungraun-home

# Temporary files
*.bk
Expand Down
6 changes: 3 additions & 3 deletions library/compiler-builtins/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ cargo bench --no-default-features \
```

There are also benchmarks that check instruction count behind the `icount`
feature. These require [`iai-callgrind-runner`] (via Cargo) and [Valgrind]
to be installed, which means these only run on limited platforms.
feature. These require [`gungraun-runner`] (via Cargo) and [Valgrind] to be
installed, which means these only run on limited platforms.

Instruction count benchmarks are run as part of CI to flag performance
regresions.
Expand All @@ -163,7 +163,7 @@ cargo bench --no-default-features \
--bench icount --bench mem_icount
```

[`iai-callgrind-runner`]: https://crates.io/crates/iai-callgrind-runner
[`gungraun-runner`]: https://crates.io/crates/gungraun-runner
[Valgrind]: https://valgrind.org/

## Subtree synchronization
Expand Down
3 changes: 2 additions & 1 deletion library/compiler-builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ codegen-units = 1
lto = "fat"

[profile.bench]
# Required for iai-callgrind
# Required for gungraun
debug = true
strip = false
2 changes: 1 addition & 1 deletion library/compiler-builtins/PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It's not great, but it works for now. PRs to improve this process would be
greatly appreciated!

1. Make sure you've got a clean working tree and it's updated with the latest
changes on `master`
changes on `main`
2. Edit `Cargo.toml` to bump the version number
3. Commit this change
4. Run `git tag` to create a tag for this version
Expand Down
7 changes: 6 additions & 1 deletion library/compiler-builtins/builtins-shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
[package]
name = "compiler_builtins"
version = "0.1.160"
authors = ["Jorge Aparicio <[email protected]>"]
authors = [
"Alex Crichton <[email protected]>",
"Amanieu d'Antras <[email protected]>",
"Jorge Aparicio <[email protected]>",
"Trevor Gross <[email protected]>",
]
description = "Compiler intrinsics used by the Rust compiler."
repository = "https://github.com/rust-lang/compiler-builtins"
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
Expand Down
7 changes: 3 additions & 4 deletions library/compiler-builtins/builtins-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "builtins-test"
version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
edition = "2024"
publish = false
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
Expand All @@ -14,7 +13,7 @@ rand_xoshiro = "0.7"
# To compare float builtins against
rustc_apfloat = "0.2.3"
# Really a dev dependency, but dev dependencies can't be optional
iai-callgrind = { version = "0.15.2", optional = true }
gungraun = { version = "0.17.0", optional = true }

[dependencies.compiler_builtins]
path = "../builtins-shim"
Expand Down Expand Up @@ -46,8 +45,8 @@ no-sys-f16-f64-convert = []
# Skip tests that rely on f16 symbols being available on the system
no-sys-f16 = ["no-sys-f16-f64-convert"]

# Enable icount benchmarks (requires iai-callgrind and valgrind)
icount = ["dep:iai-callgrind"]
# Enable icount benchmarks (requires gungraun-runner and valgrind locally)
icount = ["dep:gungraun"]

# Enable report generation without bringing in more dependencies by default
benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]
Expand Down
22 changes: 11 additions & 11 deletions library/compiler-builtins/builtins-test/benches/mem_icount.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Benchmarks that use Callgrind (via `iai_callgrind`) to report instruction count metrics. This
//! Benchmarks that use Callgrind (via `gungraun`) to report instruction count metrics. This
//! is stable enough to be tested in CI.

use std::hint::black_box;
use std::{ops, slice};

use compiler_builtins::mem::{memcmp, memcpy, memmove, memset};
use iai_callgrind::{library_benchmark, library_benchmark_group, main};
use gungraun::{library_benchmark, library_benchmark_group, main};

const PAGE_SIZE: usize = 0x1000; // 4 kiB
const MAX_ALIGN: usize = 512; // assume we may use avx512 operations one day
Expand Down Expand Up @@ -108,7 +108,7 @@ mod mcpy {
],
setup = setup,
)]
fn bench((len, mut dst, src): (usize, AlignedSlice, AlignedSlice)) {
fn bench_cpy((len, mut dst, src): (usize, AlignedSlice, AlignedSlice)) {
unsafe {
black_box(memcpy(
black_box(dst.as_mut_ptr()),
Expand All @@ -118,7 +118,7 @@ mod mcpy {
}
}

library_benchmark_group!(name = memcpy; benchmarks = bench);
library_benchmark_group!(name = memcpy; benchmarks = bench_cpy);
}

mod mset {
Expand Down Expand Up @@ -157,7 +157,7 @@ mod mset {
],
setup = setup,
)]
fn bench((len, mut dst): (usize, AlignedSlice)) {
fn bench_set((len, mut dst): (usize, AlignedSlice)) {
unsafe {
black_box(memset(
black_box(dst.as_mut_ptr()),
Expand All @@ -167,7 +167,7 @@ mod mset {
}
}

library_benchmark_group!(name = memset; benchmarks = bench);
library_benchmark_group!(name = memset; benchmarks = bench_set);
}

mod mcmp {
Expand Down Expand Up @@ -225,7 +225,7 @@ mod mcmp {
],
setup = setup
)]
fn bench((len, mut dst, src): (usize, AlignedSlice, AlignedSlice)) {
fn bench_cmp((len, mut dst, src): (usize, AlignedSlice, AlignedSlice)) {
unsafe {
black_box(memcmp(
black_box(dst.as_mut_ptr()),
Expand All @@ -235,7 +235,7 @@ mod mcmp {
}
}

library_benchmark_group!(name = memcmp; benchmarks = bench);
library_benchmark_group!(name = memcmp; benchmarks = bench_cmp);
}

mod mmove {
Expand Down Expand Up @@ -384,7 +384,7 @@ mod mmove {
],
setup = setup_forward
)]
fn forward((len, spread, mut buf): (usize, usize, AlignedSlice)) {
fn forward_move((len, spread, mut buf): (usize, usize, AlignedSlice)) {
// Test moving from the start of the buffer toward the end
unsafe {
black_box(memmove(
Expand Down Expand Up @@ -478,7 +478,7 @@ mod mmove {
],
setup = setup_backward
)]
fn backward((len, spread, mut buf): (usize, usize, AlignedSlice)) {
fn backward_move((len, spread, mut buf): (usize, usize, AlignedSlice)) {
// Test moving from the end of the buffer toward the start
unsafe {
black_box(memmove(
Expand All @@ -489,7 +489,7 @@ mod mmove {
}
}

library_benchmark_group!(name = memmove; benchmarks = forward, backward);
library_benchmark_group!(name = memmove; benchmarks = forward_move, backward_move);
}

use mcmp::memcmp;
Expand Down
18 changes: 14 additions & 4 deletions library/compiler-builtins/builtins-test/tests/lse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ mod cas {
let mut target = expected.wrapping_add(10);
assert_eq!(
unsafe {
compiler_builtins::aarch64_linux::$name::$name(expected, new, &mut target)
compiler_builtins::aarch64_outline_atomics::$name::$name(
expected,
new,
&mut target,
)
},
expected.wrapping_add(10),
"return value should always be the previous value",
Expand All @@ -33,7 +37,11 @@ mod cas {
target = expected;
assert_eq!(
unsafe {
compiler_builtins::aarch64_linux::$name::$name(expected, new, &mut target)
compiler_builtins::aarch64_outline_atomics::$name::$name(
expected,
new,
&mut target,
)
},
expected
);
Expand All @@ -54,7 +62,9 @@ mod swap {
builtins_test::fuzz_2(10000, |left: super::int_ty!($bytes), mut right| {
let orig_right = right;
assert_eq!(
unsafe { compiler_builtins::aarch64_linux::$name::$name(left, &mut right) },
unsafe {
compiler_builtins::aarch64_outline_atomics::$name::$name(left, &mut right)
},
orig_right
);
assert_eq!(left, right);
Expand All @@ -74,7 +84,7 @@ macro_rules! test_op {
let mut target = old;
let op: fn(super::int_ty!($bytes), super::int_ty!($bytes)) -> _ = $($op)*;
let expected = op(old, val);
assert_eq!(old, unsafe { compiler_builtins::aarch64_linux::$name::$name(val, &mut target) }, "{} should return original value", stringify!($name));
assert_eq!(old, unsafe { compiler_builtins::aarch64_outline_atomics::$name::$name(val, &mut target) }, "{} should return original value", stringify!($name));
assert_eq!(expected, target, "{} should store to target", stringify!($name));
});
}
Expand Down
38 changes: 23 additions & 15 deletions library/compiler-builtins/ci/bench-icount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,53 @@ if [ -z "$target" ]; then
target="$host_target"
fi

iai_home="iai-home"
# Print machine information
uname -a
lscpu || true

gungraun_home="gungraun-home"

# Use the arch as a tag to disambiguate artifacts
tag="$(echo "$target" | cut -d'-' -f1)"

# Download the baseline from master
# Download the baseline from main
./ci/ci-util.py locate-baseline --download --extract --tag "$tag"

# FIXME: migration from iai-named baselines to gungraun, can be dropped
# after the first run with gungraun.
[ -d "iai-home" ] && mv "iai-home" "$gungraun_home"

# Run benchmarks once
function run_icount_benchmarks() {
cargo_args=(
"--bench" "icount"
"--bench" "*icount*"
"--no-default-features"
"--features" "unstable,unstable-float,icount"
)

iai_args=(
"--home" "$(pwd)/$iai_home"
"--callgrind-limits=ir=5.0"
gungraun_args=(
"--home" "$(pwd)/$gungraun_home"
"--callgrind-limits=ir=5.0%"
"--save-summary"
)

# Parse `cargo_arg0 cargo_arg1 -- iai_arg0 iai_arg1` syntax
parsing_iai_args=0
# Parse `cargo_arg0 cargo_arg1 -- gungraun_arg0 gungraun_arg1` syntax
parsing_gungraun_args=0
while [ "$#" -gt 0 ]; do
if [ "$parsing_iai_args" == "1" ]; then
iai_args+=("$1")
if [ "$parsing_gungraun_args" == "1" ]; then
gungraun_args+=("$1")
elif [ "$1" == "--" ]; then
parsing_iai_args=1
parsing_gungraun_args=1
else
cargo_args+=("$1")
fi

shift
done

# Run iai-callgrind benchmarks. Do this in a subshell with `&& true` to
# capture rather than exit on error.
(cargo bench "${cargo_args[@]}" -- "${iai_args[@]}") && true
# Run gungraun benchmarks. Do this in a subshell with `&& true` to capture
# rather than exit on error.
(cargo bench "${cargo_args[@]}" -- "${gungraun_args[@]}") && true
exit_code="$?"

if [ "$exit_code" -eq 0 ]; then
Expand All @@ -68,4 +76,4 @@ run_icount_benchmarks -- --save-baseline=hardfloat
# Name and tar the new baseline
name="baseline-icount-$tag-$(date -u +'%Y%m%d%H%M')-${GITHUB_SHA:0:12}"
echo "BASELINE_NAME=$name" >>"$GITHUB_ENV"
tar cJf "$name.tar.xz" "$iai_home"
tar cJf "$name.tar.xz" "$gungraun_home"
Loading
Loading