Add arg_count field to Body in Stable MIR

This field allows SMIR consumers to identify which locals correspond to
argument locals. It simply exposes the arg_count field from the MIR
representation.
This commit is contained in:
Kirby Linvill 2023-10-23 18:07:07 +01:00
parent cf226e93dc
commit e4c41b07f0
No known key found for this signature in database
GPG key ID: E304CE3F028E6E3F
2 changed files with 11 additions and 0 deletions

View file

@ -308,6 +308,7 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
span: decl.source_info.span.stable(tables),
})
.collect(),
arg_count: self.arg_count,
}
}
}

View file

@ -2,10 +2,20 @@ use crate::ty::{AdtDef, ClosureDef, Const, CoroutineDef, GenericArgs, Movability
use crate::Opaque;
use crate::{ty::Ty, Span};
/// The SMIR representation of a single function.
#[derive(Clone, Debug)]
pub struct Body {
pub blocks: Vec<BasicBlock>,
/// Declarations of locals.
///
/// The first local is the return value pointer, followed by `arg_count`
/// locals for the function arguments, followed by any user-declared
/// variables and temporaries.
pub locals: LocalDecls,
/// The number of arguments this function takes.
pub arg_count: usize,
}
type LocalDecls = Vec<LocalDecl>;