summaryrefslogtreecommitdiffstats
path: root/src/tools/compiletest/src/runtest.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/compiletest/src/runtest.rs')
-rw-r--r--src/tools/compiletest/src/runtest.rs88
1 files changed, 64 insertions, 24 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 63e8ba7c7..5d53a4d28 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -20,12 +20,11 @@ use regex::{Captures, Regex};
use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};
use std::borrow::Cow;
-use std::collections::hash_map::DefaultHasher;
use std::collections::{HashMap, HashSet};
use std::env;
use std::ffi::{OsStr, OsString};
use std::fs::{self, create_dir_all, File, OpenOptions};
-use std::hash::{Hash, Hasher};
+use std::hash::{DefaultHasher, Hash, Hasher};
use std::io::prelude::*;
use std::io::{self, BufReader};
use std::iter;
@@ -475,14 +474,12 @@ impl<'test> TestCx<'test> {
self.fatal("missing --coverage-dump");
};
- let proc_res = self.compile_test_and_save_ir();
+ let (proc_res, llvm_ir_path) = self.compile_test_and_save_ir();
if !proc_res.status.success() {
self.fatal_proc_rec("compilation failed!", &proc_res);
}
drop(proc_res);
- let llvm_ir_path = self.output_base_name().with_extension("ll");
-
let mut dump_command = Command::new(coverage_dump_path);
dump_command.arg(llvm_ir_path);
let proc_res = self.run_command_to_procres(&mut dump_command);
@@ -2546,10 +2543,10 @@ impl<'test> TestCx<'test> {
rustc.args(&["-Zpolonius"]);
}
Some(CompareMode::NextSolver) => {
- rustc.args(&["-Ztrait-solver=next"]);
+ rustc.args(&["-Znext-solver"]);
}
Some(CompareMode::NextSolverCoherence) => {
- rustc.args(&["-Ztrait-solver=next-coherence"]);
+ rustc.args(&["-Znext-solver=coherence"]);
}
Some(CompareMode::SplitDwarf) if self.config.target.contains("windows") => {
rustc.args(&["-Csplit-debuginfo=unpacked", "-Zunstable-options"]);
@@ -2786,10 +2783,54 @@ impl<'test> TestCx<'test> {
proc_res.fatal(None, || on_failure(*self));
}
+ fn get_output_file(&self, extension: &str) -> TargetLocation {
+ let thin_lto = self.props.compile_flags.iter().any(|s| s.ends_with("lto=thin"));
+ if thin_lto {
+ TargetLocation::ThisDirectory(self.output_base_dir())
+ } else {
+ // This works with both `--emit asm` (as default output name for the assembly)
+ // and `ptx-linker` because the latter can write output at requested location.
+ let output_path = self.output_base_name().with_extension(extension);
+ let output_file = TargetLocation::ThisFile(output_path.clone());
+ output_file
+ }
+ }
+
+ fn get_filecheck_file(&self, extension: &str) -> PathBuf {
+ let thin_lto = self.props.compile_flags.iter().any(|s| s.ends_with("lto=thin"));
+ if thin_lto {
+ let name = self.testpaths.file.file_stem().unwrap().to_str().unwrap();
+ let canonical_name = name.replace('-', "_");
+ let mut output_file = None;
+ for entry in self.output_base_dir().read_dir().unwrap() {
+ if let Ok(entry) = entry {
+ let entry_path = entry.path();
+ let entry_file = entry_path.file_name().unwrap().to_str().unwrap();
+ if entry_file.starts_with(&format!("{}.{}", name, canonical_name))
+ && entry_file.ends_with(extension)
+ {
+ assert!(
+ output_file.is_none(),
+ "thinlto doesn't support multiple cgu tests"
+ );
+ output_file = Some(entry_file.to_string());
+ }
+ }
+ }
+ if let Some(output_file) = output_file {
+ self.output_base_dir().join(output_file)
+ } else {
+ self.output_base_name().with_extension(extension)
+ }
+ } else {
+ self.output_base_name().with_extension(extension)
+ }
+ }
+
// codegen tests (using FileCheck)
- fn compile_test_and_save_ir(&self) -> ProcRes {
- let output_file = TargetLocation::ThisDirectory(self.output_base_dir());
+ fn compile_test_and_save_ir(&self) -> (ProcRes, PathBuf) {
+ let output_file = self.get_output_file("ll");
let input_file = &self.testpaths.file;
let rustc = self.make_compile_args(
input_file,
@@ -2800,15 +2841,13 @@ impl<'test> TestCx<'test> {
Vec::new(),
);
- self.compose_and_run_compiler(rustc, None)
+ let proc_res = self.compose_and_run_compiler(rustc, None);
+ let output_path = self.get_filecheck_file("ll");
+ (proc_res, output_path)
}
fn compile_test_and_save_assembly(&self) -> (ProcRes, PathBuf) {
- // This works with both `--emit asm` (as default output name for the assembly)
- // and `ptx-linker` because the latter can write output at requested location.
- let output_path = self.output_base_name().with_extension("s");
-
- let output_file = TargetLocation::ThisFile(output_path.clone());
+ let output_file = self.get_output_file("s");
let input_file = &self.testpaths.file;
let mut emit = Emit::None;
@@ -2838,7 +2877,9 @@ impl<'test> TestCx<'test> {
Vec::new(),
);
- (self.compose_and_run_compiler(rustc, None), output_path)
+ let proc_res = self.compose_and_run_compiler(rustc, None);
+ let output_path = self.get_filecheck_file("s");
+ (proc_res, output_path)
}
fn verify_with_filecheck(&self, output: &Path) -> ProcRes {
@@ -2871,7 +2912,7 @@ impl<'test> TestCx<'test> {
self.fatal("missing --llvm-filecheck");
}
- let proc_res = self.compile_test_and_save_ir();
+ let (proc_res, output_path) = self.compile_test_and_save_ir();
if !proc_res.status.success() {
self.fatal_proc_rec("compilation failed!", &proc_res);
}
@@ -2879,8 +2920,6 @@ impl<'test> TestCx<'test> {
if let Some(PassMode::Build) = self.pass_mode() {
return;
}
-
- let output_path = self.output_base_name().with_extension("ll");
let proc_res = self.verify_with_filecheck(&output_path);
if !proc_res.status.success() {
self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res);
@@ -3702,9 +3741,7 @@ impl<'test> TestCx<'test> {
let stderr_bits = format!("{}bit.stderr", self.config.get_pointer_width());
let (stderr_kind, stdout_kind) = match output_kind {
TestOutput::Compile => (
- {
- if self.props.stderr_per_bitwidth { &stderr_bits } else { UI_STDERR }
- },
+ { if self.props.stderr_per_bitwidth { &stderr_bits } else { UI_STDERR } },
UI_STDOUT,
),
TestOutput::Run => (UI_RUN_STDERR, UI_RUN_STDOUT),
@@ -4251,15 +4288,18 @@ impl<'test> TestCx<'test> {
let mut seen_allocs = indexmap::IndexSet::new();
// The alloc-id appears in pretty-printed allocations.
- let re = Regex::new(r"╾─*a(lloc)?([0-9]+)(\+0x[0-9]+)?─*╼").unwrap();
+ let re =
+ Regex::new(r"╾─*a(lloc)?([0-9]+)(\+0x[0-9]+)?(<imm>)?( \([0-9]+ ptr bytes\))?─*╼")
+ .unwrap();
normalized = re
.replace_all(&normalized, |caps: &Captures<'_>| {
// Renumber the captured index.
let index = caps.get(2).unwrap().as_str().to_string();
let (index, _) = seen_allocs.insert_full(index);
let offset = caps.get(3).map_or("", |c| c.as_str());
+ let imm = caps.get(4).map_or("", |c| c.as_str());
// Do not bother keeping it pretty, just make it deterministic.
- format!("╾ALLOC{index}{offset}╼")
+ format!("╾ALLOC{index}{offset}{imm}╼")
})
.into_owned();