-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix -Z lower_128bit_ops handling of statics #46583
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
(hir::BodyOwnerKind::Static(_), _) => return, | ||
|
||
(hir::BodyOwnerKind::Fn, _) => { | ||
if tcx.is_const_fn(source.def_id) { |
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.
Does this mean i128 ops won't get lowered in const fns at all? As const fns can run at runtime as well, I figure they'd have to be lowered for the run time version even if const eval can handle them.
I think what should happen here is:
|
I'm not certain what I should do here. rkruppe is absolutely right that this PR is just changing an unsoundness to an incompleteness. (1) Getting the MIR for the lang items themselves seems insufficient, as I first tried (2) This sounds great, though I'm not sure where this pass would then run, since I figure |
@bors r+ |
📌 Commit 1b88022 has been approved by |
⌛ Testing commit 1b8802224370abea71de246d80a2859b40aacdf1 with merge ec06e86fd1f0a30f558e94af4e8771a9a08fe890... |
@bors r- retry I don't think this actually fixes things - now const fns will generate bad i128 ops when called in a non-constant context. |
I think the right way to fix it in the rust/src/librustc_trans/mir/constant.rs Lines 399 to 416 in 02b4d3d
by calling the appropriate binary op implementation if the function def-id matches, via an inverse of the
|
1b88022
to
413a495
Compare
Avoids ICEs such as the following: error: internal compiler error: src\librustc_metadata\cstore_impl.rs:131: get_optimized_mir: missing MIR for `DefId(8/0:40 ~ compiler_builtins[9532]::int[0]::addsub[0]::rust_i128_addo[0])`
413a495
to
4b95ca8
Compare
Ok, updated to special-case-translate these calls in const trans. The inverse lookup can be found here: https://github.com/rust-lang/rust/pull/46583/files#diff-823b4422fff3f3018e53dfb6dc0a1fb3R468 |
r? @eddyb - you know |
@bors r+ |
📌 Commit 4b95ca8 has been approved by |
Fix -Z lower_128bit_ops handling of statics Avoids ICEs such as the following: > error: internal compiler error: src\librustc_metadata\cstore_impl.rs:131: > get_optimized_mir: missing MIR for `DefId(8/0:40 ~ > compiler_builtins[9532]::int[0]::addsub[0]::rust_i128_addo[0])` r? @nagisa cc #45676 @est31
☀️ Test successful - status-appveyor, status-travis |
Avoids ICEs such as the following:
r? @nagisa
cc #45676 @est31