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

Make to_immediate/from_immediate configurable by backends #76071

Merged
merged 2 commits into from
Sep 1, 2020

Conversation

khyperia
Copy link
Contributor

librustc_codegen_ssa has the concept of an immediate vs. memory type, and librustc_codegen_llvm uses this distinction to implement bools being i8 in memory, and i1 in immediate contexts. However, some of that implementation leaked into codegen_ssa when converting to/from immediate values. So, move those methods into builder traits, so that behavior can be configured by backends.

This is useful if a backend is able to keep bools as bools, or, needs to do more trickery than just bools to bytes.

(Note that there's already a large amount of things abstracted with "immediate types" - this is just bringing this particular thing in line to be abstracted as well)


Pinging @eddyb since that's who I was talking about this change with when they suggested I submit a PR.

librustc_codegen_ssa has the concept of an immediate vs. memory type,
and librustc_codegen_llvm uses this distinction to implement bools being
i8 in memory, and i1 in immediate contexts. However, some of that
implementation leaked into codegen_ssa when converting to/from immediate
values. So, move those methods into builder traits, so that behavior can
be configured by backends.

This is useful if a backend is able to keep bools as bools, or, needs to
do more trickery than just bools to bytes.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @davidtwco (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 29, 2020
@khyperia
Copy link
Contributor Author

Hmm. CI is failing, I'm guessing I screwed up the bit of code around // HACK(eddyb). The failure is:

Invalid bitcast
  %4 = bitcast i8 %0 to i1
in function _ZN4core3mem12maybe_uninit20MaybeUninit$LT$T$GT$11assume_init17h491aa6540b366902E

which seems to imply that the to_immediate failed to convert to bool, and then the bitcast is trying to go from i8->i1, instead of i1->i1. However, I'm not sure how that can be the case, so I'm pretty confused - I think I might need some help here.

I would try to debug it locally, but while ./x.py test gets a decent chunk into the build, it eventually fails with:

error: failed to prepare thin LTO module: Invalid cast (Producer: 'LLVM11.0.0-rust-dev' Reader: 'LLVM 11.0.0-rust-dev')

so I'm unable to debug the CI failure locally and figure out what's going on.

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.

r=me with the pair field access fixed

@davidtwco
Copy link
Member

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned davidtwco Aug 29, 2020
@eddyb
Copy link
Member

eddyb commented Aug 30, 2020

@bors r+ Thanks!

@bors
Copy link
Contributor

bors commented Aug 30, 2020

📌 Commit 1663bfb has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 30, 2020
@bors
Copy link
Contributor

bors commented Aug 30, 2020

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

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 30, 2020
@bors
Copy link
Contributor

bors commented Sep 1, 2020

⌛ Testing commit 1663bfb with merge 6f1bbf5...

@bors
Copy link
Contributor

bors commented Sep 1, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: eddyb
Pushing 6f1bbf5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 1, 2020
@bors bors merged commit 6f1bbf5 into rust-lang:master Sep 1, 2020
@khyperia khyperia deleted the configurable_to_immediate branch September 1, 2020 10:02
@cuviper cuviper added this to the 1.48.0 milestone Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants