Add profiling to mir lower and borrowck query

This commit is contained in:
hkalbasi 2023-03-07 12:42:52 +03:30
parent 2cce9dc3e9
commit bcd7ecb242
4 changed files with 33 additions and 21 deletions

View file

@ -33,6 +33,7 @@ pub fn borrowck_query(
db: &dyn HirDatabase,
def: DefWithBodyId,
) -> Result<Arc<BorrowckResult>, MirLowerError> {
let _p = profile::span("borrowck_query");
let body = db.mir_body(def)?;
let r = BorrowckResult { mutability_of_locals: mutability_of_locals(&body), mir_body: body };
Ok(Arc::new(r))

View file

@ -15,7 +15,7 @@ use hir_def::{
resolver::{resolver_for_expr, ResolveValueResult, ValueNs},
DefWithBodyId, EnumVariantId, HasModule,
};
use hir_expand::name;
use hir_expand::name::Name;
use la_arena::ArenaMap;
use crate::{
@ -1453,6 +1453,16 @@ fn cast_kind(source_ty: &Ty, target_ty: &Ty) -> Result<CastKind> {
}
pub fn mir_body_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Result<Arc<MirBody>> {
let _p = profile::span("mir_body_query").detail(|| match def {
DefWithBodyId::FunctionId(it) => db.function_data(it).name.to_string(),
DefWithBodyId::StaticId(it) => db.static_data(it).name.clone().to_string(),
DefWithBodyId::ConstId(it) => {
db.const_data(it).name.clone().unwrap_or_else(Name::missing).to_string()
}
DefWithBodyId::VariantId(it) => {
db.enum_data(it.parent).variants[it.local_id].name.to_string()
}
});
let body = db.body(def);
let infer = db.infer(def);
let result = lower_to_mir(db, def, &body, &infer, body.body_expr)?;

View file

@ -1,6 +1,7 @@
//! MIR lowering for places
use super::*;
use hir_expand::name;
macro_rules! not_supported {
($x: expr) => {