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;
2
2
use rustc_middle:: mir:: visit:: * ;
3
3
use rustc_middle:: mir:: * ;
4
4
use rustc_middle:: ty:: { self , ParamEnv , Ty , TyCtxt } ;
5
+ use rustc_span:: sym;
5
6
6
7
const INSTR_COST : usize = 5 ;
7
8
const CALL_PENALTY : usize = 25 ;
@@ -127,14 +128,24 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
127
128
}
128
129
}
129
130
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
+ }
138
149
if let UnwindAction :: Cleanup ( _) = unwind {
139
150
self . penalty += LANDINGPAD_PENALTY ;
140
151
}
You can’t perform that action at this time.
0 commit comments