Repository navigation
Conversation
|
|
|
is this worth a stable/beta backport? |
Nominating just in case. |
39167e7 to
61f40b0
Compare
|
beta backport approved as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them. |
|
stable backport approved as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them. |
|
I have approved the backports without this PR being yet properly reviewed and merged (sorryu about that) r? compiler |
|
A random reroll here is likely unhelpful, ABI handling experts are scarce. I'll ask in the private channel. I'll do a review pass as well. |
There was a problem hiding this comment.
Change itself looks right to me, at least from what I can gather. Some non-blocking nits.
@rustbot author
| // ZERO/SIGN-EXTENDING TO 32 BITS NON-EXTENDING | ||
| // ============================== ======================= | ||
| // x86_64: void @c_arg_bool(i1 zeroext %_a) |
There was a problem hiding this comment.
I also noticed that because of how the test is written, if codegen starts adding a zeroext on a return type where it is wrong to do so, the test will pass anyway.
Yeah, that seems a bit awkward since it defeats the purpose of the return checks...
For the non-extending return check cases, can we instead match via patterns such as
// x86_64-linux: define {{(dso_local )?}}i1 @c_ret_bool()That way if the return type gets a zeroext this check should fail. Using this pattern against the uefi one (where it does zeroext) indeed fails to match.
(This is not blocking; I think we can also do this as a follow-up, since this is pre-existing.)
There was a problem hiding this comment.
Assuming we have the option to pass FileCheck arguments, you could also use something like --implicit-check-not=zeroext --implicit-check-not=signext.
There was a problem hiding this comment.
Hm yeah. I'm not sure using the implicit flags is much better though, that also seems not very straightforward when looking at the actual diff right?
61f40b0 to
3d42c2c
Compare
| // Always extend bool returns, x86_64 psABI requires that on the ABI the top 7 bits are zero | ||
| // https://github.com/llvm/llvm-project/issues/12579#issuecomment-2718032943 |
There was a problem hiding this comment.
| // Always extend bool returns, x86_64 psABI requires that on the ABI the top 7 bits are zero | |
| // https://github.com/llvm/llvm-project/issues/12579#issuecomment-2718032943 | |
| // The x86_64 psABI requires bools to be zero-extended to 8-bits, with high bits unspecified. | |
| // zeroext i1 has this behavior in the LLVM X86 backend. |
I don't think the comment linked here is super relevant, it's talking about a mismatch in how arguments are handled, where Clang/LLVM apply too much extension.
I also think it's worth mentioning here that using zeroext here for partial extension is correct due to special handling in the X86 backend (which is noteworthy because the same wouldn't be true for the AArch64 backend).
I think it would also be good to make the bool case separate and call arg.extend_integer_width(8) for it. The bit width effectively gets ignored right now (as long as it's larger than the bit width we're starting with), but I think it's confusing to have the extend_integer_width_to(32) when it's not actually extending to 32 bits.
There was a problem hiding this comment.
I agree. The only hitch is that required updating the implementation of extend_integer_width_to.
|
r? @nikic |
3d42c2c to
a0f1885
Compare
I think this fixes #163911
Though the test here is a bit hard to figure out, I'm not sure under what conditions expectation goes in the left or the right column. Do I decide that per-target or per-instance? Because x86_64 seems obligated to extend bool returns, so whether it is a "target that extends" or not depends on the type we're dealing with.
I also noticed that because of how the test is written, if codegen starts adding a
zeroexton a return type where it is wrong to do so, the test will pass anyway.