about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/back/write.rs
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2021-03-30 07:03:41 +0100
committerAmanieu d'Antras <amanieu@gmail.com>2021-03-30 07:03:41 +0100
commitcad9b6b695e86c7c23482876d2f6fefd64451ab3 (patch)
tree3e2463b8332138a538ee0f6e7b30d386f9ddb220 /compiler/rustc_codegen_llvm/src/back/write.rs
parent26d260bfa4a31df541ff1d4c24965730660b4114 (diff)
downloadrust-cad9b6b695e86c7c23482876d2f6fefd64451ab3.tar.gz
rust-cad9b6b695e86c7c23482876d2f6fefd64451ab3.zip
Apply review feedback
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back/write.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/back/write.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs
index c45d637177e..085935b94df 100644
--- a/compiler/rustc_codegen_llvm/src/back/write.rs
+++ b/compiler/rustc_codegen_llvm/src/back/write.rs
@@ -549,7 +549,11 @@ pub(crate) unsafe fn optimize(
                     continue;
                 }
                 if pass_name == "insert-gcov-profiling" || pass_name == "instrprof" {
-                    // Instrumentation should be inserted before optimization.
+                    // Instrumentation must be inserted before optimization,
+                    // otherwise LLVM may optimize some functions away which
+                    // breaks llvm-cov.
+                    //
+                    // This mirrors what Clang does in lib/CodeGen/BackendUtil.cpp.
                     llvm::LLVMRustAddPass(mpm, find_pass(pass_name).unwrap());
                     continue;
                 }