-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Refine instruction_set
MIR inline rules
#104121
Refine instruction_set
MIR inline rules
#104121
Conversation
r? @fee1-dead (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
The tests failed because of checking the exact output of the MIR inliner, but I don't know enough about how the test system works to know what I should be changing there. |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 0657585894a4f443d39ecd23fe5f5c1998bd9edf with merge ae9bb307e7ad590270685e7f486cbfba1ca5a7d9... |
This comment has been minimized.
This comment has been minimized.
@Lokathor you can run |
was really hoping i wouldn't have to clone the repo :( |
Alright I'm trying to update the test to match the new compatibility definition, and I'm not even clear what the test is trying to do in the first place. Should each type of test function just try to call each other type of function, and then we're just going to bless whatever the MIR that comes out is? Or like... what's being asserted? |
On advice of the dark-arts channel I just updated the test comments and blessed the new output without changing the test code at all. |
I nominated for language team to confirm that:
(One consequence of that choice is that functions with inline assembly cannot rely on the target default being used, so they should specify the instruction set) |
Just based on the comments in the file I touched, it looks possible to restrict the inline based on the content of the callee's body after the attribute check passes, though I personally don't know how to actually check for inline asm in the body and pass/fail based on that. Someone else might have to do that part. I'll say that it's possible to write asm that's safe to mix between both instruction sets, and I've actually got code like that in the EDIT: actually, on CPUs that do interworking, inline asm in a library function is kinda dangerous already unless steps are taken to offset the danger. If code is written assuming an arm target and it sets |
I think an alternative interpretation is that there cannot be "negative" instruction set annotations (ie ones that shrink the set of permitted instructions), only "positive" ones |
I don't quite understand what you're saying there. t32 has less possible instructions than a32. Actually it is more precise to say it has less possible mnemonics, because those mnemonics are encoded totally differently. So in terms of the actual physical binary encoding there is a 0% overlap between the two. EDIT: also, the |
Rerolling, as I don't know about r? compiler |
Oh, I had misunderstood this. I am somewhat surprised by the suggested semantics tbh, I would've expected no instruction set to mean the target default. Guess we'll see what T-lang has to say |
That's the current semantics, but that makes performance tank and makes basically all code in other crates unusable, an example of this is shown in the zulip thread. |
Under the proposed semantics, is it possible to write a correct inline asm block in a function that does not have an instruction set attribute? |
It is possible. The main difference is that with t32 you can't use I'm going to preemptively guess what you're gonna say next and say that we should inspect the function body of no-attribute functions and block their MIR inline if an asm block is detected in the body. But I don't know to do that specifically. So if someone could tell me, or just put in a PR to my branch that makes that happen, it would be appreciated. EDIT: for an example of inline asm that's actually specifically intended to work perfectly fine in both instruction sets: https://docs.rs/gba/0.10.0/src/gba/gba_cell.rs.html#97-133, and in this example it actually must be inline asm that's used rather than any intrinsic because LLVM's current handling of atomics on old embedded platforms is "very poor". |
Could you also squash the commits? |
I could squash them if you tell me exactly what to type into the terminal to make that happen. Every time I've ever tried to do anything with git other than commit and push i break it. |
|
I did that and a bunch of stuff pulled and tidy ran again and github didn't change. So someone tried to help me solve it and there wasn't a remote origin set anymore, so I set that and now I'm on the wrong branch?
So I'm not sure if I should do the thing it's suggesting I do, but it sounds dangerous so I figured I'd ask first. I'm perhaps the worst at git out of all Rust contributors. |
That command is harmless and correct, but you should check that your commits look alright first I guess |
This... doesn't look right. |
There have been 1851 new commits since your last push, so that seems exactly right if you squashed all commits into one. |
I did that push command and git said everything worked but the PR isn't showing any change. |
Don't we have bors squash? https://bors.rust-lang.org/ indicates we do, or is it not a command that actually works. |
Previously an exact match of the `instruction_set` attribute was required for an MIR inline to be considered. This change checks for an exact match *only* if the callee sets an `instruction_set` in the first place. When the callee does not declare an instruction set then it is considered to be platform agnostic code and it's allowed to be inline'd into the caller.
71cd243
to
ea47943
Compare
@bors r+ |
…set-missing-on-callee, r=tmiasko Refine `instruction_set` MIR inline rules Previously an exact match of the `instruction_set` attribute was required for an MIR inline to be considered. This change checks for an exact match *only* if the callee sets an `instruction_set` in the first place. When the callee does not declare an instruction set then it is considered to be platform agnostic code and it's allowed to be inline'd into the caller. cc `@oli-obk` [Edit] Zulip Context: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/What.20exactly.20does.20the.20MIR.20optimizer.20do.3F
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#104121 (Refine `instruction_set` MIR inline rules) - rust-lang#104675 (Unsupported query error now specifies if its unsupported for local or external crate) - rust-lang#104839 (improve array_from_fn documenation) - rust-lang#104880 ([llvm-wrapper] adapt for LLVM API change) - rust-lang#104899 (rustdoc: remove no-op CSS `#help dt { display: block }`) - rust-lang#104906 (Remove AscribeUserTypeCx) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Previously an exact match of the
instruction_set
attribute was required for an MIR inline to be considered. This change checks for an exact match only if the callee sets aninstruction_set
in the first place. When the callee does not declare an instruction set then it is considered to be platform agnostic code and it's allowed to be inline'd into the caller.cc @oli-obk
[Edit] Zulip Context: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/What.20exactly.20does.20the.20MIR.20optimizer.20do.3F