@@ -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
@@ -818,7 +818,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
818
818
// The arguments we'll be passing. Plus one to account for outptr, if used.
819
819
let arg_count = fn_abi. args . len ( ) + fn_abi. ret . is_indirect ( ) as usize ;
820
820
821
- if intrinsic == Some ( sym:: caller_location) {
821
+ if matches ! ( intrinsic, Some ( ty :: IntrinsicDef { name : sym:: caller_location, .. } ) ) {
822
822
return if let Some ( target) = target {
823
823
let location =
824
824
self . get_caller_location ( bx, mir:: SourceInfo { span : fn_span, ..source_info } ) ;
@@ -838,7 +838,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
838
838
}
839
839
840
840
let instance = match intrinsic {
841
- None | Some ( sym:: drop_in_place) => instance,
841
+ None | Some ( ty :: IntrinsicDef { name : sym:: drop_in_place, .. } ) => instance,
842
842
Some ( intrinsic) => {
843
843
let mut llargs = Vec :: with_capacity ( 1 ) ;
844
844
let ret_dest = self . make_return_dest (
@@ -866,7 +866,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
866
866
// third argument must be constant. This is
867
867
// checked by const-qualification, which also
868
868
// promotes any complex rvalues to constants.
869
- if i == 2 && intrinsic == sym:: simd_shuffle {
869
+ if i == 2 && intrinsic. name == sym:: simd_shuffle {
870
870
if let mir:: Operand :: Constant ( constant) = & arg. node {
871
871
let ( llval, ty) = self . simd_shuffle_indices ( bx, constant) ;
872
872
return OperandRef {
@@ -897,7 +897,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
897
897
} ;
898
898
}
899
899
// Call the fallback body instead of generating the intrinsic code
900
- Err ( ( ) ) => Some ( Instance :: new ( instance. def_id ( ) , instance. args ) ) ,
900
+ Err ( ( ) ) => {
901
+ if intrinsic. must_be_overridden {
902
+ span_bug ! (
903
+ span,
904
+ "intrinsic {} must be overridden by codegen backend, but isn't" ,
905
+ intrinsic. name,
906
+ ) ;
907
+ }
908
+ Some ( Instance :: new ( instance. def_id ( ) , instance. args ) )
909
+ }
901
910
}
902
911
}
903
912
} ;
0 commit comments