7
7
// If the test passes, the expected function call count was added to the use-phase LLVM-IR.
8
8
// See https://github.com/rust-lang/rust/pull/66631
9
9
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 ;
11
20
12
21
fn 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};
13
24
let common_flags = if env:: consts:: OS == "linux" && env:: var ( "TARGET" ) . unwrap_or_default ( ) . contains ( "x86" ) {
14
25
"-Clink-args=-fuse-ld=gold" // FIXME, Why was there a comma at the start?
15
26
} else {
@@ -30,7 +41,7 @@ fn main() {
30
41
. profile_generate ( & path_prof_data_dir)
31
42
. opt ( )
32
43
. run ( ) ;
33
- run ( "main aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc " ) ; // FIXME, with an arg? How to pass it?
44
+ run ( "main" ) ;
34
45
llvm_profdata ( ) . merge ( ) . output ( & path_merged_profdata) . input ( path_prof_data_dir) . command_output ( ) ;
35
46
rustc ( ) . arg ( common_flags)
36
47
. input ( "interesting.rs" )
@@ -39,6 +50,25 @@ fn main() {
39
50
. codegen_units ( 1 )
40
51
. emit ( "llvm-ir" )
41
52
. 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 ( ) ;
43
73
}
44
74
0 commit comments