Skip to content

Rollup of 8 pull requests #139358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bacd57a
Add integer to string formatting tests
GuillaumeGomez Mar 16, 2025
25900c2
Tweak integer to string conversion test a bit to be future-proof
GuillaumeGomez Mar 23, 2025
ec63690
refactor: Move Apple OSVersion (back) to rustc_target
madsmtm Feb 11, 2025
72b5ef0
refactor: Move env parsing of deployment target to rustc_session
madsmtm Feb 11, 2025
6ce74f7
replace extra_filename with strict version hash in metrics file names
yaahc Mar 25, 2025
53ef53a
settings.js: begin typechecking migration
lolbinarycat Apr 2, 2025
6ca7bd0
settings.js: add new rustdoc.Setting interface
lolbinarycat Apr 2, 2025
f056836
settings.js: remove dead code for adding <hr> to settings page
lolbinarycat Apr 2, 2025
9f8d3d0
settings.js: refactor settingsBlurHandler
lolbinarycat Apr 2, 2025
d2ff26b
settings.js: add some null checks to buildSettingsPage
lolbinarycat Apr 2, 2025
a805f52
settings.js: make top-level code typecheck
lolbinarycat Apr 2, 2025
8a34129
main.js: make hideAllModals docs clearer
lolbinarycat Apr 2, 2025
9f54910
settings.js: add elemContainsTarget utility function
lolbinarycat Apr 2, 2025
6a1f57d
Demote i686-pc-windows-gnu to Tier 2
Noratrieb Mar 1, 2025
ef1827b
settings.js: fix whitespace
lolbinarycat Apr 2, 2025
4435c99
rustdoc js: satisfy eslint
lolbinarycat Apr 2, 2025
fadea8e
Unset RUSTC_WRAPPER in cg_clif's build system
bjorn3 Mar 31, 2025
1397094
Run coretests and alloctests with cg_clif in CI
bjorn3 Apr 1, 2025
a91e97c
Fix 2024 edition doctest panic output
GuillaumeGomez Apr 3, 2025
fff2484
Add regression test for #137970
GuillaumeGomez Apr 3, 2025
fde54c2
Fix testing with randomized layouts enabled
bjorn3 Apr 3, 2025
f9927ee
Use `eprint!` instead of `eprintln!`
GuillaumeGomez Apr 3, 2025
087ffd7
add the autodiff batch mode frontend
ZuseZ4 Apr 3, 2025
e0c8ead
add autodiff batching middle-end
ZuseZ4 Apr 3, 2025
90d5545
add autodiff batching backend
ZuseZ4 Apr 3, 2025
eefe423
add new tests for autodiff batching and update old ones
ZuseZ4 Apr 3, 2025
2898b90
add new flag to print the module post-AD, before opts
ZuseZ4 Apr 3, 2025
18416c1
Rollup merge of #137869 - Noratrieb:Now_I_am_become_death,_the_destro…
Zalathar Apr 4, 2025
0745003
Rollup merge of #137880 - EnzymeAD:autodiff-batching, r=oli-obk
Zalathar Apr 4, 2025
838e94b
Rollup merge of #138546 - GuillaumeGomez:integer-to-string-tests, r=A…
Zalathar Apr 4, 2025
e5fec7c
Rollup merge of #138947 - madsmtm:refactor-apple-versions, r=Noratrieb
Zalathar Apr 4, 2025
5c4061c
Rollup merge of #138950 - yaahc:svh-metrics-name, r=bjorn3
Zalathar Apr 4, 2025
3666b2c
Rollup merge of #139213 - bjorn3:cg_clif_test_coretests, r=jieyouxu
Zalathar Apr 4, 2025
6634ad6
Rollup merge of #139274 - lolbinarycat:rustdoc-js-less-expect-error-p…
Zalathar Apr 4, 2025
08153dc
Rollup merge of #139328 - GuillaumeGomez:fix-panic-output-137970, r=f…
Zalathar Apr 4, 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
13 changes: 13 additions & 0 deletions compiler/rustc_ast/src/expand/autodiff_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ pub struct AutoDiffAttrs {
/// e.g. in the [JAX
/// Documentation](https://jax.readthedocs.io/en/latest/_tutorials/advanced-autodiff.html#how-it-s-made-two-foundational-autodiff-functions).
pub mode: DiffMode,
/// A user-provided, batching width. If not given, we will default to 1 (no batching).
/// Calling a differentiated, non-batched function through a loop 100 times is equivalent to:
/// - Calling the function 50 times with a batch size of 2
/// - Calling the function 25 times with a batch size of 4,
/// etc. A batched function takes more (or longer) arguments, and might be able to benefit from
/// cache locality, better re-usal of primal values, and other optimizations.
/// We will (before LLVM's vectorizer runs) just generate most LLVM-IR instructions `width`
/// times, so this massively increases code size. As such, values like 1024 are unlikely to
/// work. We should consider limiting this to u8 or u16, but will leave it at u32 for
/// experiments for now and focus on documenting the implications of a large width.
pub width: u32,
pub ret_activity: DiffActivity,
pub input_activity: Vec<DiffActivity>,
}
Expand Down Expand Up @@ -222,13 +233,15 @@ impl AutoDiffAttrs {
pub const fn error() -> Self {
AutoDiffAttrs {
mode: DiffMode::Error,
width: 0,
ret_activity: DiffActivity::None,
input_activity: Vec::new(),
}
}
pub fn source() -> Self {
AutoDiffAttrs {
mode: DiffMode::Source,
width: 0,
ret_activity: DiffActivity::None,
input_activity: Vec::new(),
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ builtin_macros_autodiff_ret_activity = invalid return activity {$act} in {$mode}
builtin_macros_autodiff_ty_activity = {$act} can not be used for this type
builtin_macros_autodiff_unknown_activity = did not recognize Activity: `{$act}`

builtin_macros_autodiff_width = autodiff width must fit u32, but is {$width}
builtin_macros_bad_derive_target = `derive` may only be applied to `struct`s, `enum`s and `union`s
.label = not applicable here
.label2 = not a `struct`, `enum` or `union`
Expand Down
339 changes: 213 additions & 126 deletions compiler/rustc_builtin_macros/src/autodiff.rs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions compiler/rustc_builtin_macros/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ mod autodiff {
pub(crate) mode: String,
}

#[derive(Diagnostic)]
#[diag(builtin_macros_autodiff_width)]
pub(crate) struct AutoDiffInvalidWidth {
#[primary_span]
pub(crate) span: Span,
pub(crate) width: u128,
}

#[derive(Diagnostic)]
#[diag(builtin_macros_autodiff)]
pub(crate) struct AutoDiffInvalidApplication {
Expand Down
49 changes: 28 additions & 21 deletions compiler/rustc_codegen_cranelift/build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,34 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
runner.run_out_command("gen_block_iterate", &[]);
}),
TestCase::build_bin_and_run("aot.raw-dylib", "example/raw-dylib.rs", &[]),
TestCase::custom("test.sysroot", &|runner| {
apply_patches(
&runner.dirs,
"sysroot_tests",
&runner.stdlib_source.join("library"),
&SYSROOT_TESTS_SRC.to_path(&runner.dirs),
);

SYSROOT_TESTS.clean(&runner.dirs);

let mut target_compiler = runner.target_compiler.clone();
// coretests and alloctests produce a bunch of warnings. When running
// in rust's CI warnings are denied, so we have to override that here.
target_compiler.rustflags.push("--cap-lints=allow".to_owned());
// The standard library may have been compiled with -Zrandomize-layout.
target_compiler.rustflags.extend(["--cfg".to_owned(), "randomized_layouts".to_owned()]);

if runner.is_native {
let mut test_cmd = SYSROOT_TESTS.test(&target_compiler, &runner.dirs);
test_cmd.args(["-p", "coretests", "-p", "alloctests", "--tests", "--", "-q"]);
spawn_and_wait(test_cmd);
} else {
eprintln!("Cross-Compiling: Not running tests");
let mut build_cmd = SYSROOT_TESTS.build(&target_compiler, &runner.dirs);
build_cmd.args(["-p", "coretests", "-p", "alloctests", "--tests"]);
spawn_and_wait(build_cmd);
}
}),
];

pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
Expand Down Expand Up @@ -146,27 +174,6 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
spawn_and_wait(build_cmd);
}
}),
TestCase::custom("test.sysroot", &|runner| {
apply_patches(
&runner.dirs,
"sysroot_tests",
&runner.stdlib_source.join("library"),
&SYSROOT_TESTS_SRC.to_path(&runner.dirs),
);

SYSROOT_TESTS.clean(&runner.dirs);

if runner.is_native {
let mut test_cmd = SYSROOT_TESTS.test(&runner.target_compiler, &runner.dirs);
test_cmd.args(["-p", "coretests", "-p", "alloctests", "--", "-q"]);
spawn_and_wait(test_cmd);
} else {
eprintln!("Cross-Compiling: Not running tests");
let mut build_cmd = SYSROOT_TESTS.build(&runner.target_compiler, &runner.dirs);
build_cmd.args(["-p", "coretests", "-p", "alloctests", "--tests"]);
spawn_and_wait(build_cmd);
}
}),
TestCase::custom("test.regex", &|runner| {
REGEX_REPO.patch(&runner.dirs);

Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_codegen_cranelift/build_system/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ impl CargoProject {
.arg(self.manifest_path(dirs))
.arg("--target-dir")
.arg(self.target_dir(dirs))
.arg("--locked");
.arg("--locked")
// bootstrap sets both RUSTC and RUSTC_WRAPPER to the same wrapper. RUSTC is already
// respected by the rustc-clif wrapper, but RUSTC_WRAPPER will misinterpret rustc-clif
// as filename, so we need to unset it.
.env_remove("RUSTC_WRAPPER");

if dirs.frozen {
cmd.arg("--frozen");
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ aot.issue-59326
aot.neon
aot.gen_block_iterate
aot.raw-dylib
test.sysroot

testsuite.extended_sysroot
test.rust-random/rand
test.sysroot
test.regex
test.portable-simd
12 changes: 10 additions & 2 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ fn enable_autodiff_settings(ad: &[config::AutoDiff], module: &mut ModuleCodegen<
}
// We handle this below
config::AutoDiff::PrintModAfter => {}
// We handle this below
config::AutoDiff::PrintModFinal => {}
// This is required and already checked
config::AutoDiff::Enable => {}
}
Expand Down Expand Up @@ -657,14 +659,20 @@ pub(crate) fn run_pass_manager(
}

if cfg!(llvm_enzyme) && enable_ad {
// This is the post-autodiff IR, mainly used for testing and educational purposes.
if config.autodiff.contains(&config::AutoDiff::PrintModAfter) {
unsafe { llvm::LLVMDumpModule(module.module_llvm.llmod()) };
}

let opt_stage = llvm::OptStage::FatLTO;
let stage = write::AutodiffStage::PostAD;
unsafe {
write::llvm_optimize(cgcx, dcx, module, None, config, opt_level, opt_stage, stage)?;
}

// This is the final IR, so people should be able to inspect the optimized autodiff output.
if config.autodiff.contains(&config::AutoDiff::PrintModAfter) {
// This is the final IR, so people should be able to inspect the optimized autodiff output,
// for manual inspection.
if config.autodiff.contains(&config::AutoDiff::PrintModFinal) {
unsafe { llvm::LLVMDumpModule(module.module_llvm.llmod()) };
}
}
Expand Down
Loading
Loading