99//@ ignore-cross-compile
1010
1111use run_make_support::{
12- cwd, find_files_by_prefix_and_extension, fs_wrapper, llvm_filecheck, llvm_profdata,
13- run_with_args, rustc ,
12+ cwd, fs_wrapper, has_extension, has_prefix, llvm_filecheck, llvm_profdata, run_with_args ,
13+ rustc, shallow_find_files ,
1414};
1515
1616fn main() {
@@ -28,11 +28,11 @@ fn main() {
2828 // Run it in order to generate some profiling data
2929 run_with_args("main", &["some-argument"]);
3030 // Postprocess the profiling data so it can be used by the compiler
31- llvm_profdata()
32- .merge( )
33- .output("merged.profdata")
34- .input(find_files_by_prefix_and_extension(cwd(), "default", "profraw"). get(0).unwrap())
35- .run();
31+ let profraw_files = shallow_find_files(cwd(), |path| {
32+ has_prefix(path, "default") && has_extension(path, "profraw" )
33+ });
34+ let profraw_file = profraw_files. get(0).unwrap();
35+ llvm_profdata().merge().output("merged.profdata").input(profraw_file) .run();
3636 // Compile the test program again, making use of the profiling data
3737 rustc()
3838 .opt_level("2")
@@ -42,13 +42,14 @@ fn main() {
4242 .emit("llvm-ir")
4343 .input("main.rs")
4444 .run();
45- // Check that the generate IR contains some things that we expect
46- //
47- // We feed the file into LLVM FileCheck tool *in reverse* so that we see the
45+ // Check that the generate IR contains some things that we expect.
46+ // We feed the file into LLVM FileCheck tool *with its lines reversed* so that we see the
4847 // line with the function name before the line with the function attributes.
4948 // FileCheck only supports checking that something matches on the next line,
5049 // but not if something matches on the previous line.
51- let mut bytes = fs_wrapper::read("interesting.ll");
52- bytes.reverse();
53- llvm_filecheck().patterns("filecheck-patterns.txt").stdin(bytes).run();
50+ let ir = fs_wrapper::read_to_string("main.ll");
51+ let lines: Vec<_> = ir.lines().rev().collect();
52+ let mut reversed_ir = lines.join("\n");
53+ reversed_ir.push('\n');
54+ llvm_filecheck().patterns("filecheck-patterns.txt").stdin(reversed_ir.as_bytes()).run();
5455}
0 commit comments