about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/mir/mod.rs
diff options
context:
space:
mode:
authorDianQK <dianqk@dianqk.net>2024-07-01 13:15:40 +0800
committerDianQK <dianqk@dianqk.net>2024-07-02 06:33:40 +0800
commit2ef82805d52a2f53368a56e8d3c9473f3cd89efc (patch)
tree52a703342503e5048a9820d321cdc03ec1174391 /compiler/rustc_codegen_ssa/src/mir/mod.rs
parentc453dcd62abba536d0580ad9b880b86d46e911ce (diff)
downloadrust-2ef82805d52a2f53368a56e8d3c9473f3cd89efc.tar.gz
rust-2ef82805d52a2f53368a56e8d3c9473f3cd89efc.zip
Use the aligned size for alloca at ret when the pass mode is cast.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/mir/mod.rs')
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/mod.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs
index e8da9842882..61f57c9030a 100644
--- a/compiler/rustc_codegen_ssa/src/mir/mod.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs
@@ -230,10 +230,20 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
             let layout = start_bx.layout_of(fx.monomorphize(decl.ty));
             assert!(!layout.ty.has_erasable_regions());
 
-            if local == mir::RETURN_PLACE && fx.fn_abi.ret.is_indirect() {
-                debug!("alloc: {:?} (return place) -> place", local);
-                let llretptr = start_bx.get_param(0);
-                return LocalRef::Place(PlaceRef::new_sized(llretptr, layout));
+            if local == mir::RETURN_PLACE {
+                match fx.fn_abi.ret.mode {
+                    PassMode::Indirect { .. } => {
+                        debug!("alloc: {:?} (return place) -> place", local);
+                        let llretptr = start_bx.get_param(0);
+                        return LocalRef::Place(PlaceRef::new_sized(llretptr, layout));
+                    }
+                    PassMode::Cast { ref cast, .. } => {
+                        debug!("alloc: {:?} (return place) -> place", local);
+                        let size = cast.size(&start_bx);
+                        return LocalRef::Place(PlaceRef::alloca_size(&mut start_bx, size, layout));
+                    }
+                    _ => {}
+                };
             }
 
             if memory_locals.contains(local) {