Ensure profiling runtime for -Zinstrument-coverage
If config.toml `profiler = false`, the test/mir-opt/instrument_coverage test is ignored. Otherwise, this patch ensures the profiler_runtime is loaded when -Zinstrument-coverage is enabled. Confirmed that this works for MacOS.
This commit is contained in:
parent
98685a4bf2
commit
1db44afecd
5 changed files with 44 additions and 40 deletions
|
@ -209,7 +209,8 @@
|
||||||
# Build the sanitizer runtimes
|
# Build the sanitizer runtimes
|
||||||
#sanitizers = false
|
#sanitizers = false
|
||||||
|
|
||||||
# Build the profiler runtime
|
# Build the profiler runtime (required when compiling with options that depend
|
||||||
|
# on this runtime, such as `-C profile-generate` or `-Z instrument-coverage`).
|
||||||
#profiler = false
|
#profiler = false
|
||||||
|
|
||||||
# Indicates whether the native libraries linked into Cargo will be statically
|
# Indicates whether the native libraries linked into Cargo will be statically
|
||||||
|
|
|
@ -698,7 +698,9 @@ impl<'a> CrateLoader<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inject_profiler_runtime(&mut self) {
|
fn inject_profiler_runtime(&mut self) {
|
||||||
if (self.sess.opts.debugging_opts.profile || self.sess.opts.cg.profile_generate.enabled())
|
if (self.sess.opts.debugging_opts.instrument_coverage
|
||||||
|
|| self.sess.opts.debugging_opts.profile
|
||||||
|
|| self.sess.opts.cg.profile_generate.enabled())
|
||||||
&& !self.sess.opts.debugging_opts.no_profiler_runtime
|
&& !self.sess.opts.debugging_opts.no_profiler_runtime
|
||||||
{
|
{
|
||||||
info!("loading profiler");
|
info!("loading profiler");
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// at the top of each function. The placeholders are later converted into LLVM instrprof.increment
|
// at the top of each function. The placeholders are later converted into LLVM instrprof.increment
|
||||||
// intrinsics, during codegen.
|
// intrinsics, during codegen.
|
||||||
|
|
||||||
|
// needs-profiler-support
|
||||||
// compile-flags: -Zinstrument-coverage
|
// compile-flags: -Zinstrument-coverage
|
||||||
// EMIT_MIR rustc.main.InstrumentCoverage.diff
|
// EMIT_MIR rustc.main.InstrumentCoverage.diff
|
||||||
// EMIT_MIR rustc.bar.InstrumentCoverage.diff
|
// EMIT_MIR rustc.bar.InstrumentCoverage.diff
|
||||||
|
|
|
@ -2,40 +2,40 @@
|
||||||
+ // MIR for `bar` after InstrumentCoverage
|
+ // MIR for `bar` after InstrumentCoverage
|
||||||
|
|
||||||
fn bar() -> bool {
|
fn bar() -> bool {
|
||||||
let mut _0: bool; // return place in scope 0 at $DIR/instrument_coverage.rs:17:13: 17:17
|
let mut _0: bool; // return place in scope 0 at $DIR/instrument_coverage.rs:18:13: 18:17
|
||||||
+ let mut _1: (); // in scope 0 at $DIR/instrument_coverage.rs:17:1: 19:2
|
+ let mut _1: (); // in scope 0 at $DIR/instrument_coverage.rs:18:1: 20:2
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
+ StorageLive(_1); // scope 0 at $DIR/instrument_coverage.rs:17:1: 19:2
|
+ StorageLive(_1); // scope 0 at $DIR/instrument_coverage.rs:18:1: 20:2
|
||||||
+ _1 = const std::intrinsics::count_code_region(const 0u32) -> bb2; // scope 0 at $DIR/instrument_coverage.rs:17:1: 19:2
|
+ _1 = const std::intrinsics::count_code_region(const 0u32) -> bb2; // scope 0 at $DIR/instrument_coverage.rs:18:1: 20:2
|
||||||
+ // ty::Const
|
+ // ty::Const
|
||||||
+ // + ty: unsafe extern "rust-intrinsic" fn(u32) {std::intrinsics::count_code_region}
|
+ // + ty: unsafe extern "rust-intrinsic" fn(u32) {std::intrinsics::count_code_region}
|
||||||
+ // + val: Value(Scalar(<ZST>))
|
+ // + val: Value(Scalar(<ZST>))
|
||||||
+ // mir::Constant
|
+ // mir::Constant
|
||||||
+ // + span: $DIR/instrument_coverage.rs:17:1: 17:1
|
+ // + span: $DIR/instrument_coverage.rs:18:1: 18:1
|
||||||
+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) {std::intrinsics::count_code_region}, val: Value(Scalar(<ZST>)) }
|
+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) {std::intrinsics::count_code_region}, val: Value(Scalar(<ZST>)) }
|
||||||
+ // ty::Const
|
+ // ty::Const
|
||||||
+ // + ty: u32
|
+ // + ty: u32
|
||||||
+ // + val: Value(Scalar(0x00000000))
|
+ // + val: Value(Scalar(0x00000000))
|
||||||
+ // mir::Constant
|
+ // mir::Constant
|
||||||
+ // + span: $DIR/instrument_coverage.rs:17:1: 17:1
|
+ // + span: $DIR/instrument_coverage.rs:18:1: 18:1
|
||||||
+ // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
|
+ // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ bb1 (cleanup): {
|
+ bb1 (cleanup): {
|
||||||
+ resume; // scope 0 at $DIR/instrument_coverage.rs:17:1: 19:2
|
+ resume; // scope 0 at $DIR/instrument_coverage.rs:18:1: 20:2
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ bb2: {
|
+ bb2: {
|
||||||
+ StorageDead(_1); // scope 0 at $DIR/instrument_coverage.rs:18:5: 18:9
|
+ StorageDead(_1); // scope 0 at $DIR/instrument_coverage.rs:19:5: 19:9
|
||||||
_0 = const true; // scope 0 at $DIR/instrument_coverage.rs:18:5: 18:9
|
_0 = const true; // scope 0 at $DIR/instrument_coverage.rs:19:5: 19:9
|
||||||
// ty::Const
|
// ty::Const
|
||||||
// + ty: bool
|
// + ty: bool
|
||||||
// + val: Value(Scalar(0x01))
|
// + val: Value(Scalar(0x01))
|
||||||
// mir::Constant
|
// mir::Constant
|
||||||
// + span: $DIR/instrument_coverage.rs:18:5: 18:9
|
// + span: $DIR/instrument_coverage.rs:19:5: 19:9
|
||||||
// + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
|
// + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
|
||||||
return; // scope 0 at $DIR/instrument_coverage.rs:19:2: 19:2
|
return; // scope 0 at $DIR/instrument_coverage.rs:20:2: 20:2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,81 +2,81 @@
|
||||||
+ // MIR for `main` after InstrumentCoverage
|
+ // MIR for `main` after InstrumentCoverage
|
||||||
|
|
||||||
fn main() -> () {
|
fn main() -> () {
|
||||||
let mut _0: (); // return place in scope 0 at $DIR/instrument_coverage.rs:8:11: 8:11
|
let mut _0: (); // return place in scope 0 at $DIR/instrument_coverage.rs:9:11: 9:11
|
||||||
let mut _1: (); // in scope 0 at $DIR/instrument_coverage.rs:8:1: 14:2
|
let mut _1: (); // in scope 0 at $DIR/instrument_coverage.rs:9:1: 15:2
|
||||||
let mut _2: bool; // in scope 0 at $DIR/instrument_coverage.rs:10:12: 10:17
|
let mut _2: bool; // in scope 0 at $DIR/instrument_coverage.rs:11:12: 11:17
|
||||||
let mut _3: !; // in scope 0 at $DIR/instrument_coverage.rs:10:18: 12:10
|
let mut _3: !; // in scope 0 at $DIR/instrument_coverage.rs:11:18: 13:10
|
||||||
+ let mut _4: (); // in scope 0 at $DIR/instrument_coverage.rs:8:1: 14:2
|
+ let mut _4: (); // in scope 0 at $DIR/instrument_coverage.rs:9:1: 15:2
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
- falseUnwind -> [real: bb1, cleanup: bb2]; // scope 0 at $DIR/instrument_coverage.rs:9:5: 13:6
|
- falseUnwind -> [real: bb1, cleanup: bb2]; // scope 0 at $DIR/instrument_coverage.rs:10:5: 14:6
|
||||||
+ StorageLive(_4); // scope 0 at $DIR/instrument_coverage.rs:8:1: 14:2
|
+ StorageLive(_4); // scope 0 at $DIR/instrument_coverage.rs:9:1: 15:2
|
||||||
+ _4 = const std::intrinsics::count_code_region(const 0u32) -> bb7; // scope 0 at $DIR/instrument_coverage.rs:8:1: 14:2
|
+ _4 = const std::intrinsics::count_code_region(const 0u32) -> bb7; // scope 0 at $DIR/instrument_coverage.rs:9:1: 15:2
|
||||||
+ // ty::Const
|
+ // ty::Const
|
||||||
+ // + ty: unsafe extern "rust-intrinsic" fn(u32) {std::intrinsics::count_code_region}
|
+ // + ty: unsafe extern "rust-intrinsic" fn(u32) {std::intrinsics::count_code_region}
|
||||||
+ // + val: Value(Scalar(<ZST>))
|
+ // + val: Value(Scalar(<ZST>))
|
||||||
+ // mir::Constant
|
+ // mir::Constant
|
||||||
+ // + span: $DIR/instrument_coverage.rs:8:1: 8:1
|
+ // + span: $DIR/instrument_coverage.rs:9:1: 9:1
|
||||||
+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) {std::intrinsics::count_code_region}, val: Value(Scalar(<ZST>)) }
|
+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) {std::intrinsics::count_code_region}, val: Value(Scalar(<ZST>)) }
|
||||||
+ // ty::Const
|
+ // ty::Const
|
||||||
+ // + ty: u32
|
+ // + ty: u32
|
||||||
+ // + val: Value(Scalar(0x00000000))
|
+ // + val: Value(Scalar(0x00000000))
|
||||||
+ // mir::Constant
|
+ // mir::Constant
|
||||||
+ // + span: $DIR/instrument_coverage.rs:8:1: 8:1
|
+ // + span: $DIR/instrument_coverage.rs:9:1: 9:1
|
||||||
+ // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
|
+ // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
bb1: {
|
bb1: {
|
||||||
StorageLive(_2); // scope 0 at $DIR/instrument_coverage.rs:10:12: 10:17
|
StorageLive(_2); // scope 0 at $DIR/instrument_coverage.rs:11:12: 11:17
|
||||||
_2 = const bar() -> [return: bb3, unwind: bb2]; // scope 0 at $DIR/instrument_coverage.rs:10:12: 10:17
|
_2 = const bar() -> [return: bb3, unwind: bb2]; // scope 0 at $DIR/instrument_coverage.rs:11:12: 11:17
|
||||||
// ty::Const
|
// ty::Const
|
||||||
// + ty: fn() -> bool {bar}
|
// + ty: fn() -> bool {bar}
|
||||||
// + val: Value(Scalar(<ZST>))
|
// + val: Value(Scalar(<ZST>))
|
||||||
// mir::Constant
|
// mir::Constant
|
||||||
// + span: $DIR/instrument_coverage.rs:10:12: 10:15
|
// + span: $DIR/instrument_coverage.rs:11:12: 11:15
|
||||||
// + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar(<ZST>)) }
|
// + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar(<ZST>)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
bb2 (cleanup): {
|
bb2 (cleanup): {
|
||||||
resume; // scope 0 at $DIR/instrument_coverage.rs:8:1: 14:2
|
resume; // scope 0 at $DIR/instrument_coverage.rs:9:1: 15:2
|
||||||
}
|
}
|
||||||
|
|
||||||
bb3: {
|
bb3: {
|
||||||
FakeRead(ForMatchedPlace, _2); // scope 0 at $DIR/instrument_coverage.rs:10:12: 10:17
|
FakeRead(ForMatchedPlace, _2); // scope 0 at $DIR/instrument_coverage.rs:11:12: 11:17
|
||||||
switchInt(_2) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/instrument_coverage.rs:10:9: 12:10
|
switchInt(_2) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/instrument_coverage.rs:11:9: 13:10
|
||||||
}
|
}
|
||||||
|
|
||||||
bb4: {
|
bb4: {
|
||||||
falseEdge -> [real: bb6, imaginary: bb5]; // scope 0 at $DIR/instrument_coverage.rs:10:9: 12:10
|
falseEdge -> [real: bb6, imaginary: bb5]; // scope 0 at $DIR/instrument_coverage.rs:11:9: 13:10
|
||||||
}
|
}
|
||||||
|
|
||||||
bb5: {
|
bb5: {
|
||||||
_1 = const (); // scope 0 at $DIR/instrument_coverage.rs:10:9: 12:10
|
_1 = const (); // scope 0 at $DIR/instrument_coverage.rs:11:9: 13:10
|
||||||
// ty::Const
|
// ty::Const
|
||||||
// + ty: ()
|
// + ty: ()
|
||||||
// + val: Value(Scalar(<ZST>))
|
// + val: Value(Scalar(<ZST>))
|
||||||
// mir::Constant
|
// mir::Constant
|
||||||
// + span: $DIR/instrument_coverage.rs:10:9: 12:10
|
// + span: $DIR/instrument_coverage.rs:11:9: 13:10
|
||||||
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
|
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
|
||||||
StorageDead(_2); // scope 0 at $DIR/instrument_coverage.rs:13:5: 13:6
|
StorageDead(_2); // scope 0 at $DIR/instrument_coverage.rs:14:5: 14:6
|
||||||
goto -> bb0; // scope 0 at $DIR/instrument_coverage.rs:9:5: 13:6
|
goto -> bb0; // scope 0 at $DIR/instrument_coverage.rs:10:5: 14:6
|
||||||
}
|
}
|
||||||
|
|
||||||
bb6: {
|
bb6: {
|
||||||
_0 = const (); // scope 0 at $DIR/instrument_coverage.rs:11:13: 11:18
|
_0 = const (); // scope 0 at $DIR/instrument_coverage.rs:12:13: 12:18
|
||||||
// ty::Const
|
// ty::Const
|
||||||
// + ty: ()
|
// + ty: ()
|
||||||
// + val: Value(Scalar(<ZST>))
|
// + val: Value(Scalar(<ZST>))
|
||||||
// mir::Constant
|
// mir::Constant
|
||||||
// + span: $DIR/instrument_coverage.rs:11:13: 11:18
|
// + span: $DIR/instrument_coverage.rs:12:13: 12:18
|
||||||
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
|
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
|
||||||
StorageDead(_2); // scope 0 at $DIR/instrument_coverage.rs:13:5: 13:6
|
StorageDead(_2); // scope 0 at $DIR/instrument_coverage.rs:14:5: 14:6
|
||||||
return; // scope 0 at $DIR/instrument_coverage.rs:14:2: 14:2
|
return; // scope 0 at $DIR/instrument_coverage.rs:15:2: 15:2
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ bb7: {
|
+ bb7: {
|
||||||
+ StorageDead(_4); // scope 0 at $DIR/instrument_coverage.rs:9:5: 13:6
|
+ StorageDead(_4); // scope 0 at $DIR/instrument_coverage.rs:10:5: 14:6
|
||||||
+ falseUnwind -> [real: bb1, cleanup: bb2]; // scope 0 at $DIR/instrument_coverage.rs:9:5: 13:6
|
+ falseUnwind -> [real: bb1, cleanup: bb2]; // scope 0 at $DIR/instrument_coverage.rs:10:5: 14:6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue