Skip to content

Rename tests/{assembly,codegen} into tests/{assembly,codegen}-llvm and ignore these testsuites if configured backend doesn't match #144249

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

Merged
merged 3 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
&"always",
&"--stage",
&"0",
&"tests/assembly/asm",
&"tests/assembly-llvm/asm",
&"--compiletest-rustc-args",
&rustc_args,
],
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let ltext = bx.zext(is_lt, bx.type_i8());
bx.unchecked_ssub(gtext, ltext)
} else {
// These operations are those expected by `tests/codegen/integer-cmp.rs`,
// These operations are those expected by `tests/codegen-llvm/integer-cmp.rs`,
// from <https://github.com/rust-lang/rust/pull/63767>.
let is_lt = bx.icmp(pred(mir::BinOp::Lt), lhs, rhs);
let is_ne = bx.icmp(pred(mir::BinOp::Ne), lhs, rhs);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/unreachable_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn remove_successors_from_switch<'tcx>(
let is_unreachable = |bb| unreachable_blocks.contains(&bb);

// If there are multiple targets, we want to keep information about reachability for codegen.
// For example (see tests/codegen/match-optimizes-away.rs)
// For example (see tests/codegen-llvm/match-optimizes-away.rs)
//
// pub enum Two { A, B }
// pub fn identity(x: Two) -> Two {
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/vec_deque/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
// this branch is never taken.
// We use `#[cold]` instead of `#[inline(never)]`, because inlining this
// function into the general case (`.drain(n..m)`) is fine.
// See `tests/codegen/vecdeque-drain.rs` for a test.
// See `tests/codegen-llvm/vecdeque-drain.rs` for a test.
#[cold]
fn join_head_and_tail_wrapping<T, A: Allocator>(
source_deque: &mut VecDeque<T, A>,
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/raw_vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ impl<A: Allocator> RawVecInner<A> {
}

// not marked inline(never) since we want optimizers to be able to observe the specifics of this
// function, see tests/codegen/vec-reserve-extend.rs.
// function, see tests/codegen-llvm/vec-reserve-extend.rs.
#[cold]
fn finish_grow<A>(
new_layout: Layout,
Expand Down
4 changes: 2 additions & 2 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ignore = [
"/vendor/",

# Some tests are not formatted, for various reasons.
"/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
"/tests/codegen-llvm/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
"/tests/crashes/", # Many of these tests contain syntax errors.
"/tests/debuginfo/", # These tests are somewhat sensitive to source code layout.
"/tests/incremental/", # These tests are somewhat sensitive to source code layout.
Expand Down Expand Up @@ -58,5 +58,5 @@ ignore = [

# Rustfmt doesn't support use closures yet
"tests/mir-opt/ergonomic-clones/closure.rs",
"tests/codegen/ergonomic-clones/closure.rs",
"tests/codegen-llvm/ergonomic-clones/closure.rs",
]
18 changes: 14 additions & 4 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,12 @@ test!(Ui { path: "tests/ui", mode: "ui", suite: "ui", default: true });

test!(Crashes { path: "tests/crashes", mode: "crashes", suite: "crashes", default: true });

test!(Codegen { path: "tests/codegen", mode: "codegen", suite: "codegen", default: true });
test!(CodegenLlvm {
path: "tests/codegen-llvm",
mode: "codegen",
suite: "codegen-llvm",
default: true
});

test!(CodegenUnits {
path: "tests/codegen-units",
Expand Down Expand Up @@ -1407,7 +1412,12 @@ test!(Pretty {

test!(RunMake { path: "tests/run-make", mode: "run-make", suite: "run-make", default: true });

test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly", default: true });
test!(AssemblyLlvm {
path: "tests/assembly-llvm",
mode: "assembly",
suite: "assembly-llvm",
default: true
});

/// Runs the coverage test suite at `tests/coverage` in some or all of the
/// coverage test modes.
Expand Down Expand Up @@ -1615,7 +1625,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
let suite_path = self.path;

// Skip codegen tests if they aren't enabled in configuration.
if !builder.config.codegen_tests && suite == "codegen" {
if !builder.config.codegen_tests && mode == "codegen" {
return;
}

Expand Down Expand Up @@ -1812,7 +1822,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] };
flags.push(format!(
"-Cdebuginfo={}",
if suite == "codegen" {
if mode == "codegen" {
// codegen tests typically check LLVM IR and are sensitive to additional debuginfo.
// So do not apply `rust.debuginfo-level-tests` for codegen tests.
if builder.config.rust_debuginfo_level_tests
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ const PATH_REMAP: &[(&str, &[&str])] = &[
"tests",
&[
// tidy-alphabetical-start
"tests/assembly",
"tests/codegen",
"tests/assembly-llvm",
"tests/codegen-llvm",
"tests/codegen-units",
"tests/coverage",
"tests/coverage-run-rustdoc",
Expand Down Expand Up @@ -1049,9 +1049,9 @@ impl<'a> Builder<'a> {
test::Crashes,
test::Coverage,
test::MirOpt,
test::Codegen,
test::CodegenLlvm,
test::CodegenUnits,
test::Assembly,
test::AssemblyLlvm,
test::Incremental,
test::Debuginfo,
test::UiFullDeps,
Expand Down
6 changes: 3 additions & 3 deletions src/ci/docker/host-x86_64/test-various/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_T
tests/ui \
tests/mir-opt \
tests/codegen-units \
tests/codegen \
tests/assembly \
tests/codegen-llvm \
tests/assembly-llvm \
library/core

ENV NVPTX_TARGETS=nvptx64-nvidia-cuda
ENV NVPTX_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $NVPTX_TARGETS \
tests/run-make \
tests/assembly
tests/assembly-llvm

ENV MUSL_TARGETS=x86_64-unknown-linux-musl \
CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc \
Expand Down
6 changes: 3 additions & 3 deletions src/doc/rustc-dev-guide/src/asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ can't know ahead of time whether a function will require a frame/base pointer.

Various tests for inline assembly are available:

- `tests/assembly/asm`
- `tests/assembly-llvm/asm`
- `tests/ui/asm`
- `tests/codegen/asm-*`
- `tests/codegen-llvm/asm-*`

Every architecture supported by inline assembly must have exhaustive tests in
`tests/assembly/asm` which test all combinations of register classes and types.
`tests/assembly-llvm/asm` which test all combinations of register classes and types.
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/src/autodiff/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rustup toolchain install nightly # enables -Z unstable-options
You can then run our test cases:

```bash
./x test --stage 1 tests/codegen/autodiff
./x test --stage 1 tests/codegen-llvm/autodiff
./x test --stage 1 tests/pretty/autodiff
./x test --stage 1 tests/ui/autodiff
./x test --stage 1 tests/ui/feature-gates/feature-gate-autodiff.rs
Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustc-dev-guide/src/llvm-coverage-instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ human-readable coverage report.
> directive, so they will be skipped if the profiler runtime has not been
> [enabled in `bootstrap.toml`](#recommended-configtoml-settings).
Finally, the [`tests/codegen/instrument-coverage/testprog.rs`] test compiles a simple Rust program
Finally, the [`tests/codegen-llvm/instrument-coverage/testprog.rs`] test compiles a simple Rust program
with `-C instrument-coverage` and compares the compiled program's LLVM IR to
expected LLVM IR instructions and structured data for a coverage-enabled
program, including various checks for Coverage Map-related metadata and the LLVM
Expand All @@ -136,4 +136,4 @@ and `mir-opt` tests can be refreshed by running:
[`tests/coverage`]: https://github.com/rust-lang/rust/tree/master/tests/coverage
[`src/tools/coverage-dump`]: https://github.com/rust-lang/rust/tree/master/src/tools/coverage-dump
[`tests/coverage-run-rustdoc`]: https://github.com/rust-lang/rust/tree/master/tests/coverage-run-rustdoc
[`tests/codegen/instrument-coverage/testprog.rs`]: https://github.com/rust-lang/rust/blob/master/tests/mir-opt/coverage/instrument_coverage.rs
[`tests/codegen-llvm/instrument-coverage/testprog.rs`]: https://github.com/rust-lang/rust/blob/master/tests/mir-opt/coverage/instrument_coverage.rs
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/src/offload/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This gives you a working LLVM build.
## Testing
run
```
./x test --stage 1 tests/codegen/gpu_offload
./x test --stage 1 tests/codegen-llvm/gpu_offload
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/src/profile-guided-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ There is also a [codegen test][codegen-test] that checks that some expected
instrumentation artifacts show up in LLVM IR.

[rmake-tests]: https://github.com/rust-lang/rust/tree/master/tests/run-make
[codegen-test]: https://github.com/rust-lang/rust/blob/master/tests/codegen/pgo-instrumentation.rs
[codegen-test]: https://github.com/rust-lang/rust/blob/master/tests/codegen-llvm/pgo-instrumentation.rs

## Additional information

Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustc-dev-guide/src/sanitizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ implementation:
## Testing sanitizers

Sanitizers are validated by code generation tests in
[`tests/codegen/sanitize*.rs`][test-cg] and end-to-end functional tests in
[`tests/codegen-llvm/sanitize*.rs`][test-cg] and end-to-end functional tests in
[`tests/ui/sanitizer/`][test-ui] directory.

Testing sanitizer functionality requires the sanitizer runtimes (built when
Expand All @@ -85,7 +85,7 @@ sanitizer. When sanitizer is unsupported on given target, sanitizers tests will
be ignored. This behaviour is controlled by compiletest `needs-sanitizer-*`
directives.

[test-cg]: https://github.com/rust-lang/rust/tree/master/tests/codegen
[test-cg]: https://github.com/rust-lang/rust/tree/master/tests/codegen-llvm
[test-ui]: https://github.com/rust-lang/rust/tree/master/tests/ui/sanitizer

## Enabling sanitizer on a new target
Expand Down
10 changes: 5 additions & 5 deletions src/doc/rustc-dev-guide/src/tests/compiletest.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The following test suites are available, with links for more information:
| [`pretty`](#pretty-printer-tests) | Check pretty printing |
| [`incremental`](#incremental-tests) | Check incremental compilation behavior |
| [`debuginfo`](#debuginfo-tests) | Check debuginfo generation running debuggers |
| [`codegen`](#codegen-tests) | Check code generation |
| [`codegen-*`](#codegen-tests) | Check code generation |
| [`codegen-units`](#codegen-units-tests) | Check codegen unit partitioning |
| [`assembly`](#assembly-tests) | Check assembly output |
| [`mir-opt`](#mir-opt-tests) | Check MIR generation and optimizations |
Expand Down Expand Up @@ -290,7 +290,7 @@ For example, `./x test tests/debuginfo -- --debugger gdb` will only test GDB com

### Codegen tests

The tests in [`tests/codegen`] test LLVM code generation. They compile the test
The tests in [`tests/codegen-llvm`] test LLVM code generation. They compile the test
with the `--emit=llvm-ir` flag to emit LLVM IR. They then run the LLVM
[FileCheck] tool. The test is annotated with various `// CHECK` comments to
check the generated code. See the [FileCheck] documentation for a tutorial and
Expand All @@ -301,13 +301,13 @@ See also the [assembly tests](#assembly-tests) for a similar set of tests.
If you need to work with `#![no_std]` cross-compiling tests, consult the
[`minicore` test auxiliary](./minicore.md) chapter.

[`tests/codegen`]: https://github.com/rust-lang/rust/tree/master/tests/codegen
[`tests/codegen-llvm`]: https://github.com/rust-lang/rust/tree/master/tests/codegen-llvm
[FileCheck]: https://llvm.org/docs/CommandGuide/FileCheck.html


### Assembly tests

The tests in [`tests/assembly`] test LLVM assembly output. They compile the test
The tests in [`tests/assembly-llvm`] test LLVM assembly output. They compile the test
with the `--emit=asm` flag to emit a `.s` file with the assembly output. They
then run the LLVM [FileCheck] tool.

Expand All @@ -324,7 +324,7 @@ See also the [codegen tests](#codegen-tests) for a similar set of tests.
If you need to work with `#![no_std]` cross-compiling tests, consult the
[`minicore` test auxiliary](./minicore.md) chapter.

[`tests/assembly`]: https://github.com/rust-lang/rust/tree/master/tests/assembly
[`tests/assembly-llvm`]: https://github.com/rust-lang/rust/tree/master/tests/assembly-llvm


### Codegen-units tests
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ impl TestMode {
string_enum! {
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum TestSuite {
Assembly => "assembly",
Codegen => "codegen",
AssemblyLlvm => "assembly-llvm",
CodegenLlvm => "codegen-llvm",
CodegenUnits => "codegen-units",
Coverage => "coverage",
CoverageRunRustdoc => "coverage-run-rustdoc",
Expand Down
19 changes: 18 additions & 1 deletion src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use std::time::SystemTime;
use std::{env, fs, vec};

use build_helper::git::{get_git_modified_files, get_git_untracked_files};
use camino::{Utf8Path, Utf8PathBuf};
use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
use getopts::Options;
use rayon::iter::{ParallelBridge, ParallelIterator};
use tracing::debug;
Expand Down Expand Up @@ -799,6 +799,23 @@ fn collect_tests_from_dir(
return Ok(TestCollector::new());
}

let mut components = dir.components().rev();
if let Some(Utf8Component::Normal(last)) = components.next()
&& let Some(("assembly" | "codegen", backend)) = last.split_once('-')
&& let Some(Utf8Component::Normal(parent)) = components.next()
&& parent == "tests"
&& let Ok(backend) = CodegenBackend::try_from(backend)
&& backend != cx.config.codegen_backend
{
// We ignore asm tests which don't match the current codegen backend.
warning!(
"Ignoring tests in `{dir}` because they don't match the configured codegen \
backend (`{}`)",
cx.config.codegen_backend.as_str(),
);
return Ok(TestCollector::new());
}

// For run-make tests, a "test file" is actually a directory that contains an `rmake.rs`.
if cx.config.mode == TestMode::RunMake {
let mut collector = TestCollector::new();
Expand Down
4 changes: 2 additions & 2 deletions src/tools/opt-dist/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ llvm-config = "{llvm_config}"
env.host_tuple(),
"--stage",
"0",
"tests/assembly",
"tests/codegen",
"tests/assembly-llvm",
"tests/codegen-llvm",
"tests/codegen-units",
"tests/incremental",
"tests/mir-opt",
Expand Down
6 changes: 3 additions & 3 deletions src/tools/tidy/src/target_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::path::Path;
use crate::walk::{filter_not_rust, walk};

const TARGET_DEFINITIONS_PATH: &str = "compiler/rustc_target/src/spec/targets/";
const ASSEMBLY_TEST_PATH: &str = "tests/assembly/targets/";
const ASSEMBLY_LLVM_TEST_PATH: &str = "tests/assembly-llvm/targets/";
const REVISION_LINE_START: &str = "//@ revisions: ";
const EXCEPTIONS: &[&str] = &[
// FIXME: disabled since it fails on CI saying the csky component is missing
Expand Down Expand Up @@ -43,7 +43,7 @@ pub fn check(root_path: &Path, bad: &mut bool) {
let _ = targets_to_find.insert(target_name);
}

walk(&root_path.join(ASSEMBLY_TEST_PATH), |_, _| false, &mut |_, contents| {
walk(&root_path.join(ASSEMBLY_LLVM_TEST_PATH), |_, _| false, &mut |_, contents| {
for line in contents.lines() {
let Some(_) = line.find(REVISION_LINE_START) else {
continue;
Expand All @@ -55,7 +55,7 @@ pub fn check(root_path: &Path, bad: &mut bool) {

for target in targets_to_find {
if !EXCEPTIONS.contains(&target.as_str()) {
tidy_error!(bad, "{ASSEMBLY_TEST_PATH}: missing assembly test for {target}")
tidy_error!(bad, "{ASSEMBLY_LLVM_TEST_PATH}: missing assembly test for {target}")
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// > LLVM ERROR: Cannot select: 0x7f00f400c010: i32,i32,ch = X86ISD::RDSEED 0x7f00f400bfa8:2
// > In function: foo
//
// See also tests/codegen/target-feature-overrides.rs
// See also tests/codegen-llvm/target-feature-overrides.rs
#![feature(no_core, lang_items, link_llvm_intrinsics, abi_unadjusted)]
#![crate_type = "lib"]
#![no_core]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading