3 use rustc::mir::StatementKind::*;
4 use rustc_index::vec::IndexVec;
6 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
12 pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec<Local, SsaKind> {
13 let mut flag_map = fx.mir.local_decls.iter().map(|local_decl| {
14 if fx.clif_type(local_decl.ty).is_some() {
19 }).collect::<IndexVec<Local, SsaKind>>();
21 for bb in fx.mir.basic_blocks().iter() {
22 for stmt in bb.statements.iter() {
24 Assign(place_and_rval) => match &place_and_rval.1 {
25 Rvalue::Ref(_, _, place) => {
26 not_ssa(&mut flag_map, place.local)
34 match &bb.terminator().kind {
35 TerminatorKind::Call { destination, .. } => {
36 if let Some((dest_place, _dest_bb)) = destination {
37 let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty));
38 if !crate::abi::can_return_to_ssa_var(fx.tcx, dest_layout) {
39 not_ssa(&mut flag_map, dest_place.local)
50 fn not_ssa(flag_map: &mut IndexVec<Local, SsaKind>, local: Local) {
51 flag_map[local] = SsaKind::NotSsa;