Make is_intrinsic
query return the intrinsic name
This commit is contained in:
parent
de4d615e6b
commit
0eee945680
22 changed files with 38 additions and 43 deletions
|
@ -70,7 +70,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
|
|||
TerminatorKind::Call { func: Operand::Constant(ref f), unwind, .. } => {
|
||||
let fn_ty = self.instantiate_ty(f.const_.ty());
|
||||
self.cost += if let ty::FnDef(def_id, _) = *fn_ty.kind()
|
||||
&& tcx.is_intrinsic(def_id)
|
||||
&& tcx.intrinsic(def_id).is_some()
|
||||
{
|
||||
// Don't give intrinsics the extra penalty for calls
|
||||
INSTR_COST
|
||||
|
|
|
@ -329,9 +329,8 @@ fn resolve_rust_intrinsic<'tcx>(
|
|||
func_ty: Ty<'tcx>,
|
||||
) -> Option<(Symbol, GenericArgsRef<'tcx>)> {
|
||||
if let ty::FnDef(def_id, args) = *func_ty.kind() {
|
||||
if tcx.is_intrinsic(def_id) {
|
||||
return Some((tcx.item_name(def_id), args));
|
||||
}
|
||||
let name = tcx.intrinsic(def_id)?;
|
||||
return Some((name, args));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
|
@ -161,8 +161,7 @@ fn remap_mir_for_const_eval_select<'tcx>(
|
|||
fn_span,
|
||||
..
|
||||
} if let ty::FnDef(def_id, _) = *const_.ty().kind()
|
||||
&& tcx.item_name(def_id) == sym::const_eval_select
|
||||
&& tcx.is_intrinsic(def_id) =>
|
||||
&& matches!(tcx.intrinsic(def_id), Some(sym::const_eval_select)) =>
|
||||
{
|
||||
let [tupled_args, called_in_const, called_at_rt]: [_; 3] =
|
||||
std::mem::take(args).try_into().unwrap();
|
||||
|
|
|
@ -14,9 +14,8 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
|||
if let TerminatorKind::Call { func, args, destination, target, .. } =
|
||||
&mut terminator.kind
|
||||
&& let ty::FnDef(def_id, generic_args) = *func.ty(local_decls, tcx).kind()
|
||||
&& tcx.is_intrinsic(def_id)
|
||||
&& let Some(intrinsic_name) = tcx.intrinsic(def_id)
|
||||
{
|
||||
let intrinsic_name = tcx.item_name(def_id);
|
||||
match intrinsic_name {
|
||||
sym::unreachable => {
|
||||
terminator.kind = TerminatorKind::Unreachable;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue