3 use rustc_middle::mir::StatementKind::*;
4 use rustc_index::vec::IndexVec;
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> {
13 let mut flag_map = fx.mir.local_decls.iter().map(|local_decl| {
14 let ty = fx.monomorphize(&local_decl.ty);
15 if fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some() {
20 }).collect::<IndexVec<Local, SsaKind>>();
22 for bb in fx.mir.basic_blocks().iter() {
23 for stmt in bb.statements.iter() {
25 Assign(place_and_rval) => match &place_and_rval.1 {
26 Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place)=> {
27 not_ssa(&mut flag_map, place.local)
35 match &bb.terminator().kind {
36 TerminatorKind::Call { destination, .. } => {
37 if let Some((dest_place, _dest_bb)) = destination {
38 let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty));
39 if !crate::abi::can_return_to_ssa_var(fx.tcx, dest_layout) {
40 not_ssa(&mut flag_map, dest_place.local)
51 fn not_ssa(flag_map: &mut IndexVec<Local, SsaKind>, local: Local) {
52 flag_map[local] = SsaKind::NotSsa;