@@ -5,6 +5,7 @@ use rustc_middle::mir::TerminatorKind;
5
5
use rustc_middle:: ty:: TypeVisitableExt ;
6
6
use rustc_middle:: ty:: { self , GenericArgsRef , InstanceDef , TyCtxt } ;
7
7
use rustc_session:: Limit ;
8
+ use rustc_span:: sym;
8
9
9
10
// FIXME: check whether it is cheaper to precompute the entire call graph instead of invoking
10
11
// this query ridiculously often.
@@ -164,11 +165,20 @@ pub(crate) fn mir_inliner_callees<'tcx>(
164
165
let mut calls = FxIndexSet :: default ( ) ;
165
166
for bb_data in body. basic_blocks . iter ( ) {
166
167
let terminator = bb_data. terminator ( ) ;
167
- if let TerminatorKind :: Call { func, .. } = & terminator. kind {
168
+ if let TerminatorKind :: Call { func, args : call_args , .. } = & terminator. kind {
168
169
let ty = func. ty ( & body. local_decls , tcx) ;
169
- let call = match ty. kind ( ) {
170
- ty:: FnDef ( def_id, args) => ( * def_id, * args) ,
171
- _ => continue ,
170
+ let ty:: FnDef ( def_id, generic_args) = ty. kind ( ) else {
171
+ continue ;
172
+ } ;
173
+ let call = if tcx. is_intrinsic ( * def_id, sym:: const_eval_select) {
174
+ let func = & call_args[ 2 ] . node ;
175
+ let ty = func. ty ( & body. local_decls , tcx) ;
176
+ let ty:: FnDef ( def_id, generic_args) = ty. kind ( ) else {
177
+ continue ;
178
+ } ;
179
+ ( * def_id, * generic_args)
180
+ } else {
181
+ ( * def_id, * generic_args)
172
182
} ;
173
183
calls. insert ( call) ;
174
184
}
0 commit comments