@@ -4,7 +4,7 @@ use std::ptr;
44
55use libc:: { c_char, c_uint} ;
66use rustc_abi as abi;
7- use rustc_abi:: { AddressSpace , Align , HasDataLayout , Size , TargetDataLayout , WrappingRange } ;
7+ use rustc_abi:: { Align , HasDataLayout , Size , TargetDataLayout , WrappingRange } ;
88use rustc_codegen_ssa:: MemFlags ;
99use rustc_codegen_ssa:: common:: { AtomicRmwBinOp , IntPredicate , RealPredicate , TypeKind } ;
1010use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
@@ -720,7 +720,7 @@ impl<'ll, 'tcx, 'a> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
720720 flags : MemFlags ,
721721 ) -> & ' ll Value {
722722 assert_eq ! ( self . cx. type_kind( self . cx. val_ty( ptr) ) , TypeKind :: Pointer ) ;
723- let ptr = self . check_store ( val , ptr ) ;
723+
724724 let address_space = unsafe { llvm:: LLVMGetPointerAddressSpace ( self . val_ty ( ptr) ) } ;
725725 let store_pointer_ty = unsafe { llvm:: LLVMPointerType ( self . val_ty ( val) , address_space) } ;
726726
@@ -784,7 +784,7 @@ impl<'ll, 'tcx, 'a> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
784784 UNNAMED ,
785785 ) ;
786786 self . pointercast (
787- ptr ,
787+ res ,
788788 self . type_i8p_ext ( rustc_abi:: AddressSpace ( address_space) ) ,
789789 )
790790 }
@@ -809,7 +809,7 @@ impl<'ll, 'tcx, 'a> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
809809 UNNAMED ,
810810 ) ;
811811 self . pointercast (
812- ptr ,
812+ res ,
813813 self . type_i8p_ext ( rustc_abi:: AddressSpace ( address_space) ) ,
814814 )
815815 }
@@ -917,20 +917,20 @@ impl<'ll, 'tcx, 'a> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
917917
918918 fn bitcast ( & mut self , mut val : & ' ll Value , dest_ty : & ' ll Type ) -> & ' ll Value {
919919 trace ! ( "Bitcast `{:?}` to ty `{:?}`" , val, dest_ty) ;
920- unsafe {
921- let ty = self . val_ty ( val) ;
922- let kind = llvm:: LLVMRustGetTypeKind ( ty) ;
923- if kind == llvm :: TypeKind :: Pointer {
924- let element = self . element_type ( ty ) ;
925- let addrspace = llvm :: LLVMGetPointerAddressSpace ( ty) ;
926- let new_ty = self . type_ptr_to_ext ( element , AddressSpace :: ZERO ) ;
927- if addrspace != 0 {
928- trace ! ( "injecting addrspace cast for `{:?}` to `{:?}`" , ty , new_ty ) ;
929- val = llvm :: LLVMBuildAddrSpaceCast ( self . llbuilder , val , new_ty, UNNAMED ) ;
930- }
920+
921+ let ty = self . val_ty ( val) ;
922+ let kind = unsafe { llvm:: LLVMRustGetTypeKind ( ty) } ;
923+
924+ if kind == llvm :: TypeKind :: Pointer {
925+ let element = self . element_type ( ty) ;
926+ let addrspace = unsafe { llvm :: LLVMGetPointerAddressSpace ( ty ) } ;
927+ let new_ty = unsafe { llvm :: LLVMPointerType ( element , 0 ) } ;
928+ if addrspace != 0 {
929+ trace ! ( "injecting addrspace cast for `{:?}` to `{:?}`" , ty , new_ty) ;
930+ val = unsafe { llvm :: LLVMBuildAddrSpaceCast ( self . llbuilder , val , new_ty , UNNAMED ) } ;
931931 }
932- llvm:: LLVMBuildBitCast ( self . llbuilder , val, dest_ty, UNNAMED )
933932 }
933+ unsafe { llvm:: LLVMBuildBitCast ( self . llbuilder , val, dest_ty, UNNAMED ) }
934934 }
935935
936936 fn intcast ( & mut self , val : & ' ll Value , dest_ty : & ' ll Type , is_signed : bool ) -> & ' ll Value {
@@ -1198,7 +1198,7 @@ impl<'ll, 'tcx, 'a> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11981198 let res = self . atomic_op (
11991199 dst,
12001200 tuple,
1201- |builder, dst, ty | {
1201+ |builder, dst, _ | {
12021202 let address_space =
12031203 unsafe { llvm:: LLVMGetPointerAddressSpace ( builder. val_ty ( dst) ) } ;
12041204 let dst_ty = unsafe { llvm:: LLVMPointerType ( builder. val_ty ( cmp) , address_space) } ;
@@ -1216,7 +1216,7 @@ impl<'ll, 'tcx, 'a> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
12161216 )
12171217 }
12181218 } ,
1219- |builder, dst, ty | {
1219+ |builder, dst, _ | {
12201220 let dst = builder. pointercast ( dst, unsafe {
12211221 llvm:: LLVMPointerType (
12221222 builder. val_ty ( cmp) ,
@@ -1698,20 +1698,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
16981698
16991699 fn noundef_metadata ( & mut self , _load : & ' ll Value ) { }
17001700
1701- fn check_store ( & mut self , val : & ' ll Value , ptr : & ' ll Value ) -> & ' ll Value {
1702- let dest_ptr_ty = self . cx . val_ty ( ptr) ;
1703- let stored_ty = self . cx . val_ty ( val) ;
1704- let stored_ptr_ty = self . cx . type_ptr_to ( stored_ty) ;
1705-
1706- assert_eq ! ( self . cx. type_kind( dest_ptr_ty) , TypeKind :: Pointer ) ;
1707-
1708- if dest_ptr_ty == stored_ptr_ty {
1709- ptr
1710- } else {
1711- self . bitcast ( ptr, stored_ptr_ty)
1712- }
1713- }
1714-
17151701 fn check_call < ' b > (
17161702 & mut self ,
17171703 typ : & str ,
0 commit comments