@@ -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 } ;
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 } ;
@@ -782,6 +782,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
782
782
_ => None ,
783
783
} ;
784
784
785
+ if let Some ( intrinsic @ ( sym:: copy_nonoverlapping | sym:: transmute) ) = intrinsic {
786
+ bug ! ( "Intrinsic {intrinsic} should have been lowered before codegen" ) ;
787
+ }
788
+
785
789
let extra_args = & args[ sig. inputs ( ) . skip_binder ( ) . len ( ) ..] ;
786
790
let extra_args = bx. tcx ( ) . mk_type_list ( extra_args. iter ( ) . map ( |op_arg| {
787
791
let op_ty = op_arg. ty ( self . mir , bx. tcx ( ) ) ;
@@ -793,23 +797,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
793
797
None => bx. fn_abi_of_fn_ptr ( sig, extra_args) ,
794
798
} ;
795
799
796
- if intrinsic == Some ( sym:: transmute) {
797
- return if let Some ( target) = target {
798
- self . codegen_transmute ( bx, & args[ 0 ] , destination) ;
799
- helper. funclet_br ( self , bx, target, mergeable_succ)
800
- } else {
801
- // If we are trying to transmute to an uninhabited type,
802
- // it is likely there is no allotted destination. In fact,
803
- // transmuting to an uninhabited type is UB, which means
804
- // we can do what we like. Here, we declare that transmuting
805
- // into an uninhabited type is impossible, so anything following
806
- // it must be unreachable.
807
- assert_eq ! ( fn_abi. ret. layout. abi, abi:: Abi :: Uninhabited ) ;
808
- bx. unreachable ( ) ;
809
- MergingSucc :: False
810
- } ;
811
- }
812
-
813
800
if let Some ( merging_succ) = self . codegen_panic_intrinsic (
814
801
& helper,
815
802
bx,
@@ -852,7 +839,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
852
839
853
840
match intrinsic {
854
841
None | Some ( sym:: drop_in_place) => { }
855
- Some ( sym:: copy_nonoverlapping) => unreachable ! ( ) ,
856
842
Some ( intrinsic) => {
857
843
let dest = match ret_dest {
858
844
_ if fn_abi. ret . is_indirect ( ) => llargs[ 0 ] ,
@@ -1763,32 +1749,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1763
1749
}
1764
1750
}
1765
1751
1766
- fn codegen_transmute ( & mut self , bx : & mut Bx , src : & mir:: Operand < ' tcx > , dst : mir:: Place < ' tcx > ) {
1767
- if let Some ( index) = dst. as_local ( ) {
1768
- match self . locals [ index] {
1769
- LocalRef :: Place ( place) => self . codegen_transmute_into ( bx, src, place) ,
1770
- LocalRef :: UnsizedPlace ( _) => bug ! ( "transmute must not involve unsized locals" ) ,
1771
- LocalRef :: Operand ( None ) => {
1772
- let dst_layout = bx. layout_of ( self . monomorphized_place_ty ( dst. as_ref ( ) ) ) ;
1773
- assert ! ( !dst_layout. ty. has_erasable_regions( ) ) ;
1774
- let place = PlaceRef :: alloca ( bx, dst_layout) ;
1775
- place. storage_live ( bx) ;
1776
- self . codegen_transmute_into ( bx, src, place) ;
1777
- let op = bx. load_operand ( place) ;
1778
- place. storage_dead ( bx) ;
1779
- self . locals [ index] = LocalRef :: Operand ( Some ( op) ) ;
1780
- self . debug_introduce_local ( bx, index) ;
1781
- }
1782
- LocalRef :: Operand ( Some ( op) ) => {
1783
- assert ! ( op. layout. is_zst( ) , "assigning to initialized SSAtemp" ) ;
1784
- }
1785
- }
1786
- } else {
1787
- let dst = self . codegen_place ( bx, dst. as_ref ( ) ) ;
1788
- self . codegen_transmute_into ( bx, src, dst) ;
1789
- }
1790
- }
1791
-
1792
1752
pub ( crate ) fn codegen_transmute_into (
1793
1753
& mut self ,
1794
1754
bx : & mut Bx ,
0 commit comments