-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For enums with ScalarPair ABI, some variants have Aggregate ABI #96221
Comments
The reason is this part: Layout {
fields: Arbitrary {
offsets: [
Size { raw: 8 },
],
memory_index: [
0,
],
},
abi: Aggregate {
sized: true,
}, i.e. the variant has a single field at offset If you could manually inject padding at the start of a regular |
@eddyb I certainly would not expect this to have With the current situation, how do you propose Miri handles a situation like the following? (I have no idea how this is not a problem in codegen either.)
Usually, to access a field of a type with immediate pair representation, we need the information from the
|
An alternative fix suggested by @eddyb would be to not support However, if we want to be able to check that an operand is valid at its type, then we have to be able to downcast operands. I am not sure how we could avoid this. Basically operands should be closed under "looking into" the value and taking it apart -- that seems like a sensible requirement IMO, but is not possible to uphold with our current enum layouts. |
I do not particularly prefer the current situation with codegen, I only brought it up as an explanation for why it's generally unaffected by such inconsistencies. It would IMO be preferable to have discriminant reads/writes and downcasts (and, eventually, field writes, not just reads) working in codegen on scalars (and pairs thereof). So definitely don't limit/deoptimize miri on my account, though in specific details I'm not necessarily sure what the best course for action is. That said, keeping the One could argue it's akin to the Taking this further, where the But that last part is just speculation, and it wouldn't come in handy until variants get user-exposed types (e.g. |
I noticed this while working on #96185: I added the following sanity check in Miri's
operand_downcast
:This assertion indeed fails. When downcasting
std::option::Option<*mut std::ffi::c_void>
to variant 1, the ABI changes fromScalarPair
toAggegreate
.Cc @oli-obk @erikdesjardins
The text was updated successfully, but these errors were encountered: