@@ -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 } ;
@@ -765,6 +765,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
765
765
_ => None ,
766
766
} ;
767
767
768
+ if let Some ( intrinsic @ ( sym:: copy_nonoverlapping | sym:: transmute) ) = intrinsic {
769
+ bug ! ( "Intrinsic {intrinsic} should have been lowered before codegen" ) ;
770
+ }
771
+
768
772
let extra_args = & args[ sig. inputs ( ) . skip_binder ( ) . len ( ) ..] ;
769
773
let extra_args = bx. tcx ( ) . mk_type_list_from_iter ( extra_args. iter ( ) . map ( |op_arg| {
770
774
let op_ty = op_arg. ty ( self . mir , bx. tcx ( ) ) ;
@@ -776,23 +780,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
776
780
None => bx. fn_abi_of_fn_ptr ( sig, extra_args) ,
777
781
} ;
778
782
779
- if intrinsic == Some ( sym:: transmute) {
780
- return if let Some ( target) = target {
781
- self . codegen_transmute ( bx, & args[ 0 ] , destination) ;
782
- helper. funclet_br ( self , bx, target, mergeable_succ)
783
- } else {
784
- // If we are trying to transmute to an uninhabited type,
785
- // it is likely there is no allotted destination. In fact,
786
- // transmuting to an uninhabited type is UB, which means
787
- // we can do what we like. Here, we declare that transmuting
788
- // into an uninhabited type is impossible, so anything following
789
- // it must be unreachable.
790
- assert_eq ! ( fn_abi. ret. layout. abi, abi:: Abi :: Uninhabited ) ;
791
- bx. unreachable ( ) ;
792
- MergingSucc :: False
793
- } ;
794
- }
795
-
796
783
if let Some ( merging_succ) = self . codegen_panic_intrinsic (
797
784
& helper,
798
785
bx,
@@ -835,7 +822,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
835
822
836
823
match intrinsic {
837
824
None | Some ( sym:: drop_in_place) => { }
838
- Some ( sym:: copy_nonoverlapping) => unreachable ! ( ) ,
839
825
Some ( intrinsic) => {
840
826
let dest = match ret_dest {
841
827
_ if fn_abi. ret . is_indirect ( ) => llargs[ 0 ] ,
@@ -1746,33 +1732,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1746
1732
}
1747
1733
}
1748
1734
1749
- fn codegen_transmute ( & mut self , bx : & mut Bx , src : & mir:: Operand < ' tcx > , dst : mir:: Place < ' tcx > ) {
1750
- if let Some ( index) = dst. as_local ( ) {
1751
- match self . locals [ index] {
1752
- LocalRef :: Place ( place) => self . codegen_transmute_into ( bx, src, place) ,
1753
- LocalRef :: UnsizedPlace ( _) => bug ! ( "transmute must not involve unsized locals" ) ,
1754
- LocalRef :: Operand ( None ) => {
1755
- let dst_layout = bx. layout_of ( self . monomorphized_place_ty ( dst. as_ref ( ) ) ) ;
1756
- assert ! ( !dst_layout. ty. has_erasable_regions( ) ) ;
1757
- let place = PlaceRef :: alloca ( bx, dst_layout) ;
1758
- place. storage_live ( bx) ;
1759
- self . codegen_transmute_into ( bx, src, place) ;
1760
- let op = bx. load_operand ( place) ;
1761
- place. storage_dead ( bx) ;
1762
- self . locals [ index] = LocalRef :: Operand ( Some ( op) ) ;
1763
- self . debug_introduce_local ( bx, index) ;
1764
- }
1765
- LocalRef :: Operand ( Some ( op) ) => {
1766
- assert ! ( op. layout. is_zst( ) , "assigning to initialized SSAtemp" ) ;
1767
- }
1768
- }
1769
- } else {
1770
- let dst = self . codegen_place ( bx, dst. as_ref ( ) ) ;
1771
- self . codegen_transmute_into ( bx, src, dst) ;
1772
- }
1773
- }
1774
-
1775
- fn codegen_transmute_into (
1735
+ pub ( crate ) fn codegen_transmute_into (
1776
1736
& mut self ,
1777
1737
bx : & mut Bx ,
1778
1738
src : & mir:: Operand < ' tcx > ,
0 commit comments