Skip to content

compiletest: add max-llvm-major-version directive #132310

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 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directive-list.rs
Original file line number Diff line number Diff line change
@@ -120,6 +120,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"incremental",
"known-bug",
"llvm-cov-flags",
"max-llvm-major-version",
"min-cdb-version",
"min-gdb-version",
"min-lldb-version",
14 changes: 14 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
@@ -1546,6 +1546,20 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision {
),
};
}
} else if let Some(version_string) =
config.parse_name_value_directive(line, "max-llvm-major-version")
{
let max_version = extract_llvm_version(&version_string);
// Ignore if actual major version is larger than the maximum required major version.
if actual_version.major > max_version.major {
return IgnoreDecision::Ignore {
reason: format!(
"ignored when the LLVM version ({actual_version}) is newer than major\
version {}",
max_version.major
),
};
}
} else if let Some(version_string) =
config.parse_name_value_directive(line, "min-system-llvm-version")
{
9 changes: 9 additions & 0 deletions src/tools/compiletest/src/header/tests.rs
Original file line number Diff line number Diff line change
@@ -299,6 +299,15 @@ fn llvm_version() {

let config: Config = cfg().llvm_version("10.6.2").build();
assert!(!check_ignore(&config, "//@ exact-llvm-major-version: 10"));

let config: Config = cfg().llvm_version("19.0.0").build();
assert!(!check_ignore(&config, "//@ max-llvm-major-version: 19"));

let config: Config = cfg().llvm_version("19.1.2").build();
assert!(!check_ignore(&config, "//@ max-llvm-major-version: 19"));

let config: Config = cfg().llvm_version("20.0.0").build();
assert!(check_ignore(&config, "//@ max-llvm-major-version: 19"));
}

#[test]
2 changes: 1 addition & 1 deletion tests/assembly/riscv-soft-abi-with-float-features.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
//@ compile-flags: --target riscv64imac-unknown-none-elf -Ctarget-feature=+f,+d
//@ needs-llvm-components: riscv
//@ revisions: LLVM-PRE-20 LLVM-POST-20
//@ [LLVM-PRE-20] ignore-llvm-version: 20 - 99
//@ [LLVM-PRE-20] max-llvm-major-version: 19
//@ [LLVM-POST-20] min-llvm-version: 20

#![feature(no_core, lang_items, f16)]
2 changes: 1 addition & 1 deletion tests/assembly/x86_64-cmp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ revisions: DEBUG LLVM-PRE-20-OPTIM LLVM-20-OPTIM
//@ [DEBUG] compile-flags: -C opt-level=0
//@ [LLVM-PRE-20-OPTIM] compile-flags: -C opt-level=3
//@ [LLVM-PRE-20-OPTIM] ignore-llvm-version: 20 - 99
//@ [LLVM-PRE-20-OPTIM] max-llvm-major-version: 19
//@ [LLVM-20-OPTIM] compile-flags: -C opt-level=3
//@ [LLVM-20-OPTIM] min-llvm-version: 20
//@ assembly-output: emit-asm
2 changes: 1 addition & 1 deletion tests/codegen/branch-protection-old-llvm.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
//@ [LEAF] compile-flags: -Z branch-protection=pac-ret,leaf
//@ [BKEY] compile-flags: -Z branch-protection=pac-ret,b-key
//@ compile-flags: --target aarch64-unknown-linux-gnu
//@ ignore-llvm-version: 19 - 99
//@ max-llvm-major-version: 18

#![crate_type = "lib"]
#![feature(no_core, lang_items)]
2 changes: 1 addition & 1 deletion tests/codegen/call-metadata.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
// scalar value.

//@ compile-flags: -O -C no-prepopulate-passes
//@ ignore-llvm-version: 19 - 99
//@ max-llvm-major-version: 18

#![crate_type = "lib"]

2 changes: 1 addition & 1 deletion tests/codegen/integer-cmp.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

//@ revisions: llvm-pre-20 llvm-20
//@ [llvm-20] min-llvm-version: 20
//@ [llvm-pre-20] ignore-llvm-version: 20 - 99
//@ [llvm-pre-20] max-llvm-major-version: 19
//@ compile-flags: -C opt-level=3

#![crate_type = "lib"]