Skip to content

Commit 4e3df71

Browse files
committed
Remove special handling for drop glue.
1 parent 7c870f4 commit 4e3df71

1 file changed

Lines changed: 21 additions & 57 deletions

File tree

  • compiler/rustc_codegen_ssa/src/mir

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -537,35 +537,27 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
537537
})
538538
.collect::<Vec<_>>();
539539
if bx.tcx().sess.opts.unstable_opts.codegen_emit_retag.is_some() {
540-
if let ty::InstanceKind::DropGlue(_, _) | ty::InstanceKind::AsyncDropGlue(_, _) =
541-
fx.instance.def
542-
{
543-
// We need to special-case drop glue for now. The first argument is
544-
// a raw pointer, but it needs to be treated as if it were `&mut _`.
545-
args[0] = dropee_emit_retag(bx, fx, &args[0]);
546-
} else {
547-
args = args
548-
.iter()
549-
.map(|arg| match arg {
550-
&LocalRef::Place(place_ref) => {
551-
fx.codegen_retag_place(bx, place_ref, true);
552-
LocalRef::Place(place_ref)
553-
}
554-
&LocalRef::UnsizedPlace(place_ref) => {
555-
let operand = bx.load_operand(place_ref);
556-
let retagged = fx.codegen_retag_operand(bx, operand, true);
557-
assert!(matches!(retagged.val, OperandValue::Pair(_, _)));
558-
retagged.val.store(bx, place_ref);
559-
LocalRef::UnsizedPlace(place_ref)
560-
}
561-
&LocalRef::Operand(operand_ref) => {
562-
let retagged = fx.codegen_retag_operand(bx, operand_ref, true);
563-
LocalRef::Operand(retagged)
564-
}
565-
LocalRef::PendingOperand => LocalRef::PendingOperand,
566-
})
567-
.collect::<Vec<_>>();
568-
}
540+
args = args
541+
.iter()
542+
.map(|arg| match arg {
543+
&LocalRef::Place(place_ref) => {
544+
fx.codegen_retag_place(bx, place_ref, true);
545+
LocalRef::Place(place_ref)
546+
}
547+
&LocalRef::UnsizedPlace(place_ref) => {
548+
let operand = bx.load_operand(place_ref);
549+
let retagged = fx.codegen_retag_operand(bx, operand, true);
550+
assert!(matches!(retagged.val, OperandValue::Pair(_, _)));
551+
retagged.val.store(bx, place_ref);
552+
LocalRef::UnsizedPlace(place_ref)
553+
}
554+
&LocalRef::Operand(operand_ref) => {
555+
let retagged = fx.codegen_retag_operand(bx, operand_ref, true);
556+
LocalRef::Operand(retagged)
557+
}
558+
LocalRef::PendingOperand => LocalRef::PendingOperand,
559+
})
560+
.collect::<Vec<_>>();
569561
// If we branched during retagging, then we need to update the
570562
// start block to the new location.
571563
fx.cached_llbbs[mir::START_BLOCK] = CachedLlbb::Some(bx.llbb());
@@ -647,31 +639,3 @@ fn find_cold_blocks<'tcx>(
647639

648640
cold_blocks
649641
}
650-
651-
fn dropee_emit_retag<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
652-
bx: &mut Bx,
653-
fx: &mut FunctionCx<'a, 'tcx, Bx>,
654-
local: &LocalRef<'tcx, Bx::Value>,
655-
) -> LocalRef<'tcx, Bx::Value> {
656-
// We have `*mut _` as our first argument
657-
if let &LocalRef::Operand(OperandRef { val, layout, move_annotation }) = local {
658-
if layout.ty.is_raw_ptr()
659-
&& let Some(deref_ty) = layout.ty.builtin_deref(true)
660-
{
661-
// Create `&mut _`
662-
let lifetime = bx.tcx().lifetimes.re_erased;
663-
let subst_ty_kind = ty::Ref(lifetime, deref_ty, ty::Mutability::Mut);
664-
let subst_ty = bx.tcx().mk_ty_from_kind(subst_ty_kind);
665-
let subst_layout = bx.layout_of(subst_ty);
666-
667-
// We want the same operand value, but use the reference type for it.
668-
let operand_ref = OperandRef { val, layout: subst_layout, move_annotation };
669-
670-
let retagged = fx.codegen_retag_operand(bx, operand_ref, true);
671-
672-
// Return the retagged parameter, but use the original layout now.
673-
return LocalRef::Operand(OperandRef { val: retagged.val, layout, move_annotation });
674-
}
675-
}
676-
bug!("dropee isn't a raw pointer")
677-
}

0 commit comments

Comments
 (0)