Follow target ABI sign-/zero-extension rules for enum types#36321
Merged
bors merged 2 commits intorust-lang:masterfrom Sep 9, 2016
Merged
Follow target ABI sign-/zero-extension rules for enum types#36321bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
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 <ulrich.weigand@de.ibm.com>
Contributor
|
@rust-highfive didn't assign a reviewer. Could we get someone familiar with the backend (@eddyb? 😄) to review this PR? |
src/librustc_trans/abi.rs
Outdated
| 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)); |
Member
There was a problem hiding this comment.
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.
Member
|
r? @eddyb |
Member
|
@bors r+ Thanks! |
Collaborator
|
📌 Commit ce3cecf has been approved by |
Collaborator
|
⌛ Testing commit ce3cecf with merge 9d76bed... |
Collaborator
|
💔 Test failed - auto-win-gnu-32-opt-rustbuild |
Contributor
|
@bors retry |
Collaborator
bors
added a commit
that referenced
this pull request
Sep 9, 2016
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 <ulrich.weigand@de.ibm.com>
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ulrich.weigand@de.ibm.com