@@ -350,14 +350,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
350350 if int_type_width_signed ( ty, bx. tcx ( ) ) . is_some ( ) || ty. is_unsafe_ptr ( ) {
351351 let weak = instruction == "cxchgweak" ;
352352 let dst = args[ 0 ] . immediate ( ) ;
353- let mut cmp = args[ 1 ] . immediate ( ) ;
354- let mut src = args[ 2 ] . immediate ( ) ;
355- if ty. is_unsafe_ptr ( ) {
356- // Some platforms do not support atomic operations on pointers,
357- // so we cast to integer first.
358- cmp = bx. ptrtoint ( cmp, bx. type_isize ( ) ) ;
359- src = bx. ptrtoint ( src, bx. type_isize ( ) ) ;
360- }
353+ let cmp = args[ 1 ] . immediate ( ) ;
354+ let src = args[ 2 ] . immediate ( ) ;
361355 let ( val, success) = bx. atomic_cmpxchg (
362356 dst,
363357 cmp,
@@ -385,26 +379,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
385379 let layout = bx. layout_of ( ty) ;
386380 let size = layout. size ;
387381 let source = args[ 0 ] . immediate ( ) ;
388- if ty. is_unsafe_ptr ( ) {
389- // Some platforms do not support atomic operations on pointers,
390- // so we cast to integer first...
391- let llty = bx. type_isize ( ) ;
392- let result = bx. atomic_load (
393- llty,
394- source,
395- parse_ordering ( bx, ordering) ,
396- size,
397- ) ;
398- // ... and then cast the result back to a pointer
399- bx. inttoptr ( result, bx. backend_type ( layout) )
400- } else {
401- bx. atomic_load (
402- bx. backend_type ( layout) ,
403- source,
404- parse_ordering ( bx, ordering) ,
405- size,
406- )
407- }
382+ bx. atomic_load (
383+ bx. backend_type ( layout) ,
384+ source,
385+ parse_ordering ( bx, ordering) ,
386+ size,
387+ )
408388 } else {
409389 invalid_monomorphization ( ty) ;
410390 return Ok ( ( ) ) ;
@@ -415,13 +395,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
415395 let ty = fn_args. type_at ( 0 ) ;
416396 if int_type_width_signed ( ty, bx. tcx ( ) ) . is_some ( ) || ty. is_unsafe_ptr ( ) {
417397 let size = bx. layout_of ( ty) . size ;
418- let mut val = args[ 1 ] . immediate ( ) ;
398+ let val = args[ 1 ] . immediate ( ) ;
419399 let ptr = args[ 0 ] . immediate ( ) ;
420- if ty. is_unsafe_ptr ( ) {
421- // Some platforms do not support atomic operations on pointers,
422- // so we cast to integer first.
423- val = bx. ptrtoint ( val, bx. type_isize ( ) ) ;
424- }
425400 bx. atomic_store ( val, ptr, parse_ordering ( bx, ordering) , size) ;
426401 } else {
427402 invalid_monomorphization ( ty) ;
@@ -465,12 +440,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
465440 let ty = fn_args. type_at ( 0 ) ;
466441 if int_type_width_signed ( ty, bx. tcx ( ) ) . is_some ( ) || ty. is_unsafe_ptr ( ) {
467442 let ptr = args[ 0 ] . immediate ( ) ;
468- let mut val = args[ 1 ] . immediate ( ) ;
469- if ty. is_unsafe_ptr ( ) {
470- // Some platforms do not support atomic operations on pointers,
471- // so we cast to integer first.
472- val = bx. ptrtoint ( val, bx. type_isize ( ) ) ;
473- }
443+ let val = args[ 1 ] . immediate ( ) ;
474444 bx. atomic_rmw ( atom_op, ptr, val, parse_ordering ( bx, ordering) )
475445 } else {
476446 invalid_monomorphization ( ty) ;
0 commit comments