@@ -729,17 +729,25 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
729729 unimplemented ! ( ) ;
730730 }
731731
732- fn load ( & mut self , pointee_ty : Type < ' gcc > , ptr : RValue < ' gcc > , _align : Align ) -> RValue < ' gcc > {
732+ fn load ( & mut self , pointee_ty : Type < ' gcc > , ptr : RValue < ' gcc > , align : Align ) -> RValue < ' gcc > {
733733 let block = self . llbb ( ) ;
734734 let function = block. get_function ( ) ;
735735 // NOTE: instead of returning the dereference here, we have to assign it to a variable in
736736 // the current basic block. Otherwise, it could be used in another basic block, causing a
737737 // dereference after a drop, for instance.
738- // TODO(antoyo): handle align of the load instruction.
739- let ptr = self . context . new_cast ( None , ptr, pointee_ty. make_pointer ( ) ) ;
738+ // FIXME(antoyo): this check that we don't call get_aligned() a second time on a type.
739+ // Ideally, we shouldn't need to do this check.
740+ let aligned_type =
741+ if pointee_ty == self . cx . u128_type || pointee_ty == self . cx . i128_type {
742+ pointee_ty
743+ }
744+ else {
745+ pointee_ty. get_aligned ( align. bytes ( ) )
746+ } ;
747+ let ptr = self . context . new_cast ( None , ptr, aligned_type. make_pointer ( ) ) ;
740748 let deref = ptr. dereference ( None ) . to_rvalue ( ) ;
741749 unsafe { RETURN_VALUE_COUNT += 1 } ;
742- let loaded_value = function. new_local ( None , pointee_ty , & format ! ( "loadedValue{}" , unsafe { RETURN_VALUE_COUNT } ) ) ;
750+ let loaded_value = function. new_local ( None , aligned_type , & format ! ( "loadedValue{}" , unsafe { RETURN_VALUE_COUNT } ) ) ;
743751 block. add_assignment ( None , loaded_value, deref) ;
744752 loaded_value. to_rvalue ( )
745753 }
@@ -1857,7 +1865,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
18571865
18581866 #[ cfg( feature="master" ) ]
18591867 let ( cond, element_type) = {
1860- let then_val_vector_type = then_val. get_type ( ) . dyncast_vector ( ) . expect ( "vector type" ) ;
1868+ // TODO(antoyo): dyncast_vector should not require a call to unqualified.
1869+ let then_val_vector_type = then_val. get_type ( ) . unqualified ( ) . dyncast_vector ( ) . expect ( "vector type" ) ;
18611870 let then_val_element_type = then_val_vector_type. get_element_type ( ) ;
18621871 let then_val_element_size = then_val_element_type. get_size ( ) ;
18631872
0 commit comments