@@ -182,23 +182,16 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
182
182
/// of that field's type - this is useful for taking the address of
183
183
/// that field and ensuring the struct has the right alignment.
184
184
fn gcc_type < ' gcc > ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> Type < ' gcc > {
185
+ // This must produce the same result for `repr(transparent)` wrappers as for the inner type!
186
+ // In other words, this should generally not look at the type at all, but only at the
187
+ // layout.
185
188
if let Abi :: Scalar ( ref scalar) = self . abi {
186
189
// Use a different cache for scalars because pointers to DSTs
187
190
// can be either fat or thin (data pointers of fat pointers).
188
191
if let Some ( & ty) = cx. scalar_types . borrow ( ) . get ( & self . ty ) {
189
192
return ty;
190
193
}
191
- let ty =
192
- match * self . ty . kind ( ) {
193
- ty:: Ref ( _, ty, _) | ty:: RawPtr ( ty:: TypeAndMut { ty, .. } ) => {
194
- cx. type_ptr_to ( cx. layout_of ( ty) . gcc_type ( cx) )
195
- }
196
- ty:: Adt ( def, _) if def. is_box ( ) => {
197
- cx. type_ptr_to ( cx. layout_of ( self . ty . boxed_ty ( ) ) . gcc_type ( cx) )
198
- }
199
- ty:: FnPtr ( sig) => cx. fn_ptr_backend_type ( & cx. fn_abi_of_fn_ptr ( sig, ty:: List :: empty ( ) ) ) ,
200
- _ => self . scalar_gcc_type_at ( cx, scalar, Size :: ZERO ) ,
201
- } ;
194
+ let ty = self . scalar_gcc_type_at ( cx, scalar, Size :: ZERO ) ;
202
195
cx. scalar_types . borrow_mut ( ) . insert ( self . ty , ty) ;
203
196
return ty;
204
197
}
@@ -273,22 +266,9 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
273
266
}
274
267
275
268
fn scalar_pair_element_gcc_type < ' gcc > ( & self , cx : & CodegenCx < ' gcc , ' tcx > , index : usize , immediate : bool ) -> Type < ' gcc > {
276
- // TODO(antoyo): remove llvm hack:
277
- // HACK(eddyb) special-case fat pointers until LLVM removes
278
- // pointee types, to avoid bitcasting every `OperandRef::deref`.
279
- match self . ty . kind ( ) {
280
- ty:: Ref ( ..) | ty:: RawPtr ( _) => {
281
- return self . field ( cx, index) . gcc_type ( cx) ;
282
- }
283
- // only wide pointer boxes are handled as pointers
284
- // thin pointer boxes with scalar allocators are handled by the general logic below
285
- ty:: Adt ( def, args) if def. is_box ( ) && cx. layout_of ( args. type_at ( 1 ) ) . is_zst ( ) => {
286
- let ptr_ty = Ty :: new_mut_ptr ( cx. tcx , self . ty . boxed_ty ( ) ) ;
287
- return cx. layout_of ( ptr_ty) . scalar_pair_element_gcc_type ( cx, index, immediate) ;
288
- }
289
- _ => { }
290
- }
291
-
269
+ // This must produce the same result for `repr(transparent)` wrappers as for the inner type!
270
+ // In other words, this should generally not look at the type at all, but only at the
271
+ // layout.
292
272
let ( a, b) = match self . abi {
293
273
Abi :: ScalarPair ( ref a, ref b) => ( a, b) ,
294
274
_ => bug ! ( "TyAndLayout::scalar_pair_element_llty({:?}): not applicable" , self ) ,
0 commit comments