]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/instrument_coverage.rs
Auto merge of #96978 - lqd:win_pgo2, r=Mark-Simulacrum
[rust.git] / src / test / mir-opt / instrument_coverage.rs
1 // Test that `-C instrument-coverage` injects Coverage statements. The Coverage Counter statements
2 // are later converted into LLVM instrprof.increment intrinsics, during codegen.
3
4 // needs-profiler-support
5 // ignore-windows
6 // compile-flags: -C instrument-coverage --remap-path-prefix={{src-base}}=/the/src
7
8 // EMIT_MIR instrument_coverage.main.InstrumentCoverage.diff
9 // EMIT_MIR instrument_coverage.bar.InstrumentCoverage.diff
10 fn main() {
11     loop {
12         if bar() {
13             break;
14         }
15     }
16 }
17
18 #[inline(never)]
19 fn bar() -> bool {
20     true
21 }
22
23 // Note that the MIR with injected coverage intrinsics includes references to source locations,
24 // including the source file absolute path. Typically, MIR pretty print output with file
25 // references are safe because the file prefixes are substituted with `$DIR`, but in this case
26 // the file references are encoded as function arguments, with an `Operand` type representation
27 // (`Slice` `Allocation` interned byte array) that cannot be normalized by simple substitution.
28 //
29 // The first workaround is to use the `SourceMap`-supported `--remap-path-prefix` option; however,
30 // the implementation of the `--remap-path-prefix` option currently joins the new prefix and the
31 // remaining source path with an OS-specific path separator (`\` on Windows). This difference still
32 // shows up in the byte array representation of the path, causing Windows tests to fail to match
33 // blessed results baselined with a `/` path separator.
34 //
35 // Since this `mir-opt` test does not have any significant platform dependencies, other than the
36 // path separator differences, the final workaround is to disable testing on Windows.