9
9
//@ ignore-cross-compile
10
10
11
11
use 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 ,
14
14
} ;
15
15
16
16
fn main ( ) {
@@ -28,11 +28,11 @@ fn main() {
28
28
// Run it in order to generate some profiling data
29
29
run_with_args ( "main" , & [ "some-argument" ] ) ;
30
30
// 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 ( ) ;
36
36
// Compile the test program again, making use of the profiling data
37
37
rustc ( )
38
38
. opt_level ( "2" )
@@ -42,13 +42,14 @@ fn main() {
42
42
. emit ( "llvm-ir" )
43
43
. input ( "main.rs" )
44
44
. 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
48
47
// line with the function name before the line with the function attributes.
49
48
// FileCheck only supports checking that something matches on the next line,
50
49
// 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 ( ) ;
54
55
}
0 commit comments