Skip to content

Commit cb72965

Browse files
committed
Auto merge of #145513 - beepster4096:erasedereftemps, r=saethlin,cjgillot
Validate CopyForDeref and DerefTemps better and remove them from runtime MIR (split from my WIP rust-lang/rust#145344) This PR: - Removes `Rvalue::CopyForDeref` and `LocalInfo::DerefTemp` from runtime MIR - Using a new mir pass `EraseDerefTemps` - `CopyForDeref(x)` is turned into `Use(Copy(x))` - `DerefTemp` is turned into `Boring` - Not sure if this part is actually necessary, it made more sense in rust-lang/rust#145344 with `DerefTemp` storing actual data that I wanted to keep from having to be kept in sync with the rest of the body in runtime MIR - Checks in validation that `CopyForDeref` and `DerefTemp` are only used together - Removes special handling for `CopyForDeref` from many places - Removes `CopyForDeref` from `custom_mir` reverting rust-lang/rust#111587 - In runtime MIR simple copies can be used instead - In post cleanup analysis MIR it was already wrong to use due to the lack of support for creating `DerefTemp` locals - Possibly this should be its own PR? - Adds an argument to `deref_finder` to avoid creating new `DerefTemp`s and `CopyForDeref` in runtime MIR. - Ideally we would just avoid making intermediate derefs instead of fixing it at the end of a pass / during shim building - Removes some usages of `deref_finder` that I found out don't actually do anything r? oli-obk
2 parents 0f2b470 + 7201c1b commit cb72965

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/base.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
600600
let val = codegen_operand(fx, operand);
601601
lval.write_cvalue(fx, val);
602602
}
603-
Rvalue::CopyForDeref(place) => {
604-
let cplace = codegen_place(fx, place);
605-
let val = cplace.to_cvalue(fx);
606-
lval.write_cvalue(fx, val)
607-
}
608603
Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => {
609604
let place = codegen_place(fx, place);
610605
let ref_ = place.place_ref(fx, lval.layout());
@@ -928,6 +923,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
928923
let operand = codegen_operand(fx, operand);
929924
lval.write_cvalue_transmute(fx, operand);
930925
}
926+
Rvalue::CopyForDeref(_) => bug!("`CopyForDeref` in codegen"),
931927
}
932928
}
933929
StatementKind::StorageLive(_)

0 commit comments

Comments
 (0)