diff options
| author | Amanieu d'Antras <amanieu@gmail.com> | 2021-03-27 05:04:32 +0000 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2021-03-30 02:10:28 +0100 |
| commit | 26d260bfa4a31df541ff1d4c24965730660b4114 (patch) | |
| tree | d1515135bac6e48886b4e4fe7a6873fcf2ca9b3c /compiler/rustc_codegen_llvm/src/back/write.rs | |
| parent | 3debe9acb8df363e0b5363f23f8218c2d7919904 (diff) | |
| download | rust-26d260bfa4a31df541ff1d4c24965730660b4114.tar.gz rust-26d260bfa4a31df541ff1d4c24965730660b4114.zip | |
Run LLVM coverage instrumentation passes before optimization passes
This matches the behavior of Clang and allows us to remove several hacks which were needed to ensure functions weren't optimized away before reaching the instrumentation pass.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back/write.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/write.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 388dd7ce81b..c45d637177e 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -548,6 +548,11 @@ pub(crate) unsafe fn optimize( llvm::LLVMRustAddPass(fpm, find_pass("lint").unwrap()); continue; } + if pass_name == "insert-gcov-profiling" || pass_name == "instrprof" { + // Instrumentation should be inserted before optimization. + llvm::LLVMRustAddPass(mpm, find_pass(pass_name).unwrap()); + continue; + } if let Some(pass) = find_pass(pass_name) { extra_passes.push(pass); |
