@@ -16,7 +16,7 @@ use rustc_index::vec::Idx;
16
16
use rustc_middle:: mir:: { self , AssertKind , SwitchTargets } ;
17
17
use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , ValidityRequirement } ;
18
18
use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths} ;
19
- use rustc_middle:: ty:: { self , Instance , Ty , TypeVisitableExt } ;
19
+ use rustc_middle:: ty:: { self , Instance , Ty } ;
20
20
use rustc_session:: config:: OptLevel ;
21
21
use rustc_span:: source_map:: Span ;
22
22
use rustc_span:: { sym, Symbol } ;
@@ -769,23 +769,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
769
769
None => bx. fn_abi_of_fn_ptr ( sig, extra_args) ,
770
770
} ;
771
771
772
- if intrinsic == Some ( sym:: transmute) {
773
- return if let Some ( target) = target {
774
- self . codegen_transmute ( bx, & args[ 0 ] , destination) ;
775
- helper. funclet_br ( self , bx, target, mergeable_succ)
776
- } else {
777
- // If we are trying to transmute to an uninhabited type,
778
- // it is likely there is no allotted destination. In fact,
779
- // transmuting to an uninhabited type is UB, which means
780
- // we can do what we like. Here, we declare that transmuting
781
- // into an uninhabited type is impossible, so anything following
782
- // it must be unreachable.
783
- assert_eq ! ( fn_abi. ret. layout. abi, abi:: Abi :: Uninhabited ) ;
784
- bx. unreachable ( ) ;
785
- MergingSucc :: False
786
- } ;
787
- }
788
-
789
772
if let Some ( merging_succ) = self . codegen_panic_intrinsic (
790
773
& helper,
791
774
bx,
@@ -828,7 +811,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
828
811
829
812
match intrinsic {
830
813
None | Some ( sym:: drop_in_place) => { }
831
- Some ( sym:: copy_nonoverlapping) => unreachable ! ( ) ,
832
814
Some ( intrinsic) => {
833
815
let dest = match ret_dest {
834
816
_ if fn_abi. ret . is_indirect ( ) => llargs[ 0 ] ,
@@ -1739,71 +1721,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1739
1721
}
1740
1722
}
1741
1723
1742
- fn codegen_transmute ( & mut self , bx : & mut Bx , src : & mir:: Operand < ' tcx > , dst : mir:: Place < ' tcx > ) {
1743
- if let Some ( index) = dst. as_local ( ) {
1744
- match self . locals [ index] {
1745
- LocalRef :: Place ( place) => self . codegen_transmute_into ( bx, src, place) ,
1746
- LocalRef :: UnsizedPlace ( _) => bug ! ( "transmute must not involve unsized locals" ) ,
1747
- LocalRef :: Operand ( None ) => {
1748
- let dst_layout = bx. layout_of ( self . monomorphized_place_ty ( dst. as_ref ( ) ) ) ;
1749
- assert ! ( !dst_layout. ty. has_erasable_regions( ) ) ;
1750
- let place = PlaceRef :: alloca ( bx, dst_layout) ;
1751
- place. storage_live ( bx) ;
1752
- self . codegen_transmute_into ( bx, src, place) ;
1753
- let op = bx. load_operand ( place) ;
1754
- place. storage_dead ( bx) ;
1755
- self . locals [ index] = LocalRef :: Operand ( Some ( op) ) ;
1756
- self . debug_introduce_local ( bx, index) ;
1757
- }
1758
- LocalRef :: Operand ( Some ( op) ) => {
1759
- assert ! ( op. layout. is_zst( ) , "assigning to initialized SSAtemp" ) ;
1760
- }
1761
- }
1762
- } else {
1763
- let dst = self . codegen_place ( bx, dst. as_ref ( ) ) ;
1764
- self . codegen_transmute_into ( bx, src, dst) ;
1765
- }
1766
- }
1767
-
1768
- fn codegen_transmute_into (
1769
- & mut self ,
1770
- bx : & mut Bx ,
1771
- src : & mir:: Operand < ' tcx > ,
1772
- dst : PlaceRef < ' tcx , Bx :: Value > ,
1773
- ) {
1774
- let src = self . codegen_operand ( bx, src) ;
1775
-
1776
- // Special-case transmutes between scalars as simple bitcasts.
1777
- match ( src. layout . abi , dst. layout . abi ) {
1778
- ( abi:: Abi :: Scalar ( src_scalar) , abi:: Abi :: Scalar ( dst_scalar) ) => {
1779
- // HACK(eddyb) LLVM doesn't like `bitcast`s between pointers and non-pointers.
1780
- let src_is_ptr = matches ! ( src_scalar. primitive( ) , abi:: Pointer ( _) ) ;
1781
- let dst_is_ptr = matches ! ( dst_scalar. primitive( ) , abi:: Pointer ( _) ) ;
1782
- if src_is_ptr == dst_is_ptr {
1783
- assert_eq ! ( src. layout. size, dst. layout. size) ;
1784
-
1785
- // NOTE(eddyb) the `from_immediate` and `to_immediate_scalar`
1786
- // conversions allow handling `bool`s the same as `u8`s.
1787
- let src = bx. from_immediate ( src. immediate ( ) ) ;
1788
- // LLVM also doesn't like `bitcast`s between pointers in different address spaces.
1789
- let src_as_dst = if src_is_ptr {
1790
- bx. pointercast ( src, bx. backend_type ( dst. layout ) )
1791
- } else {
1792
- bx. bitcast ( src, bx. backend_type ( dst. layout ) )
1793
- } ;
1794
- Immediate ( bx. to_immediate_scalar ( src_as_dst, dst_scalar) ) . store ( bx, dst) ;
1795
- return ;
1796
- }
1797
- }
1798
- _ => { }
1799
- }
1800
-
1801
- let llty = bx. backend_type ( src. layout ) ;
1802
- let cast_ptr = bx. pointercast ( dst. llval , bx. type_ptr_to ( llty) ) ;
1803
- let align = src. layout . align . abi . min ( dst. align ) ;
1804
- src. val . store ( bx, PlaceRef :: new_sized_aligned ( cast_ptr, src. layout , align) ) ;
1805
- }
1806
-
1807
1724
// Stores the return value of a function call into it's final location.
1808
1725
fn store_return (
1809
1726
& mut self ,
0 commit comments