rust/compiler/rustc_mir_transform/src
bors 59337cddd4 Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obk
CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility

This makes use of the `FnAbi` type in CTFE/Miri, which `@eddyb` has been saying for years is what we should do.^^ `FnAbi` is used to
- determine which arguments to skip (rather than the previous heuristic of skipping ZST arguments with the Rust ABI)
- impose further restrictions on whether caller and callee are consistent in how a given argument is passed

I was hoping it would also simplify the code, but that is not the case -- the previous type compatibility checks are still required (AFAIK), only the ZST skipping is gone and that took barely any code. We also need some hacks because `FnAbi` assumes a certain way of implementing `caller_location` (by passing extra arguments), but Miri can just read the caller location from the call stack so it doesn't need those arguments. (The fact that every backend has to separately implement support for these arguments seems suboptimal -- looks like this might have been better implemented on the MIR level.) To avoid having to implement those unnecessary arguments in Miri, we just compute *whether* the argument is present on the caller/callee side, but don't actually pass that argument around.

I have no idea if this looks the way `@eddyb` thinks it should look... but it makes Miri's test suite pass. ;)
One of rustc's tests fails unfortunately (`ui/const-generics/issues/issue-67739.rs`), some const generic code that is evaluated too early -- I think that should raise `TooGeneric` but instead it ICEs. My assumption is this is some FnAbi code that has not been properly tested on polymorphic code, but it might also be me calling that FnAbi code the wrong way.

r? `@oli-obk` `@eddyb`
Fixes https://github.com/rust-lang/rust/issues/56166
Miri PR at https://github.com/rust-lang/miri/pull/1928
2021-12-24 04:59:05 +00:00
..
coverage fix clippy::single_char_pattern perf findings 2021-12-14 12:40:28 +01:00
inline Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
abort_unwinding_calls.rs Treat drop_in_place as nounwind with -Z panic-in-drop=abort 2021-09-10 14:18:15 +01:00
add_call_guards.rs Move rustc_mir::transform to rustc_mir_transform. 2021-09-07 00:43:14 +02:00
add_moves_for_packed_drops.rs Move the dataflow framework to its own crate. 2021-09-07 19:57:07 +02:00
add_retag.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
check_const_item_mutation.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
check_packed_ref.rs give more help in the unaligned_references lint 2021-12-09 16:48:51 -05:00
check_unsafety.rs Store a DefId instead of an AdtDef in AggregateKind::Adt 2021-12-22 14:36:34 -05:00
cleanup_post_borrowck.rs Move rustc_mir::transform to rustc_mir_transform. 2021-09-07 00:43:14 +02:00
const_debuginfo.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
const_goto.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
const_prop.rs CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility 2021-12-20 22:37:12 +01:00
deaggregator.rs Move rustc_mir::transform to rustc_mir_transform. 2021-09-07 00:43:14 +02:00
deduplicate_blocks.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
dest_prop.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
dump_mir.rs Inline on_mir_pass and add inline to dump_mir 2021-10-14 15:26:59 -05:00
early_otherwise_branch.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
elaborate_drops.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
function_item_references.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
generator.rs Store a DefId instead of an AdtDef in AggregateKind::Adt 2021-12-22 14:36:34 -05:00
inline.rs Remove PartialOrd and Ord from LocalDefId 2021-12-22 10:50:57 -06:00
instcombine.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
lib.rs Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
lower_intrinsics.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
lower_slice_len.rs Update passes with new interface 2021-12-02 17:31:38 -08:00
marker.rs Add pass for simple phase change 2021-12-02 17:31:38 -08:00
match_branches.rs Update passes with new interface 2021-12-02 17:31:38 -08:00
multiple_return_terminators.rs Update passes with new interface 2021-12-02 17:31:38 -08:00
normalize_array_len.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
nrvo.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
pass_manager.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
remove_false_edges.rs Separate RemoveFalseEdges from SimplifyBranches 2021-11-30 17:14:48 -08:00
remove_noop_landing_pads.rs Update passes with new interface 2021-12-02 17:31:38 -08:00
remove_storage_markers.rs Update passes with new interface 2021-12-02 17:31:38 -08:00
remove_uninit_drops.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
remove_unneeded_drops.rs Add rationale for RemoveUnneededDrops 2021-11-30 17:25:30 -08:00
remove_zsts.rs Update passes with new interface 2021-12-02 17:31:38 -08:00
required_consts.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
reveal_all.rs use try_normalize_erasing_regions in RevealAllVisitor 2021-12-13 23:13:24 +01:00
separate_const_switch.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
shim.rs Store a DefId instead of an AdtDef in AggregateKind::Adt 2021-12-22 14:36:34 -05:00
simplify_branches.rs Auto merge of #91279 - scottmcm:small-refactor, r=nagisa 2021-12-06 13:04:18 +00:00
simplify_comparison_integral.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
simplify_try.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
simplify.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
uninhabited_enum_branching.rs Update passes with new interface 2021-12-02 17:31:38 -08:00
unreachable_prop.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00