This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
compiler/rustc_mir_transform/src Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use rustc_middle::bug;
22use rustc_middle:: mir:: visit:: * ;
33use rustc_middle:: mir:: * ;
44use rustc_middle:: ty:: { self , ParamEnv , Ty , TyCtxt } ;
5+ use rustc_span:: sym;
56
67const INSTR_COST : usize = 5 ;
78const CALL_PENALTY : usize = 25 ;
@@ -127,14 +128,24 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
127128 }
128129 }
129130 TerminatorKind :: Call { func, unwind, .. } => {
130- self . penalty += if let Some ( ( def_id, ..) ) = func. const_fn_def ( )
131- && self . tcx . intrinsic ( def_id) . is_some ( )
132- {
133- // Don't give intrinsics the extra penalty for calls
134- INSTR_COST
135- } else {
136- CALL_PENALTY
137- } ;
131+ let mut is_intrinsic = false ;
132+ let mut is_ubcheck = false ;
133+ if let Some ( ( def_id, ..) ) = func. const_fn_def ( ) {
134+ if self . tcx . intrinsic ( def_id) . is_some ( ) {
135+ is_intrinsic = true ;
136+ }
137+ if self . tcx . has_attr ( def_id, sym:: rustc_no_mir_inline) {
138+ is_ubcheck = true ;
139+ }
140+ }
141+ if !is_ubcheck {
142+ self . penalty += if is_intrinsic {
143+ // Don't give intrinsics the extra penalty for calls
144+ INSTR_COST
145+ } else {
146+ CALL_PENALTY
147+ } ;
148+ }
138149 if let UnwindAction :: Cleanup ( _) = unwind {
139150 self . penalty += LANDINGPAD_PENALTY ;
140151 }
You can’t perform that action at this time.
0 commit comments