diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a8a71c196fc..fff4f2df595 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1848,34 +1848,6 @@ fn compile_test_and_save_ir(&self) -> (ProcRes, PathBuf) { (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 input_file = &self.testpaths.file; - - // Use the `//@ assembly-output:` directive to determine how to emit assembly. - let emit = match self.props.assembly_output.as_deref() { - Some("emit-asm") => Emit::Asm, - Some("bpf-linker") => Emit::LinkArgsAsm, - Some("ptx-linker") => Emit::None, // No extra flags needed. - Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")), - None => self.fatal("missing 'assembly-output' directive"), - }; - - let rustc = self.make_compile_args( - input_file, - TargetLocation::ThisFile(output_path.clone()), - emit, - AllowUnused::No, - LinkToAux::Yes, - Vec::new(), - ); - - let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths); - (proc_res, output_path) - } - fn verify_with_filecheck(&self, output: &Path) -> ProcRes { let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap()); filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file); diff --git a/src/tools/compiletest/src/runtest/assembly.rs b/src/tools/compiletest/src/runtest/assembly.rs index 430a5534da1..89d7de58c20 100644 --- a/src/tools/compiletest/src/runtest/assembly.rs +++ b/src/tools/compiletest/src/runtest/assembly.rs @@ -1,4 +1,6 @@ -use super::TestCx; +use std::path::PathBuf; + +use super::{AllowUnused, Emit, LinkToAux, ProcRes, TargetLocation, TestCx}; impl TestCx<'_> { pub(super) fn run_assembly_test(&self) { @@ -16,4 +18,32 @@ pub(super) fn run_assembly_test(&self) { self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res); } } + + 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 input_file = &self.testpaths.file; + + // Use the `//@ assembly-output:` directive to determine how to emit assembly. + let emit = match self.props.assembly_output.as_deref() { + Some("emit-asm") => Emit::Asm, + Some("bpf-linker") => Emit::LinkArgsAsm, + Some("ptx-linker") => Emit::None, // No extra flags needed. + Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")), + None => self.fatal("missing 'assembly-output' directive"), + }; + + let rustc = self.make_compile_args( + input_file, + TargetLocation::ThisFile(output_path.clone()), + emit, + AllowUnused::No, + LinkToAux::Yes, + Vec::new(), + ); + + let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths); + (proc_res, output_path) + } }