Skip to content

Commit

Permalink
num_counters to u32, after implementing TypeFoldable
Browse files Browse the repository at this point in the history
  • Loading branch information
richkadel committed Jun 22, 2020
1 parent 8c7c84b commit 933fe80
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/librustc_middle/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ CloneTypeFoldableAndLiftImpls! {
bool,
usize,
::rustc_target::abi::VariantIdx,
u32,
u64,
String,
crate::middle::region::Scope,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/transform/instrument_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 933fe80

Please sign in to comment.