]> git.lizzy.rs Git - rust.git/blobdiff - src/analyze.rs
Rollup merge of #81618 - bjorn3:sync_cg_clif-2021-02-01, r=bjorn3
[rust.git] / src / analyze.rs
index 055b371f43c3c064dd97bf0edac92f4db7bb84e1..62fbcfe3f7a5df6bda3f4c7b4093b6aa4ba875e7 100644 (file)
@@ -1,3 +1,5 @@
+//! SSA analysis
+
 use crate::prelude::*;
 
 use rustc_index::vec::IndexVec;
@@ -9,13 +11,13 @@ pub(crate) enum SsaKind {
     Ssa,
 }
 
-pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec<Local, SsaKind> {
+pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Module>) -> IndexVec<Local, SsaKind> {
     let mut flag_map = fx
         .mir
         .local_decls
         .iter()
         .map(|local_decl| {
-            let ty = fx.monomorphize(&local_decl.ty);
+            let ty = fx.monomorphize(local_decl.ty);
             if fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some() {
                 SsaKind::Ssa
             } else {
@@ -38,11 +40,14 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec<Local,
         }
 
         match &bb.terminator().kind {
-            TerminatorKind::Call { destination, .. } => {
+            TerminatorKind::Call {
+                destination,
+                func,
+                args,
+                ..
+            } => {
                 if let Some((dest_place, _dest_bb)) = destination {
-                    let dest_layout = fx
-                        .layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty));
-                    if !crate::abi::can_return_to_ssa_var(fx.tcx, dest_layout) {
+                    if !crate::abi::can_return_to_ssa_var(fx, func, args) {
                         not_ssa(&mut flag_map, dest_place.local)
                     }
                 }