77// If the test passes, the expected function call count was added to the use-phase LLVM-IR.
88// See https://github.com/rust-lang/rust/pull/66631
99
10- use run_make_support:: { run, rustc, tmp_dir} ;
10+
11+ // FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
12+ // properly. Since we only have GCC on the CI ignore the test for now.
13+
14+ //@ needs-profiler-support
15+ //@ ignore-windows-gnu
16+ //@ ignore-cross-compile
17+
18+ use std:: io:: { self , Write } ;
19+ use std:: process:: Command ;
1120
1221fn main ( ) {
22+ // For some very small programs GNU ld seems to not properly handle
23+ // instrumentation sections correctly. Neither Gold nor LLD have that problem.use run_make_support::{run, rustc, tmp_dir};
1324 let common_flags = if env:: consts:: OS == "linux" && env:: var ( "TARGET" ) . unwrap_or_default ( ) . contains ( "x86" ) {
1425 "-Clink-args=-fuse-ld=gold" // FIXME, Why was there a comma at the start?
1526 } else {
@@ -30,7 +41,7 @@ fn main() {
3041 . profile_generate ( & path_prof_data_dir)
3142 . opt ( )
3243 . run ( ) ;
33- run ( "main aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc " ) ; // FIXME, with an arg? How to pass it?
44+ run ( "main" ) ;
3445 llvm_profdata ( ) . merge ( ) . output ( & path_merged_profdata) . input ( path_prof_data_dir) . command_output ( ) ;
3546 rustc ( ) . arg ( common_flags)
3647 . input ( "interesting.rs" )
@@ -39,6 +50,25 @@ fn main() {
3950 . codegen_units ( 1 )
4051 . emit ( "llvm-ir" )
4152 . run ( ) ;
42- // FIXME, implement cat
53+
54+ // FIXME This part below is a rough attempt
55+
56+ let interesting_ll = tmp_dir ( ) . join ( "interesting.ll" ) ;
57+ let file_interesting_ll = File :: open ( interesting_ll) ?;
58+ let reader = BufReader :: new ( file_interesting_ll) ;
59+
60+ let mut child = Command :: new ( "llvm-filecheck" )
61+ . stdin ( std:: process:: Stdio :: piped ( ) )
62+ . stdout ( std:: process:: Stdio :: piped ( ) )
63+ . stderr ( std:: process:: Stdio :: piped ( ) )
64+ . arg ( "filecheck-patterns.txt" )
65+ . spawn ( )
66+ . unwrap ( ) ;
67+
68+ let mut child_stdin = child. stdin . take ( ) . unwrap ( ) ;
69+ child_stdin. write_all ( reader. bytes ( ) . collect :: < Vec < _ > > ( ) . as_slice ( ) ) . unwrap ( ) ;
70+ child_stdin. flush ( ) . unwrap ( ) ;
71+
72+ let output = child. wait_with_output ( ) . unwrap ( ) ;
4373}
4474
0 commit comments