Skip to content
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

Implemente overflowing_sh* with new unchecked_sh* intrinsics #40521

Merged
merged 2 commits into from
Mar 20, 2017

Conversation

TimNN
Copy link
Contributor

@TimNN TimNN commented Mar 14, 2017

Also update some 128 bit builtins to not rely on the constant evaluator to avoid checked operations.

Fixes #40508.

cc @nagisa, @alexcrichton

Note: I still have a build running to see if the 128 bit changes worked (unoptimized builds take forever to compile), however at least the overflowing builtins no longer reference core::panicking::panic.

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -311,6 +311,8 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
} else {
bcx.urem(llargs[0], llargs[1])
},
"unchecked_shl" => bcx.shl(llargs[0], llargs[1]),
"unchecked_shr" => bcx.lshr(llargs[0], llargs[1]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be either ashr when types are signed or lshr when types are unsigned.

See for example the rustc_trans::common::build_unchecked_rshift (you can’t reuse it sadly, because it tries to ensure the validity of RHS).

#[cfg(not(stage0))]
pub fn overflowing_shl(self, rhs: u32) -> (Self, bool) {
(unsafe {
intrinsics::unchecked_shl(self, (rhs & ($BITS - 1)) as $SelfT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you’re already working around this code, it would be nice if you used this to implement wrapping_shl and used wrapping_shl to implement overflowing_shl instead of the inverse that we have today.

@@ -83,8 +83,8 @@ pub mod reimpls {
macro_rules! lshr {
($a: expr, $b: expr, $ty:ty) => {{
let (a, b) = ($a, $b);
let bits = (::core::mem::size_of::<$ty>() * 8) as $ty;
let half_bits = bits >> 1;
let bits = ::core::mem::size_of::<$ty>().overflowing_mul(8) as $ty;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/overflowing/wrapping/?

@nagisa
Copy link
Member

nagisa commented Mar 14, 2017

r=me

@alexcrichton
Copy link
Member

@bors r=nagisa delegate=nagisa

@bors
Copy link
Contributor

bors commented Mar 14, 2017

✌️ @nagisa can now approve this pull request

@bors
Copy link
Contributor

bors commented Mar 14, 2017

📌 Commit ceccedd has been approved by nagisa

@TimNN
Copy link
Contributor Author

TimNN commented Mar 14, 2017

I missed one of the i128 macros :(

Maybe leave this PR until tomorrow, I'll have a full unoptimized ARM build done by then to verify that actually all occurrences of panic are gone.

@TimNN
Copy link
Contributor Author

TimNN commented Mar 15, 2017

Good news! readelf no longer shows any references to panic. However run-pass/issue-28950.rs hanges somewhere, but I think that is a separate issue, so this is probably good to go to bors.

(The travis failure is about the mac bots being... broken.)

Do you want me to squash the commits?

@nagisa
Copy link
Member

nagisa commented Mar 15, 2017

Sure.

Also update some 128 bit builtins to be panic-free without relying
on the const evaluator.
@TimNN
Copy link
Contributor Author

TimNN commented Mar 15, 2017

Sure.

I assume this was regarding the squash? In that case: Done.

@nagisa
Copy link
Member

nagisa commented Mar 15, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Mar 15, 2017

📌 Commit cc23d17 has been approved by nagisa

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Implemente overflowing_sh* with new unchecked_sh* intrinsics

Also update some 128 bit builtins to not rely on the constant evaluator to avoid checked operations.

Fixes rust-lang#40508.

cc @nagisa, @alexcrichton

Note: I still have a build running to see if the 128 bit changes worked (unoptimized builds take *forever* to compile), however at least the overflowing builtins no longer reference `core::panicking::panic`.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Implemente overflowing_sh* with new unchecked_sh* intrinsics

Also update some 128 bit builtins to not rely on the constant evaluator to avoid checked operations.

Fixes rust-lang#40508.

cc @nagisa, @alexcrichton

Note: I still have a build running to see if the 128 bit changes worked (unoptimized builds take *forever* to compile), however at least the overflowing builtins no longer reference `core::panicking::panic`.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Implemente overflowing_sh* with new unchecked_sh* intrinsics

Also update some 128 bit builtins to not rely on the constant evaluator to avoid checked operations.

Fixes rust-lang#40508.

cc @nagisa, @alexcrichton

Note: I still have a build running to see if the 128 bit changes worked (unoptimized builds take *forever* to compile), however at least the overflowing builtins no longer reference `core::panicking::panic`.
@alexcrichton
Copy link
Member

@bors: r-

This is likely the cause of this failure, I think maybe the methods just need to be #[inline]?

@TimNN
Copy link
Contributor Author

TimNN commented Mar 18, 2017

I have added the additional inline attributes and verified that this fixes the issue for i686-gnu.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Mar 18, 2017

📌 Commit e16d286 has been approved by alexcrichton

arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 18, 2017
Implemente overflowing_sh* with new unchecked_sh* intrinsics

Also update some 128 bit builtins to not rely on the constant evaluator to avoid checked operations.

Fixes rust-lang#40508.

cc @nagisa, @alexcrichton

Note: I still have a build running to see if the 128 bit changes worked (unoptimized builds take *forever* to compile), however at least the overflowing builtins no longer reference `core::panicking::panic`.
bors added a commit that referenced this pull request Mar 18, 2017
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 19, 2017
Implemente overflowing_sh* with new unchecked_sh* intrinsics

Also update some 128 bit builtins to not rely on the constant evaluator to avoid checked operations.

Fixes rust-lang#40508.

cc @nagisa, @alexcrichton

Note: I still have a build running to see if the 128 bit changes worked (unoptimized builds take *forever* to compile), however at least the overflowing builtins no longer reference `core::panicking::panic`.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 20, 2017
Implemente overflowing_sh* with new unchecked_sh* intrinsics

Also update some 128 bit builtins to not rely on the constant evaluator to avoid checked operations.

Fixes rust-lang#40508.

cc @nagisa, @alexcrichton

Note: I still have a build running to see if the 128 bit changes worked (unoptimized builds take *forever* to compile), however at least the overflowing builtins no longer reference `core::panicking::panic`.
bors added a commit that referenced this pull request Mar 20, 2017
Rollup of 9 pull requests

- Successful merges: #40241, #40281, #40398, #40521, #40532, #40554, #40566, #40581, #40587
- Failed merges:
@bors bors merged commit e16d286 into rust-lang:master Mar 20, 2017
@TimNN TimNN deleted the panic-free-shift branch April 7, 2017 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants