-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Follow target ABI sign-/zero-extension rules for enum types #36321
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
While attempting to port Rust to s390x, I ran into an ABI violation (that caused rust_eh_personality to be miscompiled, breaking unwinding). The problem is that this function returns an enum type, which is supposed to be sign-extended according to the s390x ABI. However, common code would ignore target sign-/zero-extension rules for any types that do not satisfy is_integral(), which includes enums. For the general case of Rust enum types, which map to structure types with a discriminant, that seems correct. However, in the special case of simple enums that map directly to C enum types (i.e. LLVM integers), this is incorrect; we must follow the target extension rules for those. Signed-off-by: Ulrich Weigand <[email protected]>
@rust-highfive didn't assign a reviewer. Could we get someone familiar with the backend (@eddyb? 😄) to review this PR? |
if let ty::TyEnum(..) = ty.sty { | ||
if arg.ty.kind() == llvm::Integer { | ||
let repr = adt::represent_type(ccx, ty); | ||
arg.signedness = Some(adt::is_discr_signed(&repr)); |
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.
This should pattern-match on ccx.layout_of(ty)
(see librustc/ty/layout.rs
) instead of checking the LLVM type and then asking adt
(which is being phased out by #36151) for more information.
r? @eddyb |
@bors r+ Thanks! |
📌 Commit ce3cecf has been approved by |
⌛ Testing commit ce3cecf with merge 9d76bed... |
💔 Test failed - auto-win-gnu-32-opt-rustbuild |
@bors retry |
Follow target ABI sign-/zero-extension rules for enum types While attempting to port Rust to s390x, I ran into an ABI violation (that caused rust_eh_personality to be miscompiled, breaking unwinding). The problem is that this function returns an enum type, which is supposed to be sign-extended according to the s390x ABI. However, common code would ignore target sign-/zero-extension rules for any types that do not satisfy is_integral(), which includes enums. For the general case of Rust enum types, which map to structure types with a discriminant, that seems correct. However, in the special case of simple enums that map directly to C enum types (i.e. LLVM integers), this is incorrect; we must follow the target extension rules for those. Signed-off-by: Ulrich Weigand <[email protected]>
While attempting to port Rust to s390x, I ran into an ABI violation
(that caused rust_eh_personality to be miscompiled, breaking unwinding).
The problem is that this function returns an enum type, which is
supposed to be sign-extended according to the s390x ABI. However,
common code would ignore target sign-/zero-extension rules for any
types that do not satisfy is_integral(), which includes enums.
For the general case of Rust enum types, which map to structure types
with a discriminant, that seems correct. However, in the special case
of simple enums that map directly to C enum types (i.e. LLVM integers),
this is incorrect; we must follow the target extension rules for those.
Signed-off-by: Ulrich Weigand [email protected]