1 use super::BackendTypes;
2 use rustc_hir::def_id::DefId;
3 use rustc_middle::mir::coverage::*;
4 use rustc_middle::ty::Instance;
6 pub trait CoverageInfoMethods<'tcx>: BackendTypes {
7 fn coverageinfo_finalize(&self);
9 /// Codegen a small function that will never be called, with one counter
10 /// that will never be incremented, that gives LLVM coverage tools a
11 /// function definition it needs in order to resolve coverage map references
12 /// to unused functions. This is necessary so unused functions will appear
13 /// as uncovered (coverage execution count `0`) in LLVM coverage reports.
14 fn define_unused_fn(&self, def_id: DefId);
16 /// For LLVM codegen, returns a function-specific `Value` for a global
17 /// string, to hold the function name passed to LLVM intrinsic
18 /// `instrprof.increment()`. The `Value` is only created once per instance.
19 /// Multiple invocations with the same instance return the same `Value`.
20 fn get_pgo_func_name_var(&self, instance: Instance<'tcx>) -> Self::Value;
23 pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
24 /// Returns true if the function source hash was added to the coverage map (even if it had
25 /// already been added, for this instance). Returns false *only* if `-C instrument-coverage` is
26 /// not enabled (a coverage map is not being generated).
27 fn set_function_source_hash(
29 instance: Instance<'tcx>,
30 function_source_hash: u64,
33 /// Returns true if the counter was added to the coverage map; false if `-C instrument-coverage`
34 /// is not enabled (a coverage map is not being generated).
35 fn add_coverage_counter(
37 instance: Instance<'tcx>,
38 index: CounterValueReference,
42 /// Returns true if the expression was added to the coverage map; false if
43 /// `-C instrument-coverage` is not enabled (a coverage map is not being generated).
44 fn add_coverage_counter_expression(
46 instance: Instance<'tcx>,
47 id: InjectedExpressionId,
48 lhs: ExpressionOperandId,
50 rhs: ExpressionOperandId,
51 region: Option<CodeRegion>,
54 /// Returns true if the region was added to the coverage map; false if `-C instrument-coverage`
55 /// is not enabled (a coverage map is not being generated).
56 fn add_coverage_unreachable(&mut self, instance: Instance<'tcx>, region: CodeRegion) -> bool;