@@ -751,7 +751,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
751
751
& mut self ,
752
752
helper : & TerminatorCodegenHelper < ' tcx > ,
753
753
bx : & mut Bx ,
754
- intrinsic : Option < ty:: IntrinsicDef > ,
754
+ intrinsic : ty:: IntrinsicDef ,
755
755
instance : Option < Instance < ' tcx > > ,
756
756
source_info : mir:: SourceInfo ,
757
757
target : Option < mir:: BasicBlock > ,
@@ -761,8 +761,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
761
761
// Emit a panic or a no-op for `assert_*` intrinsics.
762
762
// These are intrinsics that compile to panics so that we can get a message
763
763
// which mentions the offending type, even from a const context.
764
- let panic_intrinsic = intrinsic. and_then ( |i| ValidityRequirement :: from_intrinsic ( i. name ) ) ;
765
- if let Some ( requirement) = panic_intrinsic {
764
+ if let Some ( requirement) = ValidityRequirement :: from_intrinsic ( intrinsic. name ) {
766
765
let ty = instance. unwrap ( ) . args . type_at ( 0 ) ;
767
766
768
767
let do_panic = !bx
@@ -869,12 +868,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
869
868
let sig = callee. layout . ty . fn_sig ( bx. tcx ( ) ) ;
870
869
let abi = sig. abi ( ) ;
871
870
872
- // Handle intrinsics old codegen wants Expr's for, ourselves.
873
- let intrinsic = match def {
874
- Some ( ty:: InstanceKind :: Intrinsic ( def_id) ) => Some ( bx. tcx ( ) . intrinsic ( def_id) . unwrap ( ) ) ,
875
- _ => None ,
876
- } ;
877
-
878
871
let extra_args = & args[ sig. inputs ( ) . skip_binder ( ) . len ( ) ..] ;
879
872
let extra_args = bx. tcx ( ) . mk_type_list_from_iter ( extra_args. iter ( ) . map ( |op_arg| {
880
873
let op_ty = op_arg. node . ty ( self . mir , bx. tcx ( ) ) ;
@@ -886,25 +879,25 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
886
879
None => bx. fn_abi_of_fn_ptr ( sig, extra_args) ,
887
880
} ;
888
881
889
- if let Some ( merging_succ) = self . codegen_panic_intrinsic (
890
- & helper,
891
- bx,
892
- intrinsic,
893
- instance,
894
- source_info,
895
- target,
896
- unwind,
897
- mergeable_succ,
898
- ) {
899
- return merging_succ;
900
- }
901
-
902
882
// The arguments we'll be passing. Plus one to account for outptr, if used.
903
883
let arg_count = fn_abi. args . len ( ) + fn_abi. ret . is_indirect ( ) as usize ;
904
884
905
- let instance = match intrinsic {
906
- None => instance,
907
- Some ( intrinsic) => {
885
+ let instance = match def {
886
+ Some ( ty:: InstanceKind :: Intrinsic ( def_id) ) => {
887
+ let intrinsic = bx. tcx ( ) . intrinsic ( def_id) . unwrap ( ) ;
888
+ if let Some ( merging_succ) = self . codegen_panic_intrinsic (
889
+ & helper,
890
+ bx,
891
+ intrinsic,
892
+ instance,
893
+ source_info,
894
+ target,
895
+ unwind,
896
+ mergeable_succ,
897
+ ) {
898
+ return merging_succ;
899
+ }
900
+
908
901
let mut llargs = Vec :: with_capacity ( 1 ) ;
909
902
let ret_dest = self . make_return_dest (
910
903
bx,
@@ -984,6 +977,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
984
977
}
985
978
}
986
979
}
980
+ _ => instance,
987
981
} ;
988
982
989
983
let mut llargs = Vec :: with_capacity ( arg_count) ;
0 commit comments