@@ -729,17 +729,25 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
729
729
unimplemented ! ( ) ;
730
730
}
731
731
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 > {
733
733
let block = self . llbb ( ) ;
734
734
let function = block. get_function ( ) ;
735
735
// NOTE: instead of returning the dereference here, we have to assign it to a variable in
736
736
// the current basic block. Otherwise, it could be used in another basic block, causing a
737
737
// 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 ( ) ) ;
740
748
let deref = ptr. dereference ( None ) . to_rvalue ( ) ;
741
749
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 } ) ) ;
743
751
block. add_assignment ( None , loaded_value, deref) ;
744
752
loaded_value. to_rvalue ( )
745
753
}
@@ -1857,7 +1865,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
1857
1865
1858
1866
#[ cfg( feature="master" ) ]
1859
1867
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" ) ;
1861
1870
let then_val_element_type = then_val_vector_type. get_element_type ( ) ;
1862
1871
let then_val_element_size = then_val_element_type. get_size ( ) ;
1863
1872
0 commit comments