-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Use a C-safe return type for __rust_[ui]128_*
overflowing intrinsics
#134338
base: master
Are you sure you want to change the base?
Conversation
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
__rust_[ui]128_*
overflowing intrinsics__rust_[ui]128_*
overflowing intrinsics
Some changes occurred in compiler/rustc_codegen_gcc Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
For cranelift, is there a way to load the stack slot so it can be combined with the integer for a |
You can use |
b65b8e5
to
b976550
Compare
This comment has been minimized.
This comment has been minimized.
b976550
to
c2a51c9
Compare
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #134844) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -23,7 +23,8 @@ libloading = { version = "0.8.0", optional = true } | |||
smallvec = "1.8.1" | |||
|
|||
[patch.crates-io] | |||
# Uncomment to use local checkout of cranelift | |||
# todo: remove patch | |||
compiler_builtins = { git = "https://github.com/tgross35/compiler-builtins.git", package = "compiler_builtins", branch = "overflowing-c-safe-ret" } |
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 doesn't apply to building the sysroot. Also the patch in library/Cargo.toml should be enough to apply while building a sysroot for cg_clif.
source = "registry+https://github.com/rust-lang/crates.io-index" | ||
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" | ||
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" |
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 lockfile changes should be reverted.
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.
Yeah, the entire second commit is just for testing and will be dropped. My plan is once you approve the Cranelift changes and somebody from GCC has looked that portion over, I will merge rust-lang/compiler-builtins#735, drop the second commit (which add my crates-iopatch), replace it with a normal
compiler-builtins` bump, and then this PR's merge will change everything atomically.
However, I am stuck completing the current bump at #135180, so I will hold off until that gets fixed.
c2a51c9
to
7e67edf
Compare
__rust_[ui]128_*
overflowing intrinsics__rust_[ui]128_*
overflowing intrinsics
This comment has been minimized.
This comment has been minimized.
@rust-lang/wg-gcc-backend would one of you mind taking a look at the GCC changes? I am assuming that since this bump means the intrinsics are changing to get the same signature (type aside) as |
7e67edf
to
3c4707e
Compare
This comment has been minimized.
This comment has been minimized.
_ => unreachable!(), | ||
}, | ||
}; | ||
return self.operation_with_overflow(func_name, lhs, rhs); |
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.
From what I can see, this change doesn't look right as this will fall to calling self.overflow_call()
below which expects that the overflow flag is returned from the function call (like these GCC intrinsics) whereas your change seems to return the integer result and not the overflow flag.
My guess is that you'll need to keep this special handling and change the method operation_with_overflow
accordingly as these intrinsics are also used in src/intrinsic/mod.rs
.
AFAIK, the only related tests that run in this CI are those lines.
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.
Thanks for taking a look. Doesn't this block currently sometimes use __mulosi4
without an early turn? After the change to compiler_builtins
, __rust_*128_o
should be consistent with the __mulo*i4
functions.
AFAIK, the only related tests that run in this CI are those lines.
Is there any kind of codegen/asm test that should be added here? Or is the existing test sufficient once CI gets that far.
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.
Thanks for taking a look. Doesn't this block currently sometimes use
__mulosi4
without an early turn? After the change tocompiler_builtins
,__rust_*128_o
should be consistent with the__mulo*i4
functions.
Indeed, it looks like there might be a bug in here.
Is there any kind of codegen/asm test that should be added here? Or is the existing test sufficient once CI gets that far.
What do you mean? There's more tests that are ran in the repo of rustc_codegen_gcc itself.
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.
Indeed, it looks like there might be a bug in here.
I changed this so mulo
and the __rust
functions should now be taking the same codepath, still have to update the rest.
Is there any kind of codegen/asm test that should be added here? Or is the existing test sufficient once CI gets that far.
What do you mean? There's more tests that are ran in the repo of rustc_codegen_gcc itself.
I am just wondering whether I should add another test anywhere to verify the new behavior, especially if __mulosi4
may have been called incorrectly before. And if so, what format/location this should be (for LLVM I'd probably add a codegen test, but I'm not sure what the equivalent would be here).
This comment has been minimized.
This comment has been minimized.
@bjorn3 the is segfaulting at this line within
|
Actually that would be consistent with the return place before updating compiler-builtins, I wonder if the patched version isn't getting built for some reason. Edit: yeah, I never remember that the version number needs to be higher in order for patches to work... tests pass locally now. |
5c8b439
to
bd20c22
Compare
Combined with [1], this will change the overflowing multiplication operations to return an `extern "C"`-safe type. Link: rust-lang/compiler-builtins#735 [1]
bd20c22
to
b34e07a
Compare
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 cg_clif half LGTM. #135328 will have two minor conflicts with this PR though.
Combined with [1], this will change the overflowing multiplication operations to return an
extern "C"
-safe type.Link: rust-lang/compiler-builtins#735 [1]