From 933fe805777e46163c52371d81390ba721a37252 Mon Sep 17 00:00:00 2001 From: Rich Kadel Date: Sun, 21 Jun 2020 23:48:39 -0700 Subject: [PATCH] num_counters to u32, after implementing TypeFoldable --- src/librustc_codegen_llvm/intrinsic.rs | 2 +- src/librustc_middle/mir/mod.rs | 2 +- src/librustc_middle/ty/structural_impls.rs | 1 + src/librustc_mir/transform/instrument_coverage.rs | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 8c0ccde6b16bb..c6e7820a60ed4 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -146,7 +146,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, '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 diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index a89a5ef3f8218..e88329db992f5 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -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. diff --git a/src/librustc_middle/ty/structural_impls.rs b/src/librustc_middle/ty/structural_impls.rs index f04d31601ea5b..463e2c57d46c9 100644 --- a/src/librustc_middle/ty/structural_impls.rs +++ b/src/librustc_middle/ty/structural_impls.rs @@ -262,6 +262,7 @@ CloneTypeFoldableAndLiftImpls! { bool, usize, ::rustc_target::abi::VariantIdx, + u32, u64, String, crate::middle::region::Scope, diff --git a/src/librustc_mir/transform/instrument_coverage.rs b/src/librustc_mir/transform/instrument_coverage.rs index 793ccbb081bed..a24d0acf4212c 100644 --- a/src/librustc_mir/transform/instrument_coverage.rs +++ b/src/librustc_mir/transform/instrument_coverage.rs @@ -21,7 +21,7 @@ pub struct InstrumentCoverage; struct Instrumentor<'tcx> { tcx: TyCtxt<'tcx>, - num_counters: usize, + num_counters: u32, } impl<'tcx> MirPass<'tcx> for InstrumentCoverage { @@ -55,12 +55,12 @@ impl<'tcx> Instrumentor<'tcx> { } 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;