@@ -5,6 +5,7 @@ use rustc_middle::mir::TerminatorKind;
55use rustc_middle:: ty:: TypeVisitableExt ;
66use rustc_middle:: ty:: { self , GenericArgsRef , InstanceDef , TyCtxt } ;
77use rustc_session:: Limit ;
8+ use rustc_span:: sym;
89
910// FIXME: check whether it is cheaper to precompute the entire call graph instead of invoking
1011// this query ridiculously often.
@@ -164,11 +165,20 @@ pub(crate) fn mir_inliner_callees<'tcx>(
164165 let mut calls = FxIndexSet :: default ( ) ;
165166 for bb_data in body. basic_blocks . iter ( ) {
166167 let terminator = bb_data. terminator ( ) ;
167- if let TerminatorKind :: Call { func, .. } = & terminator. kind {
168+ if let TerminatorKind :: Call { func, args : call_args , .. } = & terminator. kind {
168169 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)
172182 } ;
173183 calls. insert ( call) ;
174184 }
0 commit comments