@@ -1296,7 +1296,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1296
1296
}
1297
1297
1298
1298
// Atomic Operations
1299
- fn atomic_cmpxchg ( & mut self , dst : RValue < ' gcc > , cmp : RValue < ' gcc > , src : RValue < ' gcc > , order : AtomicOrdering , failure_order : AtomicOrdering , weak : bool ) -> RValue < ' gcc > {
1299
+ fn atomic_cmpxchg ( & mut self , dst : RValue < ' gcc > , cmp : RValue < ' gcc > , src : RValue < ' gcc > , order : AtomicOrdering , failure_order : AtomicOrdering , weak : bool ) -> ( RValue < ' gcc > , RValue < ' gcc > ) {
1300
1300
let expected = self . current_func ( ) . new_local ( None , cmp. get_type ( ) , "expected" ) ;
1301
1301
self . llbb ( ) . add_assignment ( None , expected, cmp) ;
1302
1302
// NOTE: gcc doesn't support a failure memory model that is stronger than the success
@@ -1310,20 +1310,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1310
1310
} ;
1311
1311
let success = self . compare_exchange ( dst, expected, src, order, failure_order, weak) ;
1312
1312
1313
- let pair_type = self . cx . type_struct ( & [ src. get_type ( ) , self . bool_type ] , false ) ;
1314
- let result = self . current_func ( ) . new_local ( None , pair_type, "atomic_cmpxchg_result" ) ;
1315
- let align = Align :: from_bits ( 64 ) . expect ( "align" ) ; // TODO(antoyo): use good align.
1313
+ // NOTE: since success contains the call to the intrinsic, it must be added to the basic block before
1314
+ // expected so that we store expected after the call.
1315
+ let success_var = self . current_func ( ) . new_local ( None , self . bool_type , "success" ) ;
1316
+ self . llbb ( ) . add_assignment ( None , success_var, success) ;
1316
1317
1317
- let value_type = result. to_rvalue ( ) . get_type ( ) ;
1318
- if let Some ( struct_type) = value_type. is_struct ( ) {
1319
- self . store ( success, result. access_field ( None , struct_type. get_field ( 1 ) ) . get_address ( None ) , align) ;
1320
- // NOTE: since success contains the call to the intrinsic, it must be stored before
1321
- // expected so that we store expected after the call.
1322
- self . store ( expected. to_rvalue ( ) , result. access_field ( None , struct_type. get_field ( 0 ) ) . get_address ( None ) , align) ;
1323
- }
1324
- // TODO(antoyo): handle when value is not a struct.
1325
-
1326
- result. to_rvalue ( )
1318
+ ( expected. to_rvalue ( ) , success_var. to_rvalue ( ) )
1327
1319
}
1328
1320
1329
1321
fn atomic_rmw ( & mut self , op : AtomicRmwBinOp , dst : RValue < ' gcc > , src : RValue < ' gcc > , order : AtomicOrdering ) -> RValue < ' gcc > {
0 commit comments