]> git.lizzy.rs Git - rust.git/commitdiff
num_counters to u32, after implementing TypeFoldable
authorRich Kadel <richkadel@google.com>
Mon, 22 Jun 2020 06:48:39 +0000 (23:48 -0700)
committerRich Kadel <richkadel@google.com>
Mon, 22 Jun 2020 06:48:39 +0000 (23:48 -0700)
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_middle/mir/mod.rs
src/librustc_middle/ty/structural_impls.rs
src/librustc_mir/transform/instrument_coverage.rs

index 8c0ccde6b16bb2bad66d520d2b6b79b94210dcff..c6e7820a60ed481560859cba6f5d57feacec6584 100644 (file)
@@ -146,7 +146,7 @@ fn codegen_intrinsic_call<'b, Bx: BuilderMethods<'b, 'tcx>>(
                 let (mangled_fn_name, _len_val) = self.const_str(mangled_fn.name);
                 let hash = self.const_u64(coverage_data.hash);
                 let index = args[0].immediate();
-                let num_counters = self.const_u32(coverage_data.num_counters as u32);
+                let num_counters = self.const_u32(coverage_data.num_counters);
                 debug!(
                     "count_code_region to LLVM intrinsic instrprof.increment(fn_name={}, hash={:?}, num_counters={:?}, index={:?})",
                     mangled_fn.name, hash, index, num_counters
index a89a5ef3f8218772f268c069065939df693a0d1c..e88329db992f59c1e3aab9b863e9b7c91cf834b3 100644 (file)
@@ -98,7 +98,7 @@ pub struct CoverageData {
     pub hash: u64,
 
     /// The total number of coverage region counters added to this MIR Body.
-    pub num_counters: usize,
+    pub num_counters: u32,
 }
 
 /// The lowered representation of a single function.
index f04d31601ea5b5a8e0310d77ccdb1590a282dfed..463e2c57d46c9cb08b9842c346b801eccb348672 100644 (file)
@@ -262,6 +262,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     bool,
     usize,
     ::rustc_target::abi::VariantIdx,
+    u32,
     u64,
     String,
     crate::middle::region::Scope,
index 793ccbb081bedcbebb62bc5cfec9e51d2fc761ab..a24d0acf4212cff3062b72f03f2b8697fe0e4f9a 100644 (file)
@@ -21,7 +21,7 @@
 
 struct Instrumentor<'tcx> {
     tcx: TyCtxt<'tcx>,
-    num_counters: usize,
+    num_counters: u32,
 }
 
 impl<'tcx> MirPass<'tcx> for InstrumentCoverage {
@@ -55,12 +55,12 @@ fn new(tcx: TyCtxt<'tcx>) -> Self {
     }
 
     fn next_counter(&mut self) -> u32 {
-        let next = self.num_counters as u32;
+        let next = self.num_counters;
         self.num_counters += 1;
         next
     }
 
-    fn inject_counters(&mut self, mir_body: &mut mir::Body<'tcx>) -> usize {
+    fn inject_counters(&mut self, mir_body: &mut mir::Body<'tcx>) -> u32 {
         // FIXME(richkadel): As a first step, counters are only injected at the top of each
         // function. The complete solution will inject counters at each conditional code branch.
         let top_of_function = START_BLOCK;