@@ -11,22 +11,18 @@ use rustc_ast as ast;
11
11
use rustc_codegen_ssa:: base:: { compare_simd_types, to_immediate, wants_msvc_seh} ;
12
12
use rustc_codegen_ssa:: common:: span_invalid_monomorphization_error;
13
13
use rustc_codegen_ssa:: common:: { IntPredicate , TypeKind } ;
14
- use rustc_codegen_ssa:: coverageinfo;
15
14
use rustc_codegen_ssa:: glue;
16
15
use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
17
16
use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
18
17
use rustc_codegen_ssa:: traits:: * ;
19
18
use rustc_codegen_ssa:: MemFlags ;
20
19
use rustc_hir as hir;
21
- use rustc_middle:: mir:: coverage;
22
- use rustc_middle:: mir:: Operand ;
23
20
use rustc_middle:: ty:: layout:: { FnAbiExt , HasTyCtxt } ;
24
21
use rustc_middle:: ty:: { self , Ty } ;
25
22
use rustc_middle:: { bug, span_bug} ;
26
23
use rustc_span:: { sym, symbol:: kw, Span , Symbol } ;
27
24
use rustc_target:: abi:: { self , HasDataLayout , LayoutOf , Primitive } ;
28
25
use rustc_target:: spec:: PanicStrategy ;
29
- use tracing:: debug;
30
26
31
27
use std:: cmp:: Ordering ;
32
28
use std:: iter;
@@ -83,85 +79,13 @@ fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: Symbol) -> Option<&'ll Va
83
79
}
84
80
85
81
impl IntrinsicCallMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
86
- fn is_codegen_intrinsic (
87
- & mut self ,
88
- intrinsic : Symbol ,
89
- args : & Vec < Operand < ' tcx > > ,
90
- caller_instance : ty:: Instance < ' tcx > ,
91
- ) -> bool {
92
- let mut is_codegen_intrinsic = true ;
93
- // Set `is_codegen_intrinsic` to `false` to bypass `codegen_intrinsic_call()`.
94
-
95
- // FIXME(richkadel): Make sure to add coverage analysis tests on a crate with
96
- // external crate dependencies, where:
97
- // 1. Both binary and dependent crates are compiled with `-Zinstrument-coverage`
98
- // 2. Only binary is compiled with `-Zinstrument-coverage`
99
- // 3. Only dependent crates are compiled with `-Zinstrument-coverage`
100
- match intrinsic {
101
- sym:: count_code_region => {
102
- use coverage:: count_code_region_args:: * ;
103
- self . add_counter_region (
104
- caller_instance,
105
- op_to_u64 ( & args[ FUNCTION_SOURCE_HASH ] ) ,
106
- op_to_u32 ( & args[ COUNTER_ID ] ) ,
107
- coverageinfo:: Region :: new (
108
- op_to_str_slice ( & args[ FILE_NAME ] ) ,
109
- op_to_u32 ( & args[ START_LINE ] ) ,
110
- op_to_u32 ( & args[ START_COL ] ) ,
111
- op_to_u32 ( & args[ END_LINE ] ) ,
112
- op_to_u32 ( & args[ END_COL ] ) ,
113
- ) ,
114
- ) ;
115
- }
116
- sym:: coverage_counter_add | sym:: coverage_counter_subtract => {
117
- is_codegen_intrinsic = false ;
118
- use coverage:: coverage_counter_expression_args:: * ;
119
- self . add_counter_expression_region (
120
- caller_instance,
121
- op_to_u32 ( & args[ EXPRESSION_ID ] ) ,
122
- op_to_u32 ( & args[ LEFT_ID ] ) ,
123
- if intrinsic == sym:: coverage_counter_add {
124
- coverageinfo:: ExprKind :: Add
125
- } else {
126
- coverageinfo:: ExprKind :: Subtract
127
- } ,
128
- op_to_u32 ( & args[ RIGHT_ID ] ) ,
129
- coverageinfo:: Region :: new (
130
- op_to_str_slice ( & args[ FILE_NAME ] ) ,
131
- op_to_u32 ( & args[ START_LINE ] ) ,
132
- op_to_u32 ( & args[ START_COL ] ) ,
133
- op_to_u32 ( & args[ END_LINE ] ) ,
134
- op_to_u32 ( & args[ END_COL ] ) ,
135
- ) ,
136
- ) ;
137
- }
138
- sym:: coverage_unreachable => {
139
- is_codegen_intrinsic = false ;
140
- use coverage:: coverage_unreachable_args:: * ;
141
- self . add_unreachable_region (
142
- caller_instance,
143
- coverageinfo:: Region :: new (
144
- op_to_str_slice ( & args[ FILE_NAME ] ) ,
145
- op_to_u32 ( & args[ START_LINE ] ) ,
146
- op_to_u32 ( & args[ START_COL ] ) ,
147
- op_to_u32 ( & args[ END_LINE ] ) ,
148
- op_to_u32 ( & args[ END_COL ] ) ,
149
- ) ,
150
- ) ;
151
- }
152
- _ => { }
153
- }
154
- is_codegen_intrinsic
155
- }
156
-
157
82
fn codegen_intrinsic_call (
158
83
& mut self ,
159
84
instance : ty:: Instance < ' tcx > ,
160
85
fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
161
86
args : & [ OperandRef < ' tcx , & ' ll Value > ] ,
162
87
llresult : & ' ll Value ,
163
88
span : Span ,
164
- caller_instance : ty:: Instance < ' tcx > ,
165
89
) {
166
90
let tcx = self . tcx ;
167
91
let callee_ty = instance. ty ( tcx, ty:: ParamEnv :: reveal_all ( ) ) ;
@@ -213,21 +137,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
213
137
let llfn = self . get_intrinsic ( & ( "llvm.debugtrap" ) ) ;
214
138
self . call ( llfn, & [ ] , None )
215
139
}
216
- sym:: count_code_region => {
217
- use coverage:: count_code_region_args:: * ;
218
- let coverageinfo = tcx. coverageinfo ( caller_instance. def_id ( ) ) ;
219
-
220
- let fn_name = self . create_pgo_func_name_var ( caller_instance) ;
221
- let hash = args[ FUNCTION_SOURCE_HASH ] . immediate ( ) ;
222
- let num_counters = self . const_u32 ( coverageinfo. num_counters ) ;
223
- let index = args[ COUNTER_ID ] . immediate ( ) ;
224
- debug ! (
225
- "translating Rust intrinsic `count_code_region()` to LLVM intrinsic: \
226
- instrprof.increment(fn_name={:?}, hash={:?}, num_counters={:?}, index={:?})",
227
- fn_name, hash, num_counters, index,
228
- ) ;
229
- self . instrprof_increment ( fn_name, hash, num_counters, index)
230
- }
231
140
sym:: va_start => self . va_start ( args[ 0 ] . immediate ( ) ) ,
232
141
sym:: va_end => self . va_end ( args[ 0 ] . immediate ( ) ) ,
233
142
sym:: va_copy => {
@@ -2238,15 +2147,3 @@ fn float_type_width(ty: Ty<'_>) -> Option<u64> {
2238
2147
_ => None ,
2239
2148
}
2240
2149
}
2241
-
2242
- fn op_to_str_slice < ' tcx > ( op : & Operand < ' tcx > ) -> & ' tcx str {
2243
- Operand :: value_from_const ( op) . try_to_str_slice ( ) . expect ( "Value is &str" )
2244
- }
2245
-
2246
- fn op_to_u32 < ' tcx > ( op : & Operand < ' tcx > ) -> u32 {
2247
- Operand :: scalar_from_const ( op) . to_u32 ( ) . expect ( "Scalar is u32" )
2248
- }
2249
-
2250
- fn op_to_u64 < ' tcx > ( op : & Operand < ' tcx > ) -> u64 {
2251
- Operand :: scalar_from_const ( op) . to_u64 ( ) . expect ( "Scalar is u64" )
2252
- }
0 commit comments