-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
codegen_llvm: check inline assembly constraints with LLVM #54568
Conversation
LLVM provides a way of checking whether the constraints and the actual inline assembly make sense. This commit introduces a check before emitting code for the inline assembly. If LLVM rejects the inline assembly (or its constraints), then the compiler emits an error E0668 ("malformed inline assembly"). Signed-off-by: Levente Kurusa <lkurusa@acm.org>
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. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
r? @nagisa |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Travis passed finally 🎉 ! |
@levex please also add a few tests which would specifically test the functionality introduced by this PR. These tests would most likely end up going to |
Added three tests that right now (on |
@bors r+, thanks! |
@bors r+ |
📌 Commit 0991d20 has been approved by |
codegen_llvm: check inline assembly constraints with LLVM ---%<--- Hey all, As issue #54130 highlights, constraints are not checked and passing bad constraints to LLVM can crash it since a `Verify()` call is placed inside an assertion (see: `src/llvm/lib/IR/InlineAsm.cpp:39`). As this is my first PR to the Rust compiler (woot! 🎉), there might be better ways of achieving this result. In particular, I am not too happy about generating an error in codegen; it would be much nicer if we did it earlier. However, @rkruppe [noted on IRC](https://botbot.me/mozilla/rustc/2018-09-25/?msg=104791581&page=1) that this should be fine for an unstable feature and a much better solution than the _status quo_, which is an ICE. Thanks! --->%--- LLVM provides a way of checking whether the constraints and the actual inline assembly make sense. This commit introduces a check before emitting code for the inline assembly. If LLVM rejects the inline assembly (or its constraints), then the compiler emits an error E0668 ("malformed inline assembly"). Fixes: #54130 Signed-off-by: Levente Kurusa \<lkurusa@acm.org\>
☀️ Test successful - status-appveyor, status-travis |
codegen_llvm: verify that inline assembly operands are scalars Another set of inline assembly fixes. This time let's emit an error message when the operand value cannot be coerced into the operand constraint. Two questions: 1) Should I reuse `E0668` which was introduced in #54568 or just use `E0669` as it stands because they do mean different things, but maybe that's not too user-friendly. Just a thought. 2) The `try_fold` returns the operand which failed to be converted into a scalar value, any suggestions on how to use that in the error message? Thanks!
---%<---
Hey all,
As issue #54130 highlights, constraints are not checked and passing bad constraints to LLVM can crash it since a
Verify()
call is placed inside an assertion (see:src/llvm/lib/IR/InlineAsm.cpp:39
).As this is my first PR to the Rust compiler (woot! 🎉), there might be better ways of achieving this result. In particular, I am not too happy about generating an error in codegen; it would be much nicer if we did it earlier. However, @rkruppe noted on IRC that this should be fine for an unstable feature and a much better solution than the status quo, which is an ICE.
Thanks!
--->%---
LLVM provides a way of checking whether the constraints and the actual
inline assembly make sense. This commit introduces a check before
emitting code for the inline assembly. If LLVM rejects the inline
assembly (or its constraints), then the compiler emits an error E0668
("malformed inline assembly").
Fixes: #54130
Signed-off-by: Levente Kurusa <lkurusa@acm.org>