-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[MIR] Implement as
casting (Misc cast kind)
#30586
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
Conversation
r? @Aatch (rust_highfive has picked a reviewer for you, use r? to override) |
r? @arielb1 |
&format!("unsupported cast: {:?} to {:?}", operand.ty, cast_ty) | ||
) | ||
}; | ||
OperandValue::Immediate(newval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if assuming everything is immediate here is correct, but I can’t think of a case where it could be something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful of fat pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the cast cases written out above would handle or produce fat pointers. I’m more concerned with Ref
vs Immediate
. I.e. can Misc
branch be reached with a OperandValue::Ref
for castee.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The discriminant of an OperandValue
is supposed to be a function of the operand's type.
r+ if you add fat-pointer-to-thin-pointer and fat-pointer-to-fat-pointer casts. |
I added preliminary impl of misc casts from fat-ptr, but I have little idea if it is correct. E.g. currently fat-ptr → fat-ptr is just a no-op, but only because I couldn’t think of a valid fat-ptr → fat-ptr cast which would change LLVM type of the fat-ptr. EDIT: people on IRC helped me to find such a case which resulted in updated PR |
Ah well, I also want a test that identity casts work (e.g. |
It's a separate bug. @bors r+ |
📌 Commit feab2ae has been approved by |
I think that should pretty much conclude all of #29576.
I think that should pretty much conclude all of #29576.