From cad9b6b695e86c7c23482876d2f6fefd64451ab3 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Tue, 30 Mar 2021 07:03:41 +0100 Subject: Apply review feedback --- compiler/rustc_codegen_llvm/src/back/write.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_codegen_llvm/src') 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; } -- cgit 1.4.1-3-g733a5