Skip to content

Work around LLVM issues with explicit register in inline asm #75014

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

Merged
merged 1 commit into from
Aug 17, 2020

Conversation

Amanieu
Copy link
Member

@Amanieu Amanieu commented Aug 1, 2020

Fixes #74658

@rust-highfive
Copy link
Contributor

r? @eddyb

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 1, 2020
Comment on lines +419 to +421
InlineAsmReg::X86(reg)
if reg as u32 >= X86InlineAsmReg::xmm0 as u32
&& reg as u32 <= X86InlineAsmReg::xmm15 as u32 =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
InlineAsmReg::X86(reg)
if reg as u32 >= X86InlineAsmReg::xmm0 as u32
&& reg as u32 <= X86InlineAsmReg::xmm15 as u32 =>
InlineAsmReg::X86(reg)
if RangeInclusive::new(X86InlineAsmReg::xmm0, X86InlineAsmReg::xmm15).contains(&reg) =>

Copy link
Member Author

Choose a reason for hiding this comment

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

Does RangeInclusive work on enums?

Copy link
Contributor

@tesuji tesuji Aug 1, 2020

Choose a reason for hiding this comment

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

If it is fieldless enum and implements PartialOrd and/or PartialEq I think.

Copy link
Member

Choose a reason for hiding this comment

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

You can just write (X86InlineAsmReg::xmm0..=X86InlineAsmReg::xmm15).contains(&reg), too.

@bors
Copy link
Collaborator

bors commented Aug 3, 2020

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

@eddyb
Copy link
Member

eddyb commented Aug 16, 2020

Looks fine I think, but I'd suggest avoiding waiting on reviews from me where possible.

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned eddyb Aug 16, 2020
@nagisa
Copy link
Member

nagisa commented Aug 16, 2020

This mentions LLVM issues and that this is a workaround. A couple of questions: is this really a LLVM issue (besides the fact that LLVM fires an assertion rather than diagnostic callback)? If so, is there a report upstream? If not, could this PR be retitled to something else (just so that it is easier to search for/understand in the future).

Otherwise @bors r+

@bors
Copy link
Collaborator

bors commented Aug 16, 2020

📌 Commit 9198e8a has been approved by nagisa

@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 16, 2020
@Amanieu
Copy link
Member Author

Amanieu commented Aug 16, 2020

I'm not sure it is a bug in LLVM but rather just LLVM being very picky about what types you can use with a particular register type. This PR adjusts the types in rustc to match what LLVM expects.

@bors
Copy link
Collaborator

bors commented Aug 17, 2020

⌛ Testing commit 9198e8a with merge 5f88bea...

@bors
Copy link
Collaborator

bors commented Aug 17, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: nagisa
Pushing 5f88bea to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 17, 2020
@bors bors merged commit 5f88bea into rust-lang:master Aug 17, 2020
@bors bors mentioned this pull request Aug 17, 2020
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault when using an ymm register as an out parameter in an asm! block.
7 participants