Skip to content

Commit 933fe80

Browse files
committed
num_counters to u32, after implementing TypeFoldable
1 parent 8c7c84b commit 933fe80

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/librustc_codegen_llvm/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
146146
let (mangled_fn_name, _len_val) = self.const_str(mangled_fn.name);
147147
let hash = self.const_u64(coverage_data.hash);
148148
let index = args[0].immediate();
149-
let num_counters = self.const_u32(coverage_data.num_counters as u32);
149+
let num_counters = self.const_u32(coverage_data.num_counters);
150150
debug!(
151151
"count_code_region to LLVM intrinsic instrprof.increment(fn_name={}, hash={:?}, num_counters={:?}, index={:?})",
152152
mangled_fn.name, hash, index, num_counters

src/librustc_middle/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub struct CoverageData {
9898
pub hash: u64,
9999

100100
/// The total number of coverage region counters added to this MIR Body.
101-
pub num_counters: usize,
101+
pub num_counters: u32,
102102
}
103103

104104
/// The lowered representation of a single function.

src/librustc_middle/ty/structural_impls.rs

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ CloneTypeFoldableAndLiftImpls! {
262262
bool,
263263
usize,
264264
::rustc_target::abi::VariantIdx,
265+
u32,
265266
u64,
266267
String,
267268
crate::middle::region::Scope,

src/librustc_mir/transform/instrument_coverage.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct InstrumentCoverage;
2121

2222
struct Instrumentor<'tcx> {
2323
tcx: TyCtxt<'tcx>,
24-
num_counters: usize,
24+
num_counters: u32,
2525
}
2626

2727
impl<'tcx> MirPass<'tcx> for InstrumentCoverage {
@@ -55,12 +55,12 @@ impl<'tcx> Instrumentor<'tcx> {
5555
}
5656

5757
fn next_counter(&mut self) -> u32 {
58-
let next = self.num_counters as u32;
58+
let next = self.num_counters;
5959
self.num_counters += 1;
6060
next
6161
}
6262

63-
fn inject_counters(&mut self, mir_body: &mut mir::Body<'tcx>) -> usize {
63+
fn inject_counters(&mut self, mir_body: &mut mir::Body<'tcx>) -> u32 {
6464
// FIXME(richkadel): As a first step, counters are only injected at the top of each
6565
// function. The complete solution will inject counters at each conditional code branch.
6666
let top_of_function = START_BLOCK;

0 commit comments

Comments
 (0)