Skip to content

Commit 4183917

Browse files
authored
Merge pull request #498 from rust-lang/fix/pass-indirect-with-params
Fix PassMode::Indirect with params
2 parents 4a52f95 + f9a0c3f commit 4183917

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/abi.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use gccjit::{ToLValue, ToRValue, Type};
44
use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeMethods};
55
use rustc_data_structures::fx::FxHashSet;
66
use rustc_middle::bug;
7+
use rustc_middle::ty::layout::LayoutOf;
78
use rustc_middle::ty::Ty;
89
#[cfg(feature = "master")]
910
use rustc_session::config;
@@ -184,9 +185,17 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
184185
}
185186
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), on_stack } => {
186187
assert!(!on_stack);
187-
let ty =
188-
apply_attrs(cx.type_ptr_to(arg.memory_ty(cx)), &attrs, argument_tys.len());
189-
apply_attrs(ty, &meta_attrs, argument_tys.len())
188+
// Construct the type of a (wide) pointer to `ty`, and pass its two fields.
189+
// Any two ABI-compatible unsized types have the same metadata type and
190+
// moreover the same metadata value leads to the same dynamic size and
191+
// alignment, so this respects ABI compatibility.
192+
let ptr_ty = Ty::new_mut_ptr(cx.tcx, arg.layout.ty);
193+
let ptr_layout = cx.layout_of(ptr_ty);
194+
let typ1 = ptr_layout.scalar_pair_element_gcc_type(cx, 0);
195+
let typ2 = ptr_layout.scalar_pair_element_gcc_type(cx, 1);
196+
argument_tys.push(apply_attrs(typ1, &attrs, argument_tys.len()));
197+
argument_tys.push(apply_attrs(typ2, &meta_attrs, argument_tys.len()));
198+
continue;
190199
}
191200
};
192201
argument_tys.push(arg_ty);

tests/failing-ui-tests.txt

-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ tests/ui/coroutine/panic-safe.rs
4949
tests/ui/issues/issue-14875.rs
5050
tests/ui/issues/issue-29948.rs
5151
tests/ui/panics/nested_panic_caught.rs
52-
tests/ui/const_prop/ice-issue-111353.rs
5352
tests/ui/process/println-with-broken-pipe.rs
5453
tests/ui/lto/thin-lto-inlines2.rs
5554
tests/ui/lto/weak-works.rs
@@ -60,7 +59,6 @@ tests/ui/lto/msvc-imp-present.rs
6059
tests/ui/lto/lto-thin-rustc-loads-linker-plugin.rs
6160
tests/ui/lto/all-crates.rs
6261
tests/ui/async-await/deep-futures-are-freeze.rs
63-
tests/ui/closures/capture-unsized-by-ref.rs
6462
tests/ui/coroutine/resume-after-return.rs
6563
tests/ui/simd/masked-load-store.rs
6664
tests/ui/simd/repr_packed.rs

0 commit comments

Comments
 (0)