@@ -11,22 +11,18 @@ use rustc_ast as ast;
1111use rustc_codegen_ssa:: base:: { compare_simd_types, to_immediate, wants_msvc_seh} ;
1212use rustc_codegen_ssa:: common:: span_invalid_monomorphization_error;
1313use rustc_codegen_ssa:: common:: { IntPredicate , TypeKind } ;
14- use rustc_codegen_ssa:: coverageinfo;
1514use rustc_codegen_ssa:: glue;
1615use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
1716use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
1817use rustc_codegen_ssa:: traits:: * ;
1918use rustc_codegen_ssa:: MemFlags ;
2019use rustc_hir as hir;
21- use rustc_middle:: mir:: coverage;
22- use rustc_middle:: mir:: Operand ;
2320use rustc_middle:: ty:: layout:: { FnAbiExt , HasTyCtxt } ;
2421use rustc_middle:: ty:: { self , Ty } ;
2522use rustc_middle:: { bug, span_bug} ;
2623use rustc_span:: { sym, symbol:: kw, Span , Symbol } ;
2724use rustc_target:: abi:: { self , HasDataLayout , LayoutOf , Primitive } ;
2825use rustc_target:: spec:: PanicStrategy ;
29- use tracing:: debug;
3026
3127use std:: cmp:: Ordering ;
3228use std:: iter;
@@ -83,85 +79,13 @@ fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: Symbol) -> Option<&'ll Va
8379}
8480
8581impl 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-
15782 fn codegen_intrinsic_call (
15883 & mut self ,
15984 instance : ty:: Instance < ' tcx > ,
16085 fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
16186 args : & [ OperandRef < ' tcx , & ' ll Value > ] ,
16287 llresult : & ' ll Value ,
16388 span : Span ,
164- caller_instance : ty:: Instance < ' tcx > ,
16589 ) {
16690 let tcx = self . tcx ;
16791 let callee_ty = instance. ty ( tcx, ty:: ParamEnv :: reveal_all ( ) ) ;
@@ -213,21 +137,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
213137 let llfn = self . get_intrinsic ( & ( "llvm.debugtrap" ) ) ;
214138 self . call ( llfn, & [ ] , None )
215139 }
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- }
231140 sym:: va_start => self . va_start ( args[ 0 ] . immediate ( ) ) ,
232141 sym:: va_end => self . va_end ( args[ 0 ] . immediate ( ) ) ,
233142 sym:: va_copy => {
@@ -2238,15 +2147,3 @@ fn float_type_width(ty: Ty<'_>) -> Option<u64> {
22382147 _ => None ,
22392148 }
22402149}
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