Skip to content

Commit 3d0a0dc

Browse files
committed
Add a distinct OperandValue::ZeroSized variant for ZSTs
These tend to have special handling in a bunch of places anyway, so the variant helps remember that. And I think it's easier to grok than non-Scalar Aggregates sometimes being `Immediates` (like I got wrong and caused 109992). As a minor bonus, it means we don't need to generate poison LLVM values for them to pass around in `OperandValue::Immediate`s.
1 parent afe5787 commit 3d0a0dc

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
758758
assert_eq!(place.llextra.is_some(), place.layout.is_unsized());
759759

760760
if place.layout.is_zst() {
761-
return OperandRef::new_zst(self, place.layout);
761+
return OperandRef::zero_sized(place.layout);
762762
}
763763

764764
fn scalar_load_metadata<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>, load: RValue<'gcc>, scalar: &abi::Scalar) {

src/type_of.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
159159
fn is_gcc_immediate(&self) -> bool {
160160
match self.abi {
161161
Abi::Scalar(_) | Abi::Vector { .. } => true,
162-
Abi::ScalarPair(..) => false,
163-
Abi::Uninhabited | Abi::Aggregate { .. } => self.is_zst(),
162+
Abi::ScalarPair(..) | Abi::Uninhabited | Abi::Aggregate { .. } => false,
164163
}
165164
}
166165

0 commit comments

Comments
 (0)