@@ -17,7 +17,7 @@ use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, ValidityRequirement};
17
17
use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths} ;
18
18
use rustc_middle:: ty:: { self , Instance , Ty } ;
19
19
use rustc_session:: config:: OptLevel ;
20
- use rustc_span:: { source_map:: Spanned , sym, Span , Symbol } ;
20
+ use rustc_span:: { source_map:: Spanned , sym, Span } ;
21
21
use rustc_target:: abi:: call:: { ArgAbi , FnAbi , PassMode , Reg } ;
22
22
use rustc_target:: abi:: { self , HasDataLayout , WrappingRange } ;
23
23
use rustc_target:: spec:: abi:: Abi ;
@@ -672,7 +672,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
672
672
& mut self ,
673
673
helper : & TerminatorCodegenHelper < ' tcx > ,
674
674
bx : & mut Bx ,
675
- intrinsic : Option < Symbol > ,
675
+ intrinsic : Option < ty :: IntrinsicDef > ,
676
676
instance : Option < Instance < ' tcx > > ,
677
677
source_info : mir:: SourceInfo ,
678
678
target : Option < mir:: BasicBlock > ,
@@ -682,7 +682,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
682
682
// Emit a panic or a no-op for `assert_*` intrinsics.
683
683
// These are intrinsics that compile to panics so that we can get a message
684
684
// which mentions the offending type, even from a const context.
685
- let panic_intrinsic = intrinsic. and_then ( |s | ValidityRequirement :: from_intrinsic ( s ) ) ;
685
+ let panic_intrinsic = intrinsic. and_then ( |i | ValidityRequirement :: from_intrinsic ( i . name ) ) ;
686
686
if let Some ( requirement) = panic_intrinsic {
687
687
let ty = instance. unwrap ( ) . args . type_at ( 0 ) ;
688
688
@@ -787,9 +787,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
787
787
788
788
// Handle intrinsics old codegen wants Expr's for, ourselves.
789
789
let intrinsic = match def {
790
- Some ( ty:: InstanceDef :: Intrinsic ( def_id) ) => {
791
- Some ( bx. tcx ( ) . intrinsic ( def_id) . unwrap ( ) . name )
792
- }
790
+ Some ( ty:: InstanceDef :: Intrinsic ( def_id) ) => Some ( bx. tcx ( ) . intrinsic ( def_id) . unwrap ( ) ) ,
793
791
_ => None ,
794
792
} ;
795
793
@@ -820,7 +818,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
820
818
// The arguments we'll be passing. Plus one to account for outptr, if used.
821
819
let arg_count = fn_abi. args . len ( ) + fn_abi. ret . is_indirect ( ) as usize ;
822
820
823
- if intrinsic == Some ( sym:: caller_location) {
821
+ if matches ! ( intrinsic, Some ( ty :: IntrinsicDef { name : sym:: caller_location, .. } ) ) {
824
822
return if let Some ( target) = target {
825
823
let location =
826
824
self . get_caller_location ( bx, mir:: SourceInfo { span : fn_span, ..source_info } ) ;
@@ -840,7 +838,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
840
838
}
841
839
842
840
let instance = match intrinsic {
843
- None | Some ( sym:: drop_in_place) => instance,
841
+ None | Some ( ty :: IntrinsicDef { name : sym:: drop_in_place, .. } ) => instance,
844
842
Some ( intrinsic) => {
845
843
let mut llargs = Vec :: with_capacity ( 1 ) ;
846
844
let ret_dest = self . make_return_dest (
@@ -868,7 +866,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
868
866
// third argument must be constant. This is
869
867
// checked by const-qualification, which also
870
868
// promotes any complex rvalues to constants.
871
- if i == 2 && intrinsic == sym:: simd_shuffle {
869
+ if i == 2 && intrinsic. name == sym:: simd_shuffle {
872
870
if let mir:: Operand :: Constant ( constant) = & arg. node {
873
871
let ( llval, ty) = self . simd_shuffle_indices ( bx, constant) ;
874
872
return OperandRef {
@@ -899,7 +897,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
899
897
} ;
900
898
}
901
899
// Call the fallback body instead of generating the intrinsic code
902
- Err ( ( ) ) => Some ( Instance :: new ( instance. def_id ( ) , instance. args ) ) ,
900
+ Err ( ( ) ) => {
901
+ assert ! ( !intrinsic. must_be_overridden) ;
902
+ Some ( Instance :: new ( instance. def_id ( ) , instance. args ) )
903
+ }
903
904
}
904
905
}
905
906
} ;
0 commit comments