3 use rustc_index::vec::IndexVec;
4 use rustc_middle::mir::StatementKind::*;
6 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
7 pub(crate) enum SsaKind {
12 pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec<Local, SsaKind> {
18 let ty = fx.monomorphize(&local_decl.ty);
19 if fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some() {
25 .collect::<IndexVec<Local, SsaKind>>();
27 for bb in fx.mir.basic_blocks().iter() {
28 for stmt in bb.statements.iter() {
30 Assign(place_and_rval) => match &place_and_rval.1 {
31 Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
32 not_ssa(&mut flag_map, place.local)
40 match &bb.terminator().kind {
41 TerminatorKind::Call { destination, .. } => {
42 if let Some((dest_place, _dest_bb)) = destination {
44 .layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty));
45 if !crate::abi::can_return_to_ssa_var(fx.tcx, dest_layout) {
46 not_ssa(&mut flag_map, dest_place.local)
57 fn not_ssa(flag_map: &mut IndexVec<Local, SsaKind>, local: Local) {
58 flag_map[local] = SsaKind::NotSsa;