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

Emit more assumptions in trans #36962

Merged
merged 3 commits into from
Oct 6, 2016
Merged

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Oct 4, 2016

Perf numbers pending.

@arielb1
Copy link
Contributor Author

arielb1 commented Oct 4, 2016

r? @eddyb

Copy link
Member

@eddyb eddyb left a comment

Choose a reason for hiding this comment

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

Only one complaint, everything else LGTM. r=me after changing that, if you want to.

pub fn load_fat_ptr(b: &Builder, fat_ptr: ValueRef) -> (ValueRef, ValueRef) {
(b.load(get_dataptr(b, fat_ptr)), b.load(get_meta(b, fat_ptr)))
}

Copy link
Member

@eddyb eddyb Oct 4, 2016

Choose a reason for hiding this comment

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

I prefer moving things to MIR, not away from it, TBH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then non-MIR would have to call into it. I mostly want the load/store primitives all in one place.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, we'll move them when we get rid of all non-MIR code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH, I would prefer that everything will be done through OperandRef and be in 1 file. That would require some more refactoring through.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the current structure where rvalue/block/stmt/lvalue are rather independent of each-other, and all "utility" methods go into a different place.

@arielb1
Copy link
Contributor Author

arielb1 commented Oct 4, 2016

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Oct 4, 2016

📌 Commit 74447d8 has been approved by eddyb

@luqmana
Copy link
Member

luqmana commented Oct 4, 2016

So, I recall we held back on adding assume to a lot of places cause it slowed down LLVM a bit. I'm not sure how much more efficient that's become?

cc @dotdash

@arielb1
Copy link
Contributor Author

arielb1 commented Oct 4, 2016

C-enum-to-integer casts are not really a common codepath - through we should see that this doesn't hit some terrible O(n^2) case with serialization or something.

@bors
Copy link
Contributor

bors commented Oct 5, 2016

☔ The latest upstream changes (presumably #36958) made this pull request unmergeable. Please resolve the merge conflicts.

@arielb1
Copy link
Contributor Author

arielb1 commented Oct 5, 2016

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Oct 5, 2016

📌 Commit 45fe3a1 has been approved by eddyb

sophiajt pushed a commit to sophiajt/rust that referenced this pull request Oct 6, 2016
Emit more assumptions in trans

Perf numbers pending.
bors added a commit that referenced this pull request Oct 6, 2016
@bors bors merged commit 45fe3a1 into rust-lang:master Oct 6, 2016
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 1, 2020
Eliminate some other bound checks when index comes from an enum

rust-lang#36962 introduced an assumption for the upper limit of the enum's value. This PR adds an assumption to the lower value as well.

I've modified the original codegen test to show that derived (in that case, adding 1) values also don't generate bounds checks.

However, this test is actually carefully crafted to not hit a bug: if the enum's variants are modified to 1 and 2 instead of 2 and 3, the test fails by adding a bounds check. I suppose this is an LLVM issue and rust-lang#75525, while not exactly in this context should be tracking it.

I'm not at all confident if this patch can be accepted, or even if it _should_ be accepted in this state. But I'm curious about what others think :)

~Improves~ Should improve rust-lang#13926 but does not close it because it's not exactly predictable, where bounds checks may pop up against the assumptions.
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.

4 participants