Simplify existing code for setting filecheck flags

This removes a version check for LLVM >=13, and specifies prefixes as a series
of independent `--check-prefix` flags instead of a single `--check-prefixes`.
This commit is contained in:
Zalathar 2024-02-03 11:06:59 +11:00
parent 36f298c93d
commit 1e432dd9f4

View File

@ -2906,23 +2906,29 @@ fn compile_test_and_save_assembly(&self) -> (ProcRes, PathBuf) {
fn verify_with_filecheck(&self, output: &Path) -> ProcRes { fn verify_with_filecheck(&self, output: &Path) -> ProcRes {
let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap()); let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap());
filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file); filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file);
// It would be more appropriate to make most of the arguments configurable through // It would be more appropriate to make most of the arguments configurable through
// a comment-attribute similar to `compile-flags`. For example, --check-prefixes is a very // a comment-attribute similar to `compile-flags`. For example, --check-prefixes is a very
// useful flag. // useful flag.
// //
// For now, though… // For now, though…
let prefix_for_target =
if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" }; // Because we use custom prefixes, we also have to register the default prefix.
let prefixes = if let Some(rev) = self.revision { filecheck.arg("--check-prefix=CHECK");
format!("CHECK,{},{}", prefix_for_target, rev)
} else { // Some tests use the current revision name as a check prefix.
format!("CHECK,{}", prefix_for_target) if let Some(rev) = self.revision {
}; filecheck.arg("--check-prefix").arg(rev);
if self.config.llvm_version.unwrap_or(0) >= 130000 {
filecheck.args(&["--allow-unused-prefixes", "--check-prefixes", &prefixes]);
} else {
filecheck.args(&["--check-prefixes", &prefixes]);
} }
// Some tests also expect either the MSVC or NONMSVC prefix to be defined.
let msvc_or_not = if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" };
filecheck.arg("--check-prefix").arg(msvc_or_not);
// The filecheck tool normally fails if a prefix is defined but not used.
// However, we define several prefixes globally for all tests.
filecheck.arg("--allow-unused-prefixes");
// Provide more context on failures. // Provide more context on failures.
filecheck.args(&["--dump-input-context", "100"]); filecheck.args(&["--dump-input-context", "100"]);
self.compose_and_run(filecheck, "", None, None) self.compose_and_run(filecheck, "", None, None)