Skip to content

Commit 1d49dce

Browse files
authored
Rollup merge of #101484 - oli-obk:no_zst, r=eddyb
Remove dead broken code from const zst handling in backends cc `@RalfJung` found by `@eddyb` in #98957 (comment)
2 parents 923dae5 + 9c4fb01 commit 1d49dce

File tree

4 files changed

+1
-17
lines changed

4 files changed

+1
-17
lines changed

compiler/rustc_codegen_gcc/src/common.rs

-4
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,6 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
158158
None
159159
}
160160

161-
fn zst_to_backend(&self, _ty: Type<'gcc>) -> RValue<'gcc> {
162-
self.const_undef(self.type_ix(0))
163-
}
164-
165161
fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) -> RValue<'gcc> {
166162
let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
167163
match cv {

compiler/rustc_codegen_llvm/src/common.rs

-4
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,6 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
226226
})
227227
}
228228

229-
fn zst_to_backend(&self, _llty: &'ll Type) -> &'ll Value {
230-
self.const_undef(self.type_ix(0))
231-
}
232-
233229
fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, llty: &'ll Type) -> &'ll Value {
234230
let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
235231
match cv {

compiler/rustc_codegen_ssa/src/mir/operand.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
7272
) -> Self {
7373
let layout = bx.layout_of(ty);
7474

75-
if layout.is_zst() {
76-
return OperandRef::new_zst(bx, layout);
77-
}
78-
7975
let val = match val {
8076
ConstValue::Scalar(x) => {
8177
let Abi::Scalar(scalar) = layout.abi else {
@@ -84,10 +80,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
8480
let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout));
8581
OperandValue::Immediate(llval)
8682
}
87-
ConstValue::ZeroSized => {
88-
let llval = bx.zst_to_backend(bx.immediate_backend_type(layout));
89-
OperandValue::Immediate(llval)
90-
}
83+
ConstValue::ZeroSized => return OperandRef::new_zst(bx, layout),
9184
ConstValue::Slice { data, start, end } => {
9285
let Abi::ScalarPair(a_scalar, _) = layout.abi else {
9386
bug!("from_const: invalid ScalarPair layout: {:#?}", layout);

compiler/rustc_codegen_ssa/src/traits/consts.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub trait ConstMethods<'tcx>: BackendTypes {
2929
fn const_data_from_alloc(&self, alloc: ConstAllocation<'tcx>) -> Self::Value;
3030

3131
fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, llty: Self::Type) -> Self::Value;
32-
fn zst_to_backend(&self, llty: Self::Type) -> Self::Value;
3332
fn from_const_alloc(
3433
&self,
3534
layout: TyAndLayout<'tcx>,

0 commit comments

Comments
 (0)