summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
diff options
context:
space:
mode:
authorRich Kadel <richkadel@google.com>2020-10-22 14:30:03 -0700
committerRich Kadel <richkadel@google.com>2020-11-05 18:24:15 -0800
commit198ba3bd1cfedc7115f91d549a352da2b25050b7 (patch)
tree8a6b3755806c0e8a315dab3e3ea4caf87cd50b05 /compiler/rustc_codegen_ssa
parent3291d28e9ac1173f033d240bc5f3f145c9c8dd59 (diff)
downloadrust-198ba3bd1cfedc7115f91d549a352da2b25050b7.tar.gz
rust-198ba3bd1cfedc7115f91d549a352da2b25050b7.zip
Injecting expressions in place of counters where helpful
Implementing the Graph traits for the BasicCoverageBlock
graph.

optimized replacement of counters with expressions plus new BCB graphviz

* Avoid adding coverage to unreachable blocks.
* Special case for Goto at the end of the body. Make it non-reportable.

Improved debugging and formatting options (from env)

Don't automatically add counters to BCBs without CoverageSpans. They may
still get counters but only if there are dependencies from
other BCBs that have spans, I think.

Make CodeRegions optional for Counters too. It is
possible to inject counters (`llvm.instrprof.increment` intrinsic calls
without corresponding code regions in the coverage map. An expression
can still uses these counter values.

Refactored instrument_coverage.rs -> instrument_coverage/mod.rs, and
then broke up the mod into multiple files.

Compiling with coverage, with the expression optimization, works on
the json5format crate and its dependencies.

Refactored debug features from mod.rs to debug.rs
Diffstat (limited to 'compiler/rustc_codegen_ssa')
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs4
-rw-r--r--compiler/rustc_codegen_ssa/src/traits/coverageinfo.rs10
2 files changed, 9 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs b/compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs
index e52f952e932..339e0d95fdf 100644
--- a/compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs
@@ -24,10 +24,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                     let fn_name = bx.create_pgo_func_name_var(self.instance);
                     let hash = bx.const_u64(function_source_hash);
                     let num_counters = bx.const_u32(coverageinfo.num_counters);
-                    let id = bx.const_u32(u32::from(id));
+                    let index = bx.const_u32(u32::from(id));
                     debug!(
                         "codegen intrinsic instrprof.increment(fn_name={:?}, hash={:?}, num_counters={:?}, index={:?})",
-                        fn_name, hash, num_counters, id,
+                        fn_name, hash, num_counters, index,
                     );
                     bx.instrprof_increment(fn_name, hash, num_counters, index);
                 }
diff --git a/compiler/rustc_codegen_ssa/src/traits/coverageinfo.rs b/compiler/rustc_codegen_ssa/src/traits/coverageinfo.rs
index 5aa0950b399..7da38880d60 100644
--- a/compiler/rustc_codegen_ssa/src/traits/coverageinfo.rs
+++ b/compiler/rustc_codegen_ssa/src/traits/coverageinfo.rs
@@ -11,7 +11,11 @@ pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
 
     /// Returns true if the function source hash was added to the coverage map; false if
     /// `-Z instrument-coverage` is not enabled (a coverage map is not being generated).
-    fn set_function_source_hash(&mut self, instance: Instance<'tcx>, function_source_hash: u64) -> bool;
+    fn set_function_source_hash(
+        &mut self,
+        instance: Instance<'tcx>,
+        function_source_hash: u64,
+    ) -> bool;
 
     /// Returns true if the counter was added to the coverage map; false if `-Z instrument-coverage`
     /// is not enabled (a coverage map is not being generated).
@@ -19,7 +23,7 @@ pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
         &mut self,
         instance: Instance<'tcx>,
         function_source_hash: u64,
-        id: CounterValueReference,
+        index: CounterValueReference,
         region: CodeRegion,
     ) -> bool;
 
@@ -33,7 +37,7 @@ pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
         op: Op,
         rhs: ExpressionOperandId,
         region: Option<CodeRegion>,
-    );
+    ) -> bool;
 
     /// Returns true if the region was added to the coverage map; false if `-Z instrument-coverage`
     /// is not enabled (a coverage map is not being generated).