@@ -12,7 +12,7 @@ use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout, WrappingRange};
1212use rustc_apfloat:: { Float , Round , Status , ieee} ;
1313use rustc_codegen_ssa:: MemFlags ;
1414use rustc_codegen_ssa:: common:: {
15- AtomicOrdering , AtomicRmwBinOp , IntPredicate , RealPredicate , SynchronizationScope , TypeKind ,
15+ AtomicRmwBinOp , IntPredicate , RealPredicate , SynchronizationScope , TypeKind ,
1616} ;
1717use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
1818use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
@@ -26,7 +26,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2626use rustc_middle:: ty:: layout:: {
2727 FnAbiError , FnAbiOfHelpers , FnAbiRequest , HasTyCtxt , HasTypingEnv , LayoutError , LayoutOfHelpers ,
2828} ;
29- use rustc_middle:: ty:: { self , Instance , Ty , TyCtxt } ;
29+ use rustc_middle:: ty:: { self , AtomicOrdering , Instance , Ty , TyCtxt } ;
3030use rustc_span:: Span ;
3131use rustc_span:: def_id:: DefId ;
3232use rustc_target:: callconv:: FnAbi ;
@@ -75,7 +75,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
7575
7676 let load_ordering = match order {
7777 // TODO(antoyo): does this make sense?
78- AtomicOrdering :: AcquireRelease | AtomicOrdering :: Release => AtomicOrdering :: Acquire ,
78+ AtomicOrdering :: AcqRel | AtomicOrdering :: Release => AtomicOrdering :: Acquire ,
7979 _ => order,
8080 } ;
8181 let previous_value =
@@ -781,6 +781,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
781781 return self . context . new_call ( self . location , fmod, & [ a, b] ) ;
782782 }
783783 TypeKind :: FP128 => {
784+ // TODO(antoyo): use get_simple_function_f128_2args.
784785 let f128_type = self . type_f128 ( ) ;
785786 let fmodf128 = self . context . new_function (
786787 None ,
@@ -1118,7 +1119,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
11181119 // TODO(antoyo)
11191120 }
11201121
1121- fn store ( & mut self , val : RValue < ' gcc > , ptr : RValue < ' gcc > , align : Align ) -> RValue < ' gcc > {
1122+ fn store ( & mut self , mut val : RValue < ' gcc > , ptr : RValue < ' gcc > , align : Align ) -> RValue < ' gcc > {
1123+ if self . structs_as_pointer . borrow ( ) . contains ( & val) {
1124+ // NOTE: hack to workaround a limitation of the rustc API: see comment on
1125+ // CodegenCx.structs_as_pointer
1126+ val = val. dereference ( self . location ) . to_rvalue ( ) ;
1127+ }
1128+
11221129 self . store_with_flags ( val, ptr, align, MemFlags :: empty ( ) )
11231130 }
11241131
@@ -1564,16 +1571,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
15641571 aggregate_value
15651572 }
15661573
1567- fn set_personality_fn ( & mut self , _personality : RValue < ' gcc > ) {
1574+ fn set_personality_fn ( & mut self , _personality : Function < ' gcc > ) {
15681575 #[ cfg( feature = "master" ) ]
1569- {
1570- let personality = self . rvalue_as_function ( _personality) ;
1571- self . current_func ( ) . set_personality_function ( personality) ;
1572- }
1576+ self . current_func ( ) . set_personality_function ( _personality) ;
15731577 }
15741578
15751579 #[ cfg( feature = "master" ) ]
1576- fn cleanup_landing_pad ( & mut self , pers_fn : RValue < ' gcc > ) -> ( RValue < ' gcc > , RValue < ' gcc > ) {
1580+ fn cleanup_landing_pad ( & mut self , pers_fn : Function < ' gcc > ) -> ( RValue < ' gcc > , RValue < ' gcc > ) {
15771581 self . set_personality_fn ( pers_fn) ;
15781582
15791583 // NOTE: insert the current block in a variable so that a later call to invoke knows to
@@ -1594,7 +1598,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
15941598 }
15951599
15961600 #[ cfg( not( feature = "master" ) ) ]
1597- fn cleanup_landing_pad ( & mut self , _pers_fn : RValue < ' gcc > ) -> ( RValue < ' gcc > , RValue < ' gcc > ) {
1601+ fn cleanup_landing_pad ( & mut self , _pers_fn : Function < ' gcc > ) -> ( RValue < ' gcc > , RValue < ' gcc > ) {
15981602 let value1 = self
15991603 . current_func ( )
16001604 . new_local ( self . location , self . u8_type . make_pointer ( ) , "landing_pad0" )
@@ -1604,7 +1608,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
16041608 ( value1, value2)
16051609 }
16061610
1607- fn filter_landing_pad ( & mut self , pers_fn : RValue < ' gcc > ) -> ( RValue < ' gcc > , RValue < ' gcc > ) {
1611+ fn filter_landing_pad ( & mut self , pers_fn : Function < ' gcc > ) -> ( RValue < ' gcc > , RValue < ' gcc > ) {
16081612 // TODO(antoyo): generate the correct landing pad
16091613 self . cleanup_landing_pad ( pers_fn)
16101614 }
@@ -2511,8 +2515,8 @@ impl ToGccOrdering for AtomicOrdering {
25112515 AtomicOrdering :: Relaxed => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
25122516 AtomicOrdering :: Acquire => __ATOMIC_ACQUIRE,
25132517 AtomicOrdering :: Release => __ATOMIC_RELEASE,
2514- AtomicOrdering :: AcquireRelease => __ATOMIC_ACQ_REL,
2515- AtomicOrdering :: SequentiallyConsistent => __ATOMIC_SEQ_CST,
2518+ AtomicOrdering :: AcqRel => __ATOMIC_ACQ_REL,
2519+ AtomicOrdering :: SeqCst => __ATOMIC_SEQ_CST,
25162520 } ;
25172521 ordering as i32
25182522 }
0 commit comments