Rollup merge of #97077 - ouz-a:Optimize-backend, r=oli-obk
Simplify some code that depend on Deref Now that we can assume #97025 works, it's safe to expect Deref is always in the first place of projections. With this, I was able to simplify some code that depended on Deref's place in projections. When we are able to move Derefer before `ElaborateDrops` successfully we will be able to optimize more places. r? `@oli-obk`
This commit is contained in:
commit
29892759f6
3 changed files with 22 additions and 30 deletions
|
@ -435,18 +435,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
LocalRef::Place(place) => place,
|
||||
LocalRef::UnsizedPlace(place) => bx.load_operand(place).deref(cx),
|
||||
LocalRef::Operand(..) => {
|
||||
if let Some(elem) = place_ref
|
||||
.projection
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|elem| matches!(elem.1, mir::ProjectionElem::Deref))
|
||||
{
|
||||
base = elem.0 + 1;
|
||||
if place_ref.has_deref() {
|
||||
base = 1;
|
||||
let cg_base = self.codegen_consume(
|
||||
bx,
|
||||
mir::PlaceRef { projection: &place_ref.projection[..elem.0], ..place_ref },
|
||||
mir::PlaceRef { projection: &place_ref.projection[..0], ..place_ref },
|
||||
);
|
||||
|
||||
cg_base.deref(bx.cx())
|
||||
} else {
|
||||
bug!("using operand local {:?} as place", place_ref);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue