From 1973f84ebbb3b2bb4b9a1488b6553ac46b2db8d4 Mon Sep 17 00:00:00 2001 From: Rich Kadel Date: Sun, 25 Oct 2020 11:13:16 -0700 Subject: Addressed all feedback to date --- compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'compiler/rustc_codegen_ssa/src/mir') diff --git a/compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs b/compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs index 339e0d95fdf..a115d358666 100644 --- a/compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs +++ b/compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs @@ -10,15 +10,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let Coverage { kind, code_region } = coverage; match kind { CoverageKind::Counter { function_source_hash, id } => { - let covmap_updated = if let Some(code_region) = code_region { - // Note: Some counters do not have code regions, but may still be referenced from - // expressions. - bx.add_coverage_counter(self.instance, function_source_hash, id, code_region) - } else { - bx.set_function_source_hash(self.instance, function_source_hash) - }; + if bx.set_function_source_hash(self.instance, function_source_hash) { + // If `set_function_source_hash()` returned true, the coverage map is enabled, + // so continue adding the counter. + if let Some(code_region) = code_region { + // Note: Some counters do not have code regions, but may still be referenced + // from expressions. In that case, don't add the counter to the coverage map, + // but do inject the counter intrinsic. + bx.add_coverage_counter(self.instance, id, code_region); + } - if covmap_updated { let coverageinfo = bx.tcx().coverageinfo(self.instance.def_id()); let fn_name = bx.create_pgo_func_name_var(self.instance); -- cgit 1.4.1-3-g733a5