@@ -834,10 +834,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
834834 }
835835 else if let abi:: Abi :: ScalarPair ( ref a, ref b) = place. layout . abi {
836836 let b_offset = a. size ( self ) . align_to ( b. align ( self ) . abi ) ;
837- let pair_type = place. layout . gcc_type ( self ) ;
838837
839838 let mut load = |i, scalar : & abi:: Scalar , align| {
840- let llptr = self . struct_gep ( pair_type, place. llval , i as u64 ) ;
839+ let llptr = if i == 0 {
840+ place. llval
841+ } else {
842+ self . inbounds_ptradd ( place. llval , self . const_usize ( b_offset. bytes ( ) ) )
843+ } ;
841844 let llty = place. layout . scalar_pair_element_gcc_type ( self , i) ;
842845 let load = self . load ( llty, llptr, align) ;
843846 scalar_load_metadata ( self , load, scalar) ;
@@ -971,33 +974,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
971974 result. get_address ( None )
972975 }
973976
974- fn struct_gep ( & mut self , value_type : Type < ' gcc > , ptr : RValue < ' gcc > , idx : u64 ) -> RValue < ' gcc > {
975- // FIXME(antoyo): it would be better if the API only called this on struct, not on arrays.
976- assert_eq ! ( idx as usize as u64 , idx) ;
977- let value = ptr. dereference ( None ) . to_rvalue ( ) ;
978-
979- if value_type. dyncast_array ( ) . is_some ( ) {
980- let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
981- let element = self . context . new_array_access ( None , value, index) ;
982- element. get_address ( None )
983- }
984- else if let Some ( vector_type) = value_type. dyncast_vector ( ) {
985- let array_type = vector_type. get_element_type ( ) . make_pointer ( ) ;
986- let array = self . bitcast ( ptr, array_type) ;
987- let index = self . context . new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
988- let element = self . context . new_array_access ( None , array, index) ;
989- element. get_address ( None )
990- }
991- else if let Some ( struct_type) = value_type. is_struct ( ) {
992- // NOTE: due to opaque pointers now being used, we need to bitcast here.
993- let ptr = self . bitcast_if_needed ( ptr, value_type. make_pointer ( ) ) ;
994- ptr. dereference_field ( None , struct_type. get_field ( idx as i32 ) ) . get_address ( None )
995- }
996- else {
997- panic ! ( "Unexpected type {:?}" , value_type) ;
998- }
999- }
1000-
1001977 /* Casts */
1002978 fn trunc ( & mut self , value : RValue < ' gcc > , dest_ty : Type < ' gcc > ) -> RValue < ' gcc > {
1003979 // TODO(antoyo): check that it indeed truncate the value.
0 commit comments