Conversation
a7acb1a to
b8945d8
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
The first commit does both mechanical refactorings and non-refactoring changes together. Would you mind splitting the variable renamings and outlining into a separate commit to make it easier to review? For the second commit it might also be nice to move file renamings (+ minor adjustments) into a commit separate from new tests and wholesale replacements of existing tests. |
Moves the DropGlue, virtual call, VTableShim, and closure-like transformations in transform_instance into the transform_drop_glue, transform_virtual_call, transform_vtable_shim, and transform_closure_like functions, and renames variables for consistency (e.g., invoke_ty to self_ty).
Changes transform_instance to cover each InstanceKind (and ShimKind) explicitly, similarly to how encoding is done, so the intent is expressed clearly and it is known when an instance is handled (or not) and the side effects of it (also clearly), instead of relying on fallthrough behavior. This also makes adding a new InstanceKind (or ShimKind) result in a compile-time error until it is explicitly handled.
Moves the CFI and KCFI UI tests that are at the top level into the cfi and kcfi directories (removing the now redundant kcfi- prefix from their names), and renames the regression tests to <topic>-issue-<number> (removing their entries from issues.txt accordingly, and adding the missing regression test description to reveal-opaques-issue-114160.rs).
Reorganizes the CFI and KCFI UI tests under the cfi and kcfi directories similarly to how the CFI codegen tests are organized: each test now tests a type or a language construct or feature that is handled by the CFI and KCFI transform or encoding, with complete coverage of what can be exercised at run time, and is named works-with-<type-construct-or-feature>, and tests that covered both CFI and KCFI using revisions are split into separate tests. It also adds tests for the types, language constructs, and features that were not covered (i.e., intrinsics, thread locals, builtin Clone and FnPtr implementations, pattern types, the never type, extern types, C variadics, and the generalize-pointers and normalize-integers options), removes the tests that became redundant, and changes the drop tests to run-pass, as they now pass at run time. Tests for flags/options and the regression tests are unchanged (moved and renamed in the previous commit).
Done. For whenever you have time. Thank you! |
| // wide. All platforms we currently support have a C platform, and as a | ||
| // consequence, isize/usize are at least 16-bit wide for all of them. | ||
| // wide. All platforms that Rust currently supports have a C platform, and as | ||
| // a consequence, isize/usize are at least 16-bit wide for all of them. |
There was a problem hiding this comment.
isize/usize are also guaranteed to be at least 16bit given that we have From<u16> for usize and From<i16> for isize
| /// E.g.: | ||
| /// | ||
| /// ```ignore (illustrative) | ||
| /// // The closure is transformed into <dyn Fn(i32) as Fn<(i32,)>>::call. |
There was a problem hiding this comment.
Maybe use Fn(i32) in both cases or Fn<(i32,)> in both cases. Fn(i32) is just a stable alias for the unstable Fn<(i32,)>.
| /// Adjust the type ids of DropGlues | ||
| /// Adjusts the type ids of DropGlues to a synthesized Drop trait object. | ||
| /// | ||
| /// DropGlues may have indirect calls to one or more given types drop function. Rust allows for |
There was a problem hiding this comment.
| /// DropGlues may have indirect calls to one or more given types drop function. Rust allows for | |
| /// DropGlues may have indirect calls to one or more given types' drop function. Rust allows for |
| /// ``` | ||
| /// | ||
| /// FIXME(rcvalle): This allows a drop call on any trait object to call the drop function of any | ||
| /// other type. |
There was a problem hiding this comment.
Curious how C++ handles this. Is the assumption there just that there is no super class with virtual destructor shared across a ton of different classes?
| // (i.e., fn items with extern "unadjusted"): intrinsics do not have their own callable MIR | ||
| // (i.e., calls to them are lowered by codegen) and can not be reified or called | ||
| // indirectly, so they are not transformed (i.e., type ids are encoded for them as is). | ||
| ty::InstanceKind::Intrinsic(..) | ty::InstanceKind::LlvmIntrinsic(..) => instance, |
There was a problem hiding this comment.
#[rustc_intrinsic] can nowadays have a default implementation to be used when a codegen backend doesn't have a builtin implementation. This however would result in InstanceKind::Item rather than InstanceKind::Intrinsic. Maybe update the comment to explain that the fallback body of an intrinsic would use InstanceKind::Item?
| // ThreadLocalShims (i.e., compiler-generated accessors for thread locals): do not | ||
| // implement any trait method and can not be called through a vtable, so they are not | ||
| // transformed (i.e., type ids are encoded for them as is). | ||
| ty::InstanceKind::Shim(ty::ShimKind::ThreadLocal(..)) => instance, |
There was a problem hiding this comment.
ThreadLocalShims shouldn't be called through function pointers at all I believe.
|
I've now reviewed all the compiler side changes. I will leave reviewing the test suite refactor for later. Edit: Reviewed first test commit, LGTM. The second test commit is huge though. |
|
☔ The latest upstream changes (presumably #162907) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
r? @bjorn3