about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-07-19Turn copy into moves during DSE.Camille GILLOT-3/+40
2023-07-19Auto merge of #113690 - aliemjay:opaque-defined-by-trait, r=compiler-errorsbors-5/+6
allow opaques to be defined by trait queries, again This basically reverts #112963. Moreover, all call-sites of `enter_canonical_trait_query` can now define opaque types, see the ui test `defined-by-user-annotation.rs`. Fixes #113689 r? `@compiler-errors` `@oli-obk`
2023-07-18Auto merge of #113777 - nnethercote:overlap-based-cgu-merging, r=pnkfelixbors-37/+103
Inline overlap based CGU merging Introduce a new CGU merging algorithm that aims to minimize the number of duplicated inlined items. r? `@wesleywiser`
2023-07-19Change the primary CGU merging algorithm.Nicholas Nethercote-14/+66
Instead of repeatedly merging the two smallest CGUs, we now use a merging algorithm that aims to minimize the duplication of inlined functions. `exa-0.10.1` was one benchmark that saw particularly good results. The old CGU stats: ``` INTERNALIZE - unique items: 2774 (1216 root + 1558 inlined), unique size: 122065 (77219 root + 44846 inlined) - placed items: 3834 (1216 root + 2618 inlined), placed size: 154552 (77219 root + 77333 inlined) - placed/unique items ratio: 1.38, placed/unique size ratio: 1.27 - CGUs: 16, mean size: 9659.5, sizes: [11791, 11634, 11173, 10987, 10939, 10507, 9992, 9813, 9593, 9580, 9030, 8447, 7975, 7961, 7876, 7254] ``` The new CGU stats: ``` INTERNALIZE - unique items: 2774 (1216 root + 1558 inlined), unique size: 122065 (77219 root + 44846 inlined) - placed items: 3626 (1216 root + 2410 inlined), placed size: 147201 (77219 root + 69982 inlined) - placed/unique items ratio: 1.31, placed/unique size ratio: 1.21 - CGUs: 16, mean size: 9200.1, sizes: [11634, 10939, 10227, 9555, 9178, 9167, 8879, 8804, 8604, 8603 (x3), 8602 (x2), 8601, 8600] ``` The difference is in the number of inlined items. There are 1558 unique inlined items. With the old algorithm these were placed 2618 times, resulting in 1060 duplicates. With the new algorithm these were placed 2410 times, resulting in 852 duplicates. Also, the mean CGU size dropped from 9659.5 to 9200.1, and the CGU size distribution tightened, with the biggest one a little smaller and the smallest ones a little bigger.
2023-07-19Add a useful comment.Nicholas Nethercote-0/+2
2023-07-19Split the CGU merging loop.Nicholas Nethercote-20/+30
It has two conditions. This commit splits it in two, one per condition. The next commit will change the first loop.
2023-07-19Add `MonoItemData::inlined`.Nicholas Nethercote-17/+19
2023-07-18Auto merge of #113636 - compiler-errors:opaque-recursive-check-bad, r=oli-obkbors-20/+4
Restrict recursive opaque type check We have a recursive opaque check in writeback to avoid inferring the hidden of an opaque type to be itself: https://github.com/rust-lang/rust/blob/33a2c2487ac5d9927830ea4c1844335c6b9f77db/compiler/rustc_hir_typeck/src/writeback.rs#L556-L575 Issue #113619 treats `make_option2` as not defining the TAIT `TestImpl` since it is inferred to have the definition `TestImpl := B<TestImpl>`, which fails this check. This regressed in #102700 (5d15beb5919e4ed481c44a1ac19c2ad04a36ee8a), I think due to the refactoring that made us record the hidden types of TAITs during writeback. However, nothing actually seems to go bad if we relax this recursion checker to only check for directly recursive definitions. This PR fixes #113619 by changing this recursive check from being a visitor to just checking that the hidden type is exactly the same as the opaque being inferred. Alternatively, we may be able to fix #113619 by restricting this recursion check only to RPITs/async fns. It seems to only be possible to use misuse the recursion check to cause ICEs for TAITs (though I didn't try too hard to create a bad RPIT example... may be possible, actually.) r? `@oli-obk` -- Fixes #113314
2023-07-18Rollup merge of #113832 - WaffleLapkin:track_lint_caller, r=compiler-errorsMatthias Krüger-0/+19
Add `#[track_caller]` to lint related diagnostic functions This fixes locations reported by `-Ztrack-diagnostics`.
2023-07-18Rollup merge of #113824 - lcnr:exhaustive-match, r=wesleywiserMatthias Krüger-12/+36
a small `fn needs_drop` refactor I am generally a fan of exhaustively matching on `TyKind` once we care about more than 1 variant
2023-07-18Rollup merge of #113811 - jieyouxu:fix-unused-qualifications-suggestion, ↵Matthias Krüger-11/+9
r=oli-obk Fix removal span calculation of `unused_qualifications` suggestion Given a path such as `std::ops::Index<str>`, calculate the unnecessary qualification removal span by computing the beginning of the entire span until the ident span of the last path segment, which handles generic arguments and lifetime arguments in the last path segment. Previous logic only kept the ident span of the last path segment which is incorrect. Closes #113808.
2023-07-18Relax recursive opaque type checkMichael Goulet-20/+4
2023-07-18Add `#[track_caller]` to lint related diagnostic functionsMaybe Waffle-0/+19
2023-07-18some additional refactorlcnr-12/+12
also, treat placeholders equal to params
2023-07-18support for mips32r6 as a target_arch valuechenx97-6/+7
2023-07-18merge patternschenx97-6/+3
2023-07-18support for mips64r6 as a target_arch valuechenx97-4/+8
2023-07-18Auto merge of #113677 - bryangarza:unevaluated-const-ice_issue-110892, ↵bors-1/+20
r=davidtwco Safe Transmute: Fix ICE (due to UnevaluatedConst) This patch updates the code that looks at the `Assume` type when evaluating if transmutation is possible. An ICE was being triggered in the case that the `Assume` parameter contained an unevaluated const (in this test case, due to a function with missing parameter names). Fixes #110892
2023-07-18Auto merge of #113659 - ericmarkmartin:smir-refs-and-ptrs, r=spastorinobors-7/+11
Add ty convs for smir refs and ptrs r? `@spastorino`
2023-07-18Auto merge of #113801 - compiler-errors:iter-instantiated, r=oli-obkbors-35/+42
Rename `arg_iter` to `iter_instantiated` `arg_iter` doesn't make sense, and doesn't really indicate what it's doing (returning an iterator that ~~substitutes~~ instantiates its elements). `iter_instantiated_copied` is kinda awkward but i don't really wanna bikeshed it. r? `@oli-obk`
2023-07-18Fix removal span calculation of unused_qualifications suggestion许杰友 Jieyou Xu (Joe)-11/+9
2023-07-17conversions to smir RawPtr and RefEric Mark Martin-10/+7
2023-07-17add RawPtrEric Mark Martin-1/+6
2023-07-17move const definitionEric Mark Martin-0/+2
2023-07-18Auto merge of #113061 - Amanieu:x86_64-ohos, r=compiler-errorsbors-10/+42
Add x86_64-unknown-linux-ohos target This complements the existing `aarch64-unknown-linux-ohos` and `armv7-unknown-linux-ohos` targets. This should be covered by the existing MCP (https://github.com/rust-lang/compiler-team/issues/568), but I can also create a new MCP if that is preferred.
2023-07-17Rename arg_iter to iter_instantiatedMichael Goulet-35/+42
2023-07-17Auto merge of #113720 - eduardosm:miri-target-feature, r=RalfJung,oli-obkbors-0/+33
miri: fail when calling a function that requires an unavailable target feature miri will report an UB when calling a function that has a `#[target_feature(enable = ...)]` attribute is called and the required feature is not available. "Available features" are the same that `is_x86_feature_detected!` (or equivalent) reports to be available during miri execution (which can be enabled or disabled with the `-C target-feature` flag).
2023-07-17Safe Transmute: Fix ICE (due to UnevaluatedConst)Bryan Garza-1/+20
This patch updates the code that looks at the `Assume` type when evaluating if transmutation is possible. An ICE was being triggered in the case that the `Assume` parameter contained an unevaluated const (in this test case, due to a function with missing parameter names). Fixes #110892
2023-07-17Auto merge of #113714 - Kobzol:ci-cmake, r=nikicbors-1/+4
CI: build CMake 3.20 to support LLVM 17 LLVM 17 will require CMake at least 3.20, so we have to go back to building our own CMake on the Linux x64 dist builder. r? `@nikic`
2023-07-17exhaustive matches are goodlcnr-1/+25
2023-07-17Rollup merge of #113770 - dtolnay:derivevoid, r=compiler-errors,nnethercoteMatthias Krüger-4/+14
Generate safe stable code for derives on empty enums Generate `match *self {}` instead of `unsafe { core::intrinsics::unreachable() }`. This is: 1. safe 2. stable for the benefit of everyone looking at these derived impls through `cargo expand`. [Both expansions compile to the same code at all optimization levels (including `0`).](https://rust.godbolt.org/z/P79joGMh3)
2023-07-17Rollup merge of #113651 - lcnr:parent-def-id, r=compiler-errorsMatthias Krüger-11/+7
self type param infer, avoid ICE fixes #113610, which is caused by https://github.com/rust-lang/rust/blob/33a2c2487ac5d9927830ea4c1844335c6b9f77db/compiler/rustc_hir_analysis/src/collect/generics_of.rs#L190-L205
2023-07-17Rollup merge of #113535 - jonathanpallant:sparc-bare-metal, r=jackh726Matthias Krüger-0/+29
Add a sparc-unknown-none-elf target. # `sparc-unknown-none-elf` **Tier: 3** Rust for bare-metal 32-bit SPARC V7 and V8 systems, e.g. the Gaisler LEON3. ## Target maintainers - Jonathan Pallant, `jonathan.pallant@ferrous-systems.com`, https://ferrous-systems.com ## Requirements > Does the target support host tools, or only cross-compilation? Only cross-compilation. > Does the target support std, or alloc (either with a default allocator, or if the user supplies an allocator)? Only tested with `libcore` but I see no reason why you couldn't also support `liballoc`. > Document the expectations of binaries built for the target. Do they assume specific minimum features beyond the baseline of the CPU/environment/etc? What version of the OS or environment do they expect? Tested by linking with a standard SPARC bare-metal toolchain - specifically I used the [BCC2] toolchain from Gaisler (both GCC and clang variants, both pre-compiled for x64 Linux and compiling my own SPARC GCC from source to run on `aarch64-apple-darwin`). The target is set to use the lowest-common-denominator `SPARC V7` architecture (yes, they started at V7 - see [Wikipedia](https://en.wikipedia.org/wiki/SPARC#History)). [BCC2]: https://www.gaisler.com/index.php/downloads/compilers > Are there notable `#[target_feature(...)]` or `-C target-feature=` values that programs may wish to use? `-Ctarget-cpu=v8` adds the instructions added in V8. `-Ctarget-cpu=leon3` adds the V8 instructions and sets up scheduling to suit the Gaisler LEON3. > What calling convention does `extern "C"` use on the target? I believe this is defined by the SPARC architecture reference manuals and V7, V8 and V9 are all compatible. > What format do binaries use by default? ELF, PE, something else? ELF ## Building the target > If Rust doesn't build the target by default, how can users build it? Can users just add it to the `target` list in `config.toml`? Yes. I did: ```toml target = ["aarch64-apple-darwin", "sparc-unknown-none-elf"] ``` ## Building Rust programs > Rust does not yet ship pre-compiled artifacts for this target. To compile for this target, you will either need to build Rust with the target enabled (see "Building the target" above), or build your own copy of `core` by using `build-std` or similar. Correct. ## Testing > Does the target support running binaries, or do binaries have varying expectations that prevent having a standard way to run them? No - it's a bare metal platform. > If users can run binaries, can they do so in some common emulator, or do they need native hardware? But if you use [BCC2] as the linker, you get default memory map suitable for the LEON3, and a default BSP for the LEON3, and so you can run the binaries in the `tsim-leon3` simulator from Gaisler. ```console $ cat .cargo/config.toml | grep runner runner = "tsim-leon3 -c sim-commands.txt" $ cat sim-commands.txt run quit $ cargo +sparcrust run --targe=sparc-unknown-none-elf Compiling sparc-demo-rust v0.1.0 (/work/sparc-demo-rust) Finished dev [unoptimized + debuginfo] target(s) in 3.44s Running `tsim-leon3 -c sim-commands.txt target/sparc-unknown-none-elf/debug/sparc-demo-rust` TSIM3 LEON3 SPARC simulator, version 3.1.9 (evaluation version) Copyright (C) 2023, Frontgrade Gaisler - all rights reserved. This software may only be used with a valid license. For latest updates, go to https://www.gaisler.com/ Comments or bug-reports to support@gaisler.com This TSIM evaluation version will expire 2023-11-28 Number of CPUs: 2 system frequency: 50.000 MHz icache: 1 * 4 KiB, 16 bytes/line (4 KiB total) dcache: 1 * 4 KiB, 16 bytes/line (4 KiB total) Allocated 8192 KiB SRAM memory, in 1 bank at 0x40000000 Allocated 32 MiB SDRAM memory, in 1 bank at 0x60000000 Allocated 8192 KiB ROM memory at 0x00000000 section: .text, addr: 0x40000000, size: 104400 bytes section: .rodata, addr: 0x400197d0, size: 15616 bytes section: .data, addr: 0x4001d4d0, size: 1176 bytes read 1006 symbols Initializing and starting from 0x40000000 Hello, this is Rust! PANIC: PanicInfo { payload: Any { .. }, message: Some(I am a panic), location: Location { file: "src/main.rs", line: 33, col: 5 }, can_unwind: true } Program exited normally on CPU 0. ``` > Does the target support running the Rust testsuite? I don't think so, the testsuite requires `libstd` IIRC. ## Cross-compilation toolchains and C code > Does the target support C code? Yes. > If so, what toolchain target should users use to build compatible C code? (This may match the target triple, or it may be a toolchain for a different target triple, potentially with specific options or caveats.) I suggest [BCC2] from Gaisler. It comes in both GCC and Clang variants.
2023-07-17Link to `execinfo` on NetBSDJakub Beránek-1/+4
2023-07-17Auto merge of #113562 - saethlin:larger-incr-comp-offset, r=nnethercotebors-6/+9
Use u64 for incr comp allocation offsets Fixes https://github.com/rust-lang/rust/issues/76037 Fixes https://github.com/rust-lang/rust/issues/95780 Fixes https://github.com/rust-lang/rust/issues/111613 These issues are all reporting ICEs caused by using `u32` to store offsets to allocations in the incremental compilation cache. This PR aims to lift that limitation by changing the offset type in question to `u64`. There are two perf runs in this PR. The first reports a regression, and the second does not. The changes are the same in both. I rebased the PR then did the second perf run because I noticed that the primary regression in it was very commonly seen in spurious regression reports. I do not know what the perf run will report when this is merged. I would not be surprised to see regression or neutral, but the cachegrind diffs for the regression point at `try_mark_previous_green` which is a common source of inexplicable regressions and I don't think should be perturbed by this PR. I'm not opposed to adding a regression test such as ```rust fn main() { println!("{}", [37; 1 << 30].len()); } ``` But that program takes 1 minute to compile and consumes 4.6 GB of memory then writes that much to disk. Is that a concerning amount of resource use for a test? r? `@nnethercote`
2023-07-17Auto merge of #113772 - nnethercote:streamline-size-estimates-2, r=wesleywiserbors-97/+85
Streamline size estimates (take 2) This was merged in #113684 but then [something happened](https://github.com/rust-lang/rust/pull/113684#issuecomment-1636811985): > There has been a bors issue that lead to the merge commit of this PR getting purged from master. > You'll have to make a new PR to reapply it. So this is exactly the same changes. `@bors` r=wesleywiser
2023-07-17Auto merge of #113336 - compiler-errors:new-solver-iat, r=lcnrbors-6/+85
Add support for inherent projections in new solver Not hard to support these, and it cuts out a really big chunk of failing UI tests with `--compare-mode=next-solver` r? `@lcnr` (feel free to reassign, anyone can review this)
2023-07-16Auto merge of #113769 - matthiaskrgr:rollup-p6i1rco, r=matthiaskrgrbors-4/+6
Rollup of 7 pull requests Successful merges: - #113042 (Add Platform Support documentation for MIPS Release 6 targets) - #113539 (fixed typo) - #113614 (platform-support.md: It's now verified that NetBSD/riscv64 can self-h…) - #113750 (Add missing italicization to `sort_unstable_by_key` complexity ) - #113755 (Normalize lazy type aliases when probing for ADTs) - #113756 (fix wrong link) - #113762 (Fix typo) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-17Remove `instance_def_size_estimate` query.Nicholas Nethercote-28/+12
It doesn't seem worthwhile now that `MonoItem::size_estimate` is called much less often.
2023-07-17Ignore unreachable inlined items in `debug_dump`.Nicholas Nethercote-30/+18
They're quite rare, and ignoring them simplifies things quite a bit, and further reduces the number of calls to `MonoItem::size_estimate` to the number of placed items (one per root item, and one or more per reachable inlined item).
2023-07-17Store item size estimate in `MonoItemData`.Nicholas Nethercote-18/+22
This means we call `MonoItem::size_estimate` (which involves a query) less often: just once per mono item, and then once more per inline item placement. After that we can reuse the stored value as necessary. This means `CodegenUnit::compute_size_estimate` is cheaper.
2023-07-17Introduce `MonoItemData`.Nicholas Nethercote-27/+39
It replaces `(Linkage, Visibility)`, making the code nicer. Plus the next commit will add another field.
2023-07-16Add a comparison between match *self and intrinsics::unreachable()David Tolnay-2/+3
2023-07-17Rollup merge of #113755 - fmease:probe-adt-norm-lazy-ty-alias, r=oli-obkMatthias Krüger-1/+3
Normalize lazy type aliases when probing for ADTs Fixes #113736. r? ```@oli-obk```
2023-07-17Rollup merge of #113539 - agnarrarendelle:master, r=workingjubileeMatthias Krüger-3/+3
fixed typo Hi, I have fixed a few typos in commands. Please review my pr.
2023-07-16Generate safe stable code for derives on empty enumsDavid Tolnay-4/+13
Generate `match *self {}` instead of `unsafe { core::intrinsics::unreachable() }`. This is: 1. safe 2. stable for the benefit of everyone looking at these derived impls through `cargo expand`. Both expansions compile to the same code at all optimization levels (including `0`).
2023-07-16Auto merge of #113742 - ↵bors-2/+2
compiler-errors:dont-short-circuit-intercrate-global-preds, r=lcnr Don't call `predicate_must_hold`-esque functions during fulfillment in intercrate Fixes #113415 Given that this only happens in `translate_substs`, I don't actually think that this is something that you can weaponize, but it's still sketchy regardless. r? `@lcnr`
2023-07-16Check GAT, IAT, and weak type where clauses during projectionMichael Goulet-9/+45
2023-07-16Add support for inherent projectionsMichael Goulet-3/+46
2023-07-16Auto merge of #113545 - cjgillot:query-entry, r=compiler-errorsbors-269/+284
Check entry type as part of item type checking. This code is currently executed inside the root `analysis` query. Instead, check it during `check_for_entry_fn(CRATE_DEF_ID)` to hopefully avoid some re-executions. `CRATE_DEF_ID` is chosen by considering that entry fn are typically at crate root, so the corresponding HIR should already be in the dependencies.