Skip to content

Fix a bug in inline assembly llvm IR generation #23466

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 2 commits into from
Mar 24, 2015
Merged

Fix a bug in inline assembly llvm IR generation #23466

merged 2 commits into from
Mar 24, 2015

Conversation

woehr
Copy link
Contributor

@woehr woehr commented Mar 18, 2015

This fixes a bug in LLVM IR generation for in-line assembly where Rust would always use the host clobbers instead of target clobbers.

I also took this opportunity to clean/simplify the trans_inline_asm function.

This is my first Rust pull request; please let me know if I'm missing anything.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (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. 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 CONTRIBUTING.md for more information.

@richo
Copy link
Contributor

richo commented Mar 18, 2015

Great first pr!!

(Haven't read diff properly and can't r+, just wanted to thank and welcome)

On Tuesday, March 17, 2015, Jordan Woehr [email protected] wrote:

This fixes a bug in LLVM IR generation for in-line assembly where Rust
would always use the host clobbers instead of target clobbers.

I also took this opportunity to clean/simplify the trans_inline_asm
function.

This is my first Rust pull request; please let me know if I'm missing

anything.

You can view, comment on, or merge this pull request online at:

#23466
Commit Summary

  • Fix a bug in inline assembly codegen where host clobbers were always
    used regardless of target

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#23466.

}
let clobbers = ia.clobbers.iter()
.map(|s| format!("~{{{}}}", &s))
.collect::<Vec<String>>();
Copy link
Member

Choose a reason for hiding this comment

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

I suspect this collect may be unnecessary, and .chain(clobbers.into_iter()) below can become .chain(clobbers).

@woehr
Copy link
Contributor Author

woehr commented Mar 23, 2015

I addressed the unnecessary vector creation that @huonw pointed out. In doing so I now realize I accidentally changed an into_iter to an iter so I'd like to ask, is there a preference to which is used over vectors in this case?

@alexcrichton
Copy link
Member

is there a preference to which is used over vectors in this case?

It largely depends on the use case at hand (whether you want to transfer ownership or not) so there's not really a hard-and-fast convention on which to prefer. For small cases like this it's generally whichever works out best!

@bors: r+ b92fee9

Thanks!

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Mar 23, 2015
This fixes a bug in LLVM IR generation for in-line assembly where Rust would always use the host clobbers instead of target clobbers.

I also took this opportunity to clean/simplify the ```trans_inline_asm``` function.

This is my first Rust pull request; please let me know if I'm missing anything.
@bors bors merged commit b92fee9 into rust-lang:master Mar 24, 2015
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.

7 participants