3 use rustc_middle
::mir
::coverage
::*;
4 use rustc_middle
::mir
::Coverage
;
8 impl<'a
, 'tcx
, Bx
: BuilderMethods
<'a
, 'tcx
>> FunctionCx
<'a
, 'tcx
, Bx
> {
9 pub fn codegen_coverage(&self, bx
: &mut Bx
, coverage
: Coverage
) {
10 let Coverage { kind, code_region }
= coverage
;
12 CoverageKind
::Counter { function_source_hash, id }
=> {
13 bx
.add_counter_region(self.instance
, function_source_hash
, id
, code_region
);
15 let coverageinfo
= bx
.tcx().coverageinfo(self.instance
.def_id());
17 let fn_name
= bx
.create_pgo_func_name_var(self.instance
);
18 let hash
= bx
.const_u64(function_source_hash
);
19 let num_counters
= bx
.const_u32(coverageinfo
.num_counters
);
20 let id
= bx
.const_u32(u32::from(id
));
22 "codegen intrinsic instrprof.increment(fn_name={:?}, hash={:?}, num_counters={:?}, index={:?})",
23 fn_name
, hash
, num_counters
, id
,
25 bx
.instrprof_increment(fn_name
, hash
, num_counters
, id
);
27 CoverageKind
::Expression { id, lhs, op, rhs }
=> {
28 bx
.add_counter_expression_region(self.instance
, id
, lhs
, op
, rhs
, code_region
);
30 CoverageKind
::Unreachable
=> {
31 bx
.add_unreachable_region(self.instance
, code_region
);