@@ -39,7 +39,7 @@ use rustc::middle::weak_lang_items;
39
39
use rustc:: mir:: mono:: { Linkage , Visibility , Stats , CodegenUnitNameBuilder } ;
40
40
use rustc:: middle:: cstore:: { EncodedMetadata } ;
41
41
use rustc:: ty:: { self , Ty , TyCtxt } ;
42
- use rustc:: ty:: layout:: { self , Align , TyLayout , LayoutOf , VariantIdx } ;
42
+ use rustc:: ty:: layout:: { self , Align , TyLayout , LayoutOf , VariantIdx , HasTyCtxt } ;
43
43
use rustc:: ty:: query:: Providers ;
44
44
use rustc:: middle:: cstore:: { self , LinkagePreference } ;
45
45
use rustc:: middle:: exported_symbols;
@@ -76,6 +76,7 @@ use interfaces::*;
76
76
use std:: any:: Any ;
77
77
use std:: cmp;
78
78
use std:: ffi:: CString ;
79
+ use std:: marker;
79
80
use std:: ops:: { Deref , DerefMut } ;
80
81
use std:: sync:: mpsc;
81
82
use std:: time:: { Instant , Duration } ;
@@ -90,27 +91,29 @@ use mir::operand::OperandValue;
90
91
91
92
use rustc_codegen_utils:: check_for_rustc_errors_attr;
92
93
93
- pub struct StatRecorder < ' a , ' ll : ' a , ' tcx : ' ll > {
94
- cx : & ' a CodegenCx < ' ll , ' tcx > ,
94
+ pub struct StatRecorder < ' a , ' tcx , Cx : ' a + CodegenMethods < ' tcx > > {
95
+ cx : & ' a Cx ,
95
96
name : Option < String > ,
96
97
istart : usize ,
98
+ _marker : marker:: PhantomData < & ' tcx ( ) > ,
97
99
}
98
100
99
- impl StatRecorder < ' a , ' ll , ' tcx > {
100
- pub fn new ( cx : & ' a CodegenCx < ' ll , ' tcx > , name : String ) -> Self {
101
- let istart = cx. stats . borrow ( ) . n_llvm_insns ;
101
+ impl < ' a , ' tcx , Cx : CodegenMethods < ' tcx > > StatRecorder < ' a , ' tcx , Cx > {
102
+ pub fn new ( cx : & ' a Cx , name : String ) -> Self {
103
+ let istart = cx. stats ( ) . borrow ( ) . n_llvm_insns ;
102
104
StatRecorder {
103
105
cx,
104
106
name : Some ( name) ,
105
107
istart,
108
+ _marker : marker:: PhantomData ,
106
109
}
107
110
}
108
111
}
109
112
110
- impl Drop for StatRecorder < ' a , ' ll , ' tcx > {
113
+ impl < ' a , ' tcx , Cx : CodegenMethods < ' tcx > > Drop for StatRecorder < ' a , ' tcx , Cx > {
111
114
fn drop ( & mut self ) {
112
115
if self . cx . sess ( ) . codegen_stats ( ) {
113
- let mut stats = self . cx . stats . borrow_mut ( ) ;
116
+ let mut stats = self . cx . stats ( ) . borrow_mut ( ) ;
114
117
let iend = stats. n_llvm_insns ;
115
118
stats. fn_stats . push ( ( self . name . take ( ) . unwrap ( ) , iend - self . istart ) ) ;
116
119
stats. n_fns += 1 ;
@@ -449,10 +452,13 @@ pub fn memcpy_ty<'a, 'tcx: 'a, Builder: BuilderMethods<'a, 'tcx>>(
449
452
bx. memcpy ( dst, dst_align, src, src_align, bx. cx ( ) . const_usize ( size) , flags) ;
450
453
}
451
454
452
- pub fn codegen_instance ( cx : & CodegenCx < ' _ , ' tcx > , instance : Instance < ' tcx > ) {
455
+ pub fn codegen_instance < ' a , ' tcx : ' a , Bx : BuilderMethods < ' a , ' tcx > > (
456
+ cx : & ' a Bx :: CodegenCx ,
457
+ instance : Instance < ' tcx > ,
458
+ ) {
453
459
let _s = if cx. sess ( ) . codegen_stats ( ) {
454
460
let mut instance_name = String :: new ( ) ;
455
- DefPathBasedNames :: new ( cx. tcx , true , true )
461
+ DefPathBasedNames :: new ( cx. tcx ( ) , true , true )
456
462
. push_def_path ( instance. def_id ( ) , & mut instance_name) ;
457
463
Some ( StatRecorder :: new ( cx, instance_name) )
458
464
} else {
@@ -464,16 +470,16 @@ pub fn codegen_instance(cx: &CodegenCx<'_, 'tcx>, instance: Instance<'tcx>) {
464
470
// release builds.
465
471
info ! ( "codegen_instance({})" , instance) ;
466
472
467
- let sig = instance. fn_sig ( cx. tcx ) ;
468
- let sig = cx. tcx . normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , & sig) ;
473
+ let sig = instance. fn_sig ( cx. tcx ( ) ) ;
474
+ let sig = cx. tcx ( ) . normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , & sig) ;
469
475
470
- let lldecl = cx. instances . borrow ( ) . get ( & instance) . cloned ( ) . unwrap_or_else ( ||
476
+ let lldecl = cx. instances ( ) . borrow ( ) . get ( & instance) . cloned ( ) . unwrap_or_else ( ||
471
477
bug ! ( "Instance `{:?}` not already declared" , instance) ) ;
472
478
473
- cx. stats . borrow_mut ( ) . n_closures += 1 ;
479
+ cx. stats ( ) . borrow_mut ( ) . n_closures += 1 ;
474
480
475
- let mir = cx. tcx . instance_mir ( instance. def ) ;
476
- mir:: codegen_mir :: < Builder > ( cx, lldecl, & mir, instance, sig) ;
481
+ let mir = cx. tcx ( ) . instance_mir ( instance. def ) ;
482
+ mir:: codegen_mir :: < Bx > ( cx, lldecl, & mir, instance, sig) ;
477
483
}
478
484
479
485
pub fn set_link_section ( llval : & Value , attrs : & CodegenFnAttrs ) {
0 commit comments