@@ -17,6 +17,7 @@ use rustc_codegen_ssa::glue;
17
17
use rustc_codegen_ssa:: base:: { to_immediate, wants_msvc_seh, compare_simd_types} ;
18
18
use rustc:: ty:: { self , Ty } ;
19
19
use rustc:: ty:: layout:: { self , LayoutOf , HasTyCtxt , Primitive } ;
20
+ use rustc:: mir:: interpret:: GlobalId ;
20
21
use rustc_codegen_ssa:: common:: { IntPredicate , TypeKind } ;
21
22
use rustc:: hir;
22
23
use syntax:: ast:: { self , FloatTy } ;
@@ -83,13 +84,14 @@ fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: &str) -> Option<&'ll Valu
83
84
impl IntrinsicCallMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
84
85
fn codegen_intrinsic_call (
85
86
& mut self ,
86
- callee_ty : Ty < ' tcx > ,
87
+ instance : ty :: Instance < ' tcx > ,
87
88
fn_ty : & FnType < ' tcx , Ty < ' tcx > > ,
88
89
args : & [ OperandRef < ' tcx , & ' ll Value > ] ,
89
90
llresult : & ' ll Value ,
90
91
span : Span ,
91
92
) {
92
93
let tcx = self . tcx ;
94
+ let callee_ty = instance. ty ( tcx) ;
93
95
94
96
let ( def_id, substs) = match callee_ty. sty {
95
97
ty:: FnDef ( def_id, substs) => ( def_id, substs) ,
@@ -135,10 +137,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
135
137
let llfn = self . get_intrinsic ( & ( "llvm.debugtrap" ) ) ;
136
138
self . call ( llfn, & [ ] , None )
137
139
}
138
- "size_of" => {
139
- let tp_ty = substs. type_at ( 0 ) ;
140
- self . const_usize ( self . size_of ( tp_ty) . bytes ( ) )
141
- }
142
140
"va_start" => {
143
141
self . va_start ( args[ 0 ] . immediate ( ) )
144
142
}
@@ -190,10 +188,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
190
188
self . const_usize ( self . size_of ( tp_ty) . bytes ( ) )
191
189
}
192
190
}
193
- "min_align_of" => {
194
- let tp_ty = substs. type_at ( 0 ) ;
195
- self . const_usize ( self . align_of ( tp_ty) . bytes ( ) )
196
- }
197
191
"min_align_of_val" => {
198
192
let tp_ty = substs. type_at ( 0 ) ;
199
193
if let OperandValue :: Pair ( _, meta) = args[ 0 ] . val {
@@ -203,18 +197,19 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
203
197
self . const_usize ( self . align_of ( tp_ty) . bytes ( ) )
204
198
}
205
199
}
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" |
210
205
"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 ( ) ;
213
211
OperandRef :: from_const ( self , ty_name) . immediate_or_packed_pair ( self )
214
212
}
215
- "type_id" => {
216
- self . const_u64 ( self . tcx . type_id_hash ( substs. type_at ( 0 ) ) )
217
- }
218
213
"init" => {
219
214
let ty = substs. type_at ( 0 ) ;
220
215
if !self . layout_of ( ty) . is_zst ( ) {
@@ -237,11 +232,6 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
237
232
"uninit" | "forget" => {
238
233
return ;
239
234
}
240
- "needs_drop" => {
241
- let tp_ty = substs. type_at ( 0 ) ;
242
-
243
- self . const_bool ( self . type_needs_drop ( tp_ty) )
244
- }
245
235
"offset" => {
246
236
let ptr = args[ 0 ] . immediate ( ) ;
247
237
let offset = args[ 1 ] . immediate ( ) ;
0 commit comments