@@ -17,6 +17,7 @@ use rustc_codegen_ssa::glue;
1717use rustc_codegen_ssa:: base:: { to_immediate, wants_msvc_seh, compare_simd_types} ;
1818use rustc:: ty:: { self , Ty } ;
1919use rustc:: ty:: layout:: { self , LayoutOf , HasTyCtxt , Primitive } ;
20+ use rustc:: mir:: interpret:: GlobalId ;
2021use rustc_codegen_ssa:: common:: { IntPredicate , TypeKind } ;
2122use rustc:: hir;
2223use syntax:: ast:: { self , FloatTy } ;
@@ -83,13 +84,14 @@ fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: &str) -> Option<&'ll Valu
8384impl IntrinsicCallMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
8485 fn codegen_intrinsic_call (
8586 & mut self ,
86- callee_ty : Ty < ' tcx > ,
87+ instance : ty :: Instance < ' tcx > ,
8788 fn_ty : & FnType < ' tcx , Ty < ' tcx > > ,
8889 args : & [ OperandRef < ' tcx , & ' ll Value > ] ,
8990 llresult : & ' ll Value ,
9091 span : Span ,
9192 ) {
9293 let tcx = self . tcx ;
94+ let callee_ty = instance. ty ( tcx) ;
9395
9496 let ( def_id, substs) = match callee_ty. sty {
9597 ty:: FnDef ( def_id, substs) => ( def_id, substs) ,
@@ -135,10 +137,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
135137 let llfn = self . get_intrinsic ( & ( "llvm.debugtrap" ) ) ;
136138 self . call ( llfn, & [ ] , None )
137139 }
138- "size_of" => {
139- let tp_ty = substs. type_at ( 0 ) ;
140- self . const_usize ( self . size_of ( tp_ty) . bytes ( ) )
141- }
142140 "va_start" => {
143141 self . va_start ( args[ 0 ] . immediate ( ) )
144142 }
@@ -190,10 +188,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
190188 self . const_usize ( self . size_of ( tp_ty) . bytes ( ) )
191189 }
192190 }
193- "min_align_of" => {
194- let tp_ty = substs. type_at ( 0 ) ;
195- self . const_usize ( self . align_of ( tp_ty) . bytes ( ) )
196- }
197191 "min_align_of_val" => {
198192 let tp_ty = substs. type_at ( 0 ) ;
199193 if let OperandValue :: Pair ( _, meta) = args[ 0 ] . val {
@@ -203,18 +197,19 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
203197 self . const_usize ( self . align_of ( tp_ty) . bytes ( ) )
204198 }
205199 }
206- "pref_align_of" => {
207- let tp_ty = substs. type_at ( 0 ) ;
208- self . const_usize ( self . layout_of ( tp_ty) . align . pref . bytes ( ) )
209- }
200+ "size_of" |
201+ "pref_align_of" |
202+ "min_align_of" |
203+ "needs_drop" |
204+ "type_id" |
210205 "type_name" => {
211- let tp_ty = substs. type_at ( 0 ) ;
212- let ty_name = self . tcx . type_name ( tp_ty) ;
206+ let gid = GlobalId {
207+ instance,
208+ promoted : None ,
209+ } ;
210+ let ty_name = self . tcx . const_eval ( ty:: ParamEnv :: reveal_all ( ) . and ( gid) ) . unwrap ( ) ;
213211 OperandRef :: from_const ( self , ty_name) . immediate_or_packed_pair ( self )
214212 }
215- "type_id" => {
216- self . const_u64 ( self . tcx . type_id_hash ( substs. type_at ( 0 ) ) )
217- }
218213 "init" => {
219214 let ty = substs. type_at ( 0 ) ;
220215 if !self . layout_of ( ty) . is_zst ( ) {
@@ -237,11 +232,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
237232 "uninit" | "forget" => {
238233 return ;
239234 }
240- "needs_drop" => {
241- let tp_ty = substs. type_at ( 0 ) ;
242-
243- self . const_bool ( self . type_needs_drop ( tp_ty) )
244- }
245235 "offset" => {
246236 let ptr = args[ 0 ] . immediate ( ) ;
247237 let offset = args[ 1 ] . immediate ( ) ;
0 commit comments