Skip to content

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jan 23, 2021
1 parent c3367db commit fa12fdb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2736,13 +2736,14 @@ where
let arg_of = |ty: Ty<'tcx>, arg_idx: Option<usize>| {
let is_return = arg_idx.is_none();

let layout = cx.layout_of(ty);
let layout = if force_thin_self_ptr && arg_idx == Some(0) {
// Don't pass the vtable, it's not an argument of the virtual fn.
// Instead, pass just the data pointer, but give it the type `*const/mut dyn Trait`
// or `&/&mut dyn Trait` because this is special-cased elsewhere in codegen
make_thin_self_ptr(cx, cx.layout_of(ty))
make_thin_self_ptr(cx, layout)
} else {
cx.layout_of(ty)
layout
};

let mut arg = ArgAbi::new(cx, layout, |layout, scalar, offset| {
Expand Down Expand Up @@ -2842,11 +2843,9 @@ where
let max_by_val_size = Pointer.size(cx) * 2;
let size = arg.layout.size;

assert!(
matches!(arg.mode, PassMode::Indirect { on_stack: false, .. }),
"{:?}",
arg
);
let is_indirect_not_on_stack =
matches!(arg.mode, PassMode::Indirect { on_stack: false, .. });
assert!(is_indirect_not_on_stack, "{:?}", arg);
if !arg.layout.is_unsized() && size <= max_by_val_size {
// We want to pass small aggregates as immediates, but using
// a LLVM aggregate type for this leads to bad optimizations,
Expand Down

0 comments on commit fa12fdb

Please sign in to comment.