about summary refs log tree commit diff
path: root/compiler/rustc_session/src/config.rs
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2021-01-08 02:06:03 +0900
committerGitHub <noreply@github.com>2021-01-08 02:06:03 +0900
commit3acd75dd25bd59712d92cee23ff4932fe27cf7ce (patch)
tree1174c69e31d86e620bac6747a42ef1ba1c59e768 /compiler/rustc_session/src/config.rs
parentbb229b8f6c5dcf2acfdd1cc1e54d657cd5b3cacd (diff)
parente4aa99fe7afaabf846d9c67dc68364e7661a0bde (diff)
downloadrust-3acd75dd25bd59712d92cee23ff4932fe27cf7ce.tar.gz
rust-3acd75dd25bd59712d92cee23ff4932fe27cf7ce.zip
Rollup merge of #80521 - richkadel:llvm-coverage-counters-2.4.0, r=wesleywiser
MIR Inline is incompatible with coverage

Fixes: #80060

Fixed by disabling inlining if `-Zinstrument-coverage` is set.

The PR also adds additional use cases to the coverage test for doctests.

r? `@wesleywiser`
cc: `@tmandry`
Diffstat (limited to 'compiler/rustc_session/src/config.rs')
-rw-r--r--compiler/rustc_session/src/config.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index 62859f4bef4..938edb76ca6 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -1829,11 +1829,17 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         }
 
         if debugging_opts.mir_opt_level > 1 {
+            // Functions inlined during MIR transform can, at best, make it impossible to
+            // effectively cover inlined functions, and, at worst, break coverage map generation
+            // during LLVM codegen. For example, function counter IDs are only unique within a
+            // function. Inlining after these counters are injected can produce duplicate counters,
+            // resulting in an invalid coverage map (and ICE); so this option combination is not
+            // allowed.
             early_warn(
                 error_format,
                 &format!(
-                    "`-Z mir-opt-level={}` (any level > 1) enables function inlining, which \
-                    limits the effectiveness of `-Z instrument-coverage`.",
+                    "`-Z mir-opt-level={}` (or any level > 1) enables function inlining, which \
+                    is incompatible with `-Z instrument-coverage`. Inlining will be disabled.",
                     debugging_opts.mir_opt_level,
                 ),
             );