-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Handle GCC's write-only inline asm constraint in liveness, borrowck and trans. #9850
Conversation
It looks to be that we have a section of constraints which are all dedicated to "output constraints", but it's possible to have an output constraint which isn't validated to be writable? It seems to me that we should merge all the constraints into one list (having Or is there a purpose for having an output constraint without an |
For the following C code: int main() {
short port = 0;
int val = 0;
asm("in %1, %0" : "a"(val) : "d"(port));
} GCC gives me this error:
while clang just fails validation, without a precise cause (but better location info than GCC): <stdin>:4:23: error: invalid output constraint 'a' in asm
asm("in %1, %0" : "a"(val) : "d"(port));}
^
1 error generated. We can follow the same rule, require '=' at the start of output constraints, and then remove all my |
&mut cleanups, | ||
callee::DontAutorefArg) | ||
}) | ||
let out_datum = unpack_datum!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be one line, no need to manually wrap. The max line length is 100 characters.
I've implemented analysis support for the [GCC '=' write-only inline asm constraint modifier](http://gcc.gnu.org/onlinedocs/gcc/Modifiers.html). I had more changes, for '+' (read+write) as well, but it turns out LLVM doesn't support '+' at all. I've removed the need for wrapping each output in ExprAddrOf, as that would require unwrapping almost everywhere and it was harder to reason about in borrowck than ExprAssign's LHS. With this change, rustc will treat (in respect to validity of accessing a local) code like this: ```rust let x: int; unsafe { asm!("mov $1, $0" : "=r"(x) : "r"(5u)); } ``` as if it were this: ```rust let x : int; x = 5; ``` Previously, the local was required to be both mutable and initialized, and the write effect wasn't recorded.
Preserve `ref` on `infallible_destructuring_match` suggestion Fixes rust-lang/rust-clippy#7499 changelog: [`infallible_destructuring_match`]: Preserve `ref` on suggestion
Don't filter out private items when completing paths in the same crate. Instead respect the `privateEditable` setting. Fixes rust-lang#9850
Don't filter out private items when completing paths in the same crate. Instead respect the `privateEditable` setting. Fixes rust-lang#9850
I've implemented analysis support for the GCC '=' write-only inline asm constraint modifier. I had more changes, for '+' (read+write) as well, but it turns out LLVM doesn't support '+' at all.
I've removed the need for wrapping each output in ExprAddrOf, as that would require unwrapping almost everywhere and it was harder to reason about in borrowck than ExprAssign's LHS.
With this change, rustc will treat (in respect to validity of accessing a local) code like this:
as if it were this:
Previously, the local was required to be both mutable and initialized, and the write effect wasn't recorded.