Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uplibrustc_trans: function parameters should be annotated with zeroext/signext #30841
Comments
This comment has been minimized.
This comment has been minimized.
|
I don't think it's I'm curious if you have a PowerPC-specific example, as we don't add these for other platforms and it hasn't caused a problem there. Does PowerPC do something different that means it matters more here? |
Aatch
added
the
A-codegen
label
Jan 15, 2016
This comment has been minimized.
This comment has been minimized.
|
This came up while reviewing #30776. I haven't seen a specific issue, but @eefriedman pointed out that I wasn't modelling the PowerPC64 ABI completely. The test case in C was:
I'm not sure why x86_64 isn't annotating the LLVM IR with signext here. |
This comment has been minimized.
This comment has been minimized.
|
Well we're not annotating the parameters properly for any platform, which at least suggests that is relatively low priority in terms of actual problems caused. The reason being that most of the time you're calling out to C code that will itself only use the parts of the register for the size of the appropriate type. What I mean is that it doesn't matter if the value is sign- or zero-extended if code never actually relies on the extended portion of the value. Anyway, I think the PowerPC aspect here is a bit of a red herring and we should be annotating all parameters that need the annotations, |
antonblanchard
changed the title
librustc_trans: compute_abi_info() needs signedness info for PowerPC targets
librustc_trans: function parameters should be annotated with zeroext/signext
Jan 17, 2016
This comment has been minimized.
This comment has been minimized.
|
Agreed, changing the title to match. |
This comment has been minimized.
This comment has been minimized.
|
Ah, I just figured out/found out why PowerPC is a problem specifically. PowerPC apparently doesn't support 8-bit or 16-bit operations natively and therefore you can't tell it to just add (for example) together to lowest byte/word in each register. I'm surprised this hasn't caused any issues with calling out to C code, a quick test suggests that it could cause issues if you have a C function accepting signed bytes, Rust will just zero-extend them to the register size. This is on x86 too, so it's definitely a not a PPC-specific issue, and it actually much more serious than I first though. |
Aatch
added
I-nominated
T-compiler
labels
Jan 20, 2016
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium Good catch reporting this bug! This should definitely be fixed, but PowerPC is not a "tier 1" platform, so it's not a high priority (drop everything) sort of bug. |
rust-highfive
added
P-medium
and removed
I-nominated
labels
Jan 21, 2016
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis this does affect other platforms though. Clang will assume that I'm not disagreeing with the priority, I think medium is fine, just clarifying that this is a general FFI issue, not just a PPC issue. |
This comment has been minimized.
This comment has been minimized.
|
thanks for the clarification On Mon, Jan 25, 2016 at 08:37:23PM -0800, James Miller wrote:
|
Aatch
referenced this issue
Feb 1, 2016
Closed
ARM ABI Violation on extern function that returns u8 #31315
Aatch
self-assigned this
Feb 17, 2016
Aatch
referenced this issue
Feb 17, 2016
Closed
Add zeroext/signext attributes to C ABI functions where appropriate #31725
This comment has been minimized.
This comment has been minimized.
|
This seems fixed by #32732. |
antonblanchard commentedJan 12, 2016
type_of -> Type::uint_from_ty/Type::int_from_ty converts to LLVM types which have no sign. This is then passed to the architecture specific code in compute_abi_info().
PowerPC needs to know whether to sign or zero extend function call parameters, but it doesn't have enough information in the LLVM types.