]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/instrument_coverage.rs
Update upstream source from tag 'upstream/1.49.0_beta.4+dfsg1'
[rustc.git] / src / test / mir-opt / instrument_coverage.rs
CommitLineData
29967ef6
XL
1// Test that `-Z instrument-coverage` injects Coverage statements. The Coverage Counter statements
2// are later converted into LLVM instrprof.increment intrinsics, during codegen.
f035d41b
XL
3
4// needs-profiler-support
3dfed10e 5// ignore-windows
29967ef6
XL
6// compile-flags: -Z instrument-coverage --remap-path-prefix={{src-base}}=/the/src
7
3dfed10e
XL
8// EMIT_MIR instrument_coverage.main.InstrumentCoverage.diff
9// EMIT_MIR instrument_coverage.bar.InstrumentCoverage.diff
f035d41b
XL
10fn main() {
11 loop {
12 if bar() {
13 break;
14 }
15 }
16}
17
18#[inline(never)]
19fn bar() -> bool {
20 true
21}
3dfed10e
XL
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.