about summary refs log tree commit diff
path: root/src/tools
AgeCommit message (Collapse)AuthorLines
2023-08-08feat: `riscv-interrupt-{m,s}` calling conventionsSeth Pellegrino-0/+2
Similar to prior support added for the mips430, avr, and x86 targets this change implements the rough equivalent of clang's [`__attribute__((interrupt))`][clang-attr] for riscv targets, enabling e.g. ```rust static mut CNT: usize = 0; pub extern "riscv-interrupt-m" fn isr_m() { unsafe { CNT += 1; } } ``` to produce highly effective assembly like: ```asm pub extern "riscv-interrupt-m" fn isr_m() { 420003a0: 1141 addi sp,sp,-16 unsafe { CNT += 1; 420003a2: c62a sw a0,12(sp) 420003a4: c42e sw a1,8(sp) 420003a6: 3fc80537 lui a0,0x3fc80 420003aa: 63c52583 lw a1,1596(a0) # 3fc8063c <_ZN12esp_riscv_rt3CNT17hcec3e3a214887d53E.0> 420003ae: 0585 addi a1,a1,1 420003b0: 62b52e23 sw a1,1596(a0) } } 420003b4: 4532 lw a0,12(sp) 420003b6: 45a2 lw a1,8(sp) 420003b8: 0141 addi sp,sp,16 420003ba: 30200073 mret ``` (disassembly via `riscv64-unknown-elf-objdump -C -S --disassemble ./esp32c3-hal/target/riscv32imc-unknown-none-elf/release/examples/gpio_interrupt`) This outcome is superior to hand-coded interrupt routines which, lacking visibility into any non-assembly body of the interrupt handler, have to be very conservative and save the [entire CPU state to the stack frame][full-frame-save]. By instead asking LLVM to only save the registers that it uses, we defer the decision to the tool with the best context: it can more accurately account for the cost of spills if it knows that every additional register used is already at the cost of an implicit spill. At the LLVM level, this is apparently [implemented by] marking every register as "[callee-save]," matching the semantics of an interrupt handler nicely (it has to leave the CPU state just as it found it after its `{m|s}ret`). This approach is not suitable for every interrupt handler, as it makes no attempt to e.g. save the state in a user-accessible stack frame. For a full discussion of those challenges and tradeoffs, please refer to [the interrupt calling conventions RFC][rfc]. Inside rustc, this implementation differs from prior art because LLVM does not expose the "all-saved" function flavor as a calling convention directly, instead preferring to use an attribute that allows for differentiating between "machine-mode" and "superivsor-mode" interrupts. Finally, some effort has been made to guide those who may not yet be aware of the differences between machine-mode and supervisor-mode interrupts as to why no `riscv-interrupt` calling convention is exposed through rustc, and similarly for why `riscv-interrupt-u` makes no appearance (as it would complicate future LLVM upgrades). [clang-attr]: https://clang.llvm.org/docs/AttributeReference.html#interrupt-risc-v [full-frame-save]: https://github.com/esp-rs/esp-riscv-rt/blob/9281af2ecffe13e40992917316f36920c26acaf3/src/lib.rs#L440-L469 [implemented by]: https://github.com/llvm/llvm-project/blob/b7fb2a3fec7c187d58a6d338ab512d9173bca987/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp#L61-L67 [callee-save]: https://github.com/llvm/llvm-project/blob/973f1fe7a8591c7af148e573491ab68cc15b6ecf/llvm/lib/Target/RISCV/RISCVCallingConv.td#L30-L37 [rfc]: https://github.com/rust-lang/rfcs/pull/3246
2023-08-08Rollup merge of #114596 - Kobzol:opt-dist-host, r=lqdMatthias Krüger-5/+5
Rename method in `opt-dist` This makes it clearer that the LLVM is the host one (it doesn't necessarily have to be downloaded). On Linux, it comes from the Dockerfile, on Windows it's downloaded. Suggested here: https://github.com/rust-lang/rust/pull/114344#discussion_r1285596217 r? `@lqd`
2023-08-08Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, ↵Matthias Krüger-3/+3
r=oli-obk Store the laziness of type aliases in their `DefKind` Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not. With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*: Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates. As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions. --- This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
2023-08-07Rename method in `opt-dist`Jakub Beránek-5/+5
This makes it clearer that the LLVM is the host one (it doesn't necessarily have to be downloaded).
2023-08-07Auto merge of #114344 - Kobzol:opt-dist-llvm-profdata, r=nikicbors-11/+23
Use the correct `llvm-profdata` binary in `opt-dist` Turns out that we were probably using the wrong `llvm-profdata` binary in the PGO script all along. This should resolve the performance regressions of switching the host LLVM to 17 ([host `llvm-profdata`](https://github.com/rust-lang/rust/pull/114297#issuecomment-1660521361), [target `llvm-profdata`](https://github.com/rust-lang/rust/pull/114297#issuecomment-1661127032)]). r? `@nikic`
2023-08-07Rollup merge of #114570 - ttsugriy:miri-vc-typo, r=RalfJungMatthias Krüger-1/+1
[miri][typo] Fix a typo in a vector_block comment.
2023-08-07Rollup merge of #114562 - Trolldemorted:thiscall, r=oli-obkMatthias Krüger-16/+0
stabilize abi_thiscall Closes https://github.com/rust-lang/rust/issues/42202, stabilizing the use of the "thiscall" ABI. FCP was substituted by a poll, and the poll has been accepted.
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-3/+3
2023-08-07stabilize abi_thiscallBenedikt Radtke-16/+0
2023-08-07Auto merge of #114576 - lnicola:sync-from-ra, r=lnicolabors-1042/+4248
:arrow_up: `rust-analyzer` r? `@ghost`
2023-08-07Merge commit 'baee6b338b0ea076cd7a9f18d47f175dd2ba0e5d' into sync-from-raLaurențiu Nicola-1042/+4248
2023-08-07Auto merge of #114560 - RalfJung:miri, r=RalfJungbors-778/+1645
update Miri
2023-08-06[miri][typo] Fix a typo in a vector_block comment.Taras Tsugrii-1/+1
2023-08-07Rollup merge of #114382 - scottmcm:compare-bytes-intrinsic, r=cjgillotMatthias Krüger-4/+4
Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly As discussed in #113435, this lets the backends be the place that can have the "don't call the function if n == 0" logic, if it's needed for the target. (I didn't actually *add* those checks, though, since as I understood it we didn't actually need them on known targets?) Doing this also let me make it `const` (unstable), which I don't think `extern "C" fn memcmp` can be. cc `@RalfJung` `@Amanieu`
2023-08-06Add a new `compare_bytes` intrinsic instead of calling `memcmp` directlyScott McMurray-4/+4
2023-08-07Rollup merge of #114535 - klensy:windows-sys-0-42, r=compiler-errorsMatthias Krüger-1/+1
bump schannel, miow to drop windows-sys 0.42 Changes contains almost only of update to windows-sys 0.48 https://github.com/steffengy/schannel-rs/compare/v0.1.21...v0.1.22 https://github.com/yoshuawuyts/miow/compare/v0.5.0...v0.6.0
2023-08-06Rollup merge of #114539 - Enselic:unneeded-fixme, r=ehussMatthias Krüger-1/+0
linkchecker: Remove unneeded FIXME about intra-doc links It was added by https://github.com/rust-lang/rust/pull/77971 but the adder [proposed](https://github.com/rust-lang/rust/pull/77971#issuecomment-710026798) that the added code is a good fallback to have in case rustdoc gets buggy, and I agree. So remove the FIXME. This PR is part of #44366 which is E-help-wanted. r? `@jyn514` since you added the FIXME `@rustbot` label T-dev-tools
2023-08-06Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJungMatthias Krüger-1/+1
Add documentation to has_deref Documentation of `has_deref` needed some polish to be more clear about where it should be used and what's it's purpose. cc https://github.com/rust-lang/rust/issues/114401 r? `@RalfJung`
2023-08-06cleanup misinformation regarding has_derefouz-a-1/+1
2023-08-06linkchecker: Remove unneeded FIXME about intra-doc linksMartin Nordholts-1/+0
It was added by 77971 but the adder proposed in that PR that the added code is a good fallback to have in case rustdoc gets buggy, and I agree. So remove the FIXME.
2023-08-06bump schannel, miow to drop windows-sys 0.42klensy-1/+1
2023-08-05Auto merge of #114143 - Enselic:rename-issue-100605, r=eholkbors-1/+1
Rename tests/ui/issues/issue-100605.rs to ../type/option-ref-advice.rs The test is a regression test for a [bug ](https://github.com/rust-lang/rust/issues/100605) where the compiler gave bad advice for an `Option<&String>`. Rename the file appropriately. Part of #73494
2023-08-05Rename tests/ui/issues/issue-100605.rs to ../type/option-ref-advice.rsMartin Nordholts-1/+1
The test is a regression test for a bug where the compiler gave bad advice for an `Option<&String>`. Rename the file appropriately.
2023-08-05Rollup merge of #114498 - chenyukang:yukang-fix-tidy-tip, r=ozkanonurMatthias Krüger-1/+1
Print tidy command with bless tidy check failure It's more friendly for beginners to fix fluent alphabetical errors.
2023-08-05add a test ensuring that we enforce noalias on accessesRalf Jung-7/+37
2023-08-05tree borrows: consider some retags as writes for the purpose of data racesRalf Jung-138/+186
2023-08-05ensure we allow zero-sized references to functions and vtablesRalf Jung-0/+32
2023-08-05borrow tracking: simplify provenance updatingRalf Jung-55/+20
2023-08-05fix return place protection when the place is given as a localRalf Jung-1/+71
2023-08-05fmtRalf Jung-10/+2
2023-08-05Merge from rustcRalf Jung-79/+71
2023-08-05Preparing for merge from rustcRalf Jung-1/+1
2023-08-05Print tidy command with bless tidy check failureyukang-1/+1
2023-08-04Rollup merge of #114482 - compiler-errors:sigh, r=pnkfelixMichael Goulet-2/+7
Fix ui-fulldeps missing the `internal_features` lint on stage 0 Similar to #114102, `ui-fulldeps --stage=1` builds using the the stage 0 compiler instead of the stage 1 compiler. That means that the new `internal_features` lint is referencing a lint that does not exist. Gate the flag it properly until the next feature bump. Maybe we should just add ui-fulldeps stage 1 into CI somewhere so this is flagged before landing.
2023-08-04Auto merge of #114481 - matthiaskrgr:rollup-58pczpl, r=matthiaskrgrbors-54/+52
Rollup of 9 pull requests Successful merges: - #113945 (Fix wrong span for trait selection failure error reporting) - #114351 ([rustc_span][perf] Remove unnecessary string joins and allocs.) - #114418 (bump parking_lot to 0.12) - #114434 (Improve spans for indexing expressions) - #114450 (Fix ICE failed to get layout for ReferencesError) - #114461 (Fix unwrap on None) - #114462 (interpret: add mplace_to_ref helper method) - #114472 (Reword `confusable_idents` lint) - #114477 (Account for `Rc` and `Arc` when suggesting to clone) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-04Fix ui-fulldeps missing the internal_features lint on stage 0Michael Goulet-2/+7
2023-08-04Rollup merge of #114462 - RalfJung:mplace_to_ref, r=oli-obkMatthias Krüger-6/+4
interpret: add mplace_to_ref helper method
2023-08-04Rollup merge of #114434 - Nilstrieb:indexing-spans, r=est31Matthias Krüger-48/+48
Improve spans for indexing expressions fixes #114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
2023-08-04Auto merge of #114104 - oli-obk:syn2, r=compiler-errorsbors-23/+10
Lots of tiny incremental simplifications of `EmitterWriter` internals ignore the first commit, it's https://github.com/rust-lang/rust/pull/114088 squashed and rebased, but it's needed to use to use `derive_setters`, as they need a newer `syn` version. Then this PR starts out with removing many arguments that are almost always defaulted to `None` or `false` and replace them with builder methods that can set these fields in the few cases that want to set them. After that it's one commit after the other that removes or merges things until everything becomes some very simple trait objects
2023-08-04interpret: add mplace_to_ref helper methodRalf Jung-6/+4
2023-08-04Improve spans for indexing expressionsNilstrieb-48/+48
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-08-04Rollup merge of #114022 - oli-obk:tait_ice_alias_field_projection, r=cjgillotMatthias Krüger-0/+2
Perform OpaqueCast field projection on HIR, too. fixes #105819 This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field). See https://github.com/rust-lang/rust/pull/99806 for when and why we added OpaqueCast to MIR.
2023-08-04Auto merge of #3011 - saethlin:spellck, r=RalfJungbors-7/+7
A bit of spell-checking I noticed the one error in miri-script and took care of a few more shallow ones.
2023-08-04Merge from rustcThe Miri Conjob Bot-28/+42
2023-08-04Preparing for merge from rustcThe Miri Conjob Bot-1/+1
2023-08-04Rollup merge of #114429 - Enselic:compiletest-fix, r=est31Matthias Krüger-10/+14
compiletest: Handle non-utf8 paths (fix FIXME) Removes the last FIXME in the code for #9639 🎉 (which was closed 8 years ago) Part of #44366 which is E-help-wanted. (The other two PRs that does this are #114377 and #114427)
2023-08-03Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obkbors-1/+13
Add `internal_features` lint Implements https://github.com/rust-lang/compiler-team/issues/596 Also requires some more test blessing for codegen tests etc `@jyn514` had the idea of just `allow`ing the lint by default in the test suite. I'm not sure whether this is a good idea, but it's definitely one worth considering. Additional input encouraged.
2023-08-03A bit of spell-checkingBen Kimock-7/+7
2023-08-03Auto merge of #114424 - matthiaskrgr:rollup-cegblvo, r=matthiaskrgrbors-12/+14
Rollup of 8 pull requests Successful merges: - #113657 (Expand, rename and improve `incorrect_fn_null_checks` lint) - #114237 (parser: more friendly hints for handling `async move` in the 2015 edition) - #114300 (Suggests turbofish in patterns) - #114372 (const validation: point at where we found a pointer but expected an integer) - #114395 ([rustc_span][perf] Hoist lookup sorted by words out of the loop.) - #114403 (fix the span in the suggestion of remove question mark) - #114408 (Temporary remove myself from review rotation) - #114415 (Skip checking of `rustc_codegen_gcc` with vendoring enabled) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-03compiletest: Handle non-utf8 paths (fix FIXME)Martin Nordholts-10/+14