Skip to content

Commit aae084d

Browse files
committed
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.
1 parent 858a42b commit aae084d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
302302
span: decl.source_info.span.stable(tables),
303303
})
304304
.collect(),
305+
arg_count: self.arg_count,
305306
}
306307
}
307308
}

compiler/stable_mir/src/mir/body.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@ use crate::ty::{AdtDef, ClosureDef, Const, CoroutineDef, GenericArgs, Movability
22
use crate::Opaque;
33
use crate::{ty::Ty, Span};
44

5+
/// The SMIR representation of a single function.
56
#[derive(Clone, Debug)]
67
pub struct Body {
78
pub blocks: Vec<BasicBlock>,
9+
10+
/// Declarations of locals.
11+
///
12+
/// The first local is the return value pointer, followed by `arg_count`
13+
/// locals for the function arguments, followed by any user-declared
14+
/// variables and temporaries.
815
pub locals: LocalDecls,
16+
17+
/// The number of arguments this function takes.
18+
pub arg_count: usize,
919
}
1020

1121
type LocalDecls = Vec<LocalDecl>;

0 commit comments

Comments
 (0)