diff options
| author | bors <bors@rust-lang.org> | 2021-03-15 11:30:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-15 11:30:33 +0000 |
| commit | 7a7bbdb3abfa72ca717ef54ffc4f307d0d44de67 (patch) | |
| tree | e85839c159556d7628b8d842bb06a3bee5de01e8 /compiler/rustc_codegen_ssa/src | |
| parent | 2a55274e0ca9bf0b60cf72744b91237de625863e (diff) | |
| parent | 47f8bacc469a6d90ace323eb482f273988674dd1 (diff) | |
| download | rust-7a7bbdb3abfa72ca717ef54ffc4f307d0d44de67.tar.gz rust-7a7bbdb3abfa72ca717ef54ffc4f307d0d44de67.zip | |
Auto merge of #83118 - erikdesjardins:removezst, r=oli-obk
Rebase and fixup #80493: Remove MIR assignments to ZST types closes #80493 cc `@simonvandel` r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/analyze.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs index 289629d9215..31d5c87182d 100644 --- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs +++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs @@ -281,7 +281,18 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> Some(assignment_location) => { assignment_location.dominates(location, &self.dominators) } - None => false, + None => { + debug!("No first assignment found for {:?}", local); + // We have not seen any assignment to the local yet, + // but before marking not_ssa, check if it is a ZST, + // in which case we don't need to initialize the local. + let ty = self.fx.mir.local_decls[local].ty; + let ty = self.fx.monomorphize(ty); + + let is_zst = self.fx.cx.layout_of(ty).is_zst(); + debug!("is_zst: {}", is_zst); + is_zst + } }; if !ssa_read { self.not_ssa(local); |
