summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Auto merge of #111364 - cuviper:unhack-thinlto, r=nikicHEADmasterbors2023-05-183-112/+0
|\ | | | | | | | | | | | | | | | | | | | | Remove the ThinLTO CU hack This reverts #46722, commit e0ab5d5feb4eb2d8af11b8dd9446c2b45fada8af. Since #111167, commit 10b69dde3fd15334ea2382d2dc9e9a261de1afaf, we are generating DWARF subprograms in a way that is meant to be more compatible with LLVM's expectations, so hopefully we don't need this workaround rewriting CUs anymore.
| * Remove the ThinLTO CU hackJosh Stone2023-05-083-112/+0
| | | | | | | | | | | | | | | | | | This reverts #46722, commit e0ab5d5feb4eb2d8af11b8dd9446c2b45fada8af. Since #111167, commit 10b69dde3fd15334ea2382d2dc9e9a261de1afaf, we are generating DWARF subprograms in a way that is meant to be more compatible with LLVM's expectations, so hopefully we don't need this workaround rewriting CUs anymore.
* | Auto merge of #111568 - scottmcm:undo-opt, r=WaffleLapkinbors2023-05-171-13/+0
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stop turning transmutes into discriminant reads in mir-opt Partially reverts #109612, as after #109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place. Having this "simplification" meant that similar-looking code actually did somewhat different things. For example, ```rust pub unsafe fn demo1(x: std::cmp::Ordering) -> u8 { std::mem::transmute(x) } pub unsafe fn demo2(x: std::cmp::Ordering) -> i8 { std::mem::transmute(x) } ``` in nightly today is generating <https://rust.godbolt.org/z/dPK58zW18> ```llvm define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef %x) unnamed_addr #0 { %0 = icmp uge i8 %x, -1 %1 = icmp ule i8 %x, 1 %2 = or i1 %0, %1 call void `@llvm.assume(i1` %2) ret i8 %x } define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef %0) unnamed_addr #0 { %x = alloca i8, align 1 store i8 %0, ptr %x, align 1 %1 = load i8, ptr %x, align 1, !range !2, !noundef !3 ret i8 %1 } ``` Which feels too different when the original code is essentially identical. --- Aside: that example is different *after* optimizations too: ```llvm define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef returned %x) unnamed_addr #0 { %0 = add i8 %x, 1 %1 = icmp ult i8 %0, 3 tail call void `@llvm.assume(i1` %1) ret i8 %x } define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef returned %0) unnamed_addr #1 { ret i8 %0 } ``` so turning the `Transmute` into a `Discriminant` was arguably just making things worse, so leaving it alone instead -- and thus having less code in rustc -- seems clearly better.
| * | Stop turning transmutes into discriminants in mir-optScott McMurray2023-05-141-13/+0
| | | | | | | | | | | | Partially reverts 109612, as after 109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place.
* | | Rollup merge of #111625 - Zoxc:rustc_middle-query-move, r=cjgillotDylan DPC2023-05-1717-33/+29
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rs This just keeps the query modules together. r? `@cjgillot`
| * | | Finish move of query.rsJohn Kåre Alsaker2023-05-1716-33/+29
| | | |
| * | | Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rsJohn Kåre Alsaker2023-05-171-0/+0
| | | |
* | | | Rollup merge of #111588 - MU001999:diag/improve-e0782, r=fee1-deadDylan DPC2023-05-177-36/+119
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | Emits E0599 when meeting `MyTrait::missing_method` Fixes #111312
| * | | | Emits E0599 when meeting MyTrait::missing_methodmu0019992023-05-177-36/+119
| | | | |
* | | | | Rollup merge of #111557 - cjgillot:revert-111020, r=petrochenkovDylan DPC2023-05-172-5/+2
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revert "Validate resolution for SelfCtor too." This reverts commit 83453408a0ce91b9e3d3ae6e7f117b1fd28b487d. That PR introduced a breaking change. Fixes https://github.com/rust-lang/rust/issues/111541 Reopens https://github.com/rust-lang/rust/issues/89868 r? `@petrochenkov`
| * | | | | Revert "Validate resolution for SelfCtor too."Camille GILLOT2023-05-142-5/+2
| |/ / / / | | | | | | | | | | | | | | | This reverts commit 83453408a0ce91b9e3d3ae6e7f117b1fd28b487d.
* | | | | Rollup merge of #110930 - b-naber:normalize-elaborate-drops, r=cjgillotDylan DPC2023-05-172-1/+27
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't expect normalization to succeed in elaborate_drops Fixes https://github.com/rust-lang/rust/issues/110682 This was exposed through the changes in https://github.com/rust-lang/rust/pull/109247, which causes more things to be inlined. Inlining can happen before monomorphization, so we can't expect normalization to succeed. In the elaborate_drops analysis we currently have [this call](https://github.com/rust-lang/rust/blob/033aa092ab23ba14cdad27073c5e37ba0eddb428/compiler/rustc_mir_dataflow/src/elaborate_drops.rs#L278) to `normalize_erasing_regions`, which ICEs when normalization fails. The types are used to infer [whether the type needs a drop](https://github.com/rust-lang/rust/blob/033aa092ab23ba14cdad27073c5e37ba0eddb428/compiler/rustc_mir_dataflow/src/elaborate_drops.rs#L374), where `needs_drop` itself [uses `try_normalize_erasing_regions`](https://github.com/rust-lang/rust/blob/033aa092ab23ba14cdad27073c5e37ba0eddb428/compiler/rustc_middle/src/ty/util.rs#L1121). ~[`instance_mir`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.instance_mir) isn't explicit about whether it expects the instances corresponding to the `InstanceDef`s to be monomorphized (though I think in all other contexts the function is used post-monomorphization), so the use of `instance_mir` in inlining doesn't necessarily seem wrong to me.~
| * | | | | don't inline polymorphic adt instances whose fields contain projectionsb-naber2023-05-102-9/+29
| | | | | | | | | | | | | | | | | | | | | | | | in DropGlue.
| * | | | | dont expect normalization to succeed in elaborate_dropsb-naber2023-04-281-3/+9
| | | | | |
* | | | | | Auto merge of #111671 - Dylan-DPC:rollup-1jy5r16, r=Dylan-DPCbors2023-05-1722-74/+109
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rollup of 6 pull requests Successful merges: - #110145 (Share slice of bytes) - #111043 (Stabilize feature `cstr_is_empty`) - #111648 (Remove `LangItems::require`) - #111649 (Add derive for `core::marker::ConstParamTy`) - #111654 (Add a conversion from `&mut T` to `&mut UnsafeCell<T>`) - #111661 (Erase regions of type in `offset_of!`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| * \ \ \ \ \ Rollup merge of #111661 - clubby789:offset-of-erase-regions, r=compiler-errorsDylan DPC2023-05-171-3/+4
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Erase regions of type in `offset_of!` Fixes #111657
| | * | | | | | Erase regions of type in `offset_of!`clubby7892023-05-161-3/+4
| | | | | | | |
| * | | | | | | Rollup merge of #111654 - JoJoJet:unsafe-cell-from-mut-lib, r=joshtriplettDylan DPC2023-05-171-0/+1
| |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a conversion from `&mut T` to `&mut UnsafeCell<T>` Provides a safe way of downgrading an exclusive reference into an alias-able `&UnsafeCell<T>` reference. ACP: https://github.com/rust-lang/libs-team/issues/198.
| | * | | | | | | add `UnsafeCell::from_mut`JoJoJet2023-05-161-0/+1
| | |/ / / / / /
| * | | | | | | Rollup merge of #111649 - Nilstrieb:derive-const-param-ty, r=BoxyUwUDylan DPC2023-05-173-0/+25
| |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add derive for `core::marker::ConstParamTy` This makes it easier to implement it for a type, just like `Copy`. `@BoxyUwU` half asked me to add it
| | * | | | | | | Add derive for `core::marker::ConstParamTy`Nilstrieb2023-05-163-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it easier to implement it for a type, just like `Copy`.
| * | | | | | | | Rollup merge of #111648 - Nilstrieb:language-items, r=WaffleLapkinDylan DPC2023-05-178-34/+15
| |\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove `LangItems::require` It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
| | * | | | | | | | Remove `LangItems::require`Nilstrieb2023-05-168-34/+15
| | |/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
| * | | | | | | | Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=NilstriebDylan DPC2023-05-1710-37/+64
| |\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Share slice of bytes r? `@Nilstrieb` cc `@noamtashma`
| | * | | | | | | | Fixup commentsMaybe Waffle2023-05-161-4/+4
| | | | | | | | | |
| | * | | | | | | | Remove `MetadataRef` type aliasMaybe Waffle2023-05-165-18/+12
| | | | | | | | | |
| | * | | | | | | | Switch `OwnedSlice` to use `Lrc` & remove `Lrc` from `MetadataBlob`Maybe Waffle2023-05-166-13/+47
| | | | | | | | | |
| | * | | | | | | | Merge `MetadataRef` type aliasesMaybe Waffle2023-05-161-4/+3
| | | | | | | | | |
* | | | | | | | | | Auto merge of #111630 - BoxyUwU:ty_const_debug_formatting, r=compiler-errorsbors2023-05-174-41/+71
|\ \ \ \ \ \ \ \ \ \ | |/ / / / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | debug format `Const`'s less verbosely Not user visible change only visible to people debugging const generics. Currently debug output for `ty::Const` is super verbose (even for `-Zverbose` lol), things like printing infer vars as `Infer(Var(?0c))` instead of just `?0c`, bound vars and placeholders not using `^0_1` or `!0_1` syntax respectively. With these changes its imo better but not perfect: `Const { ty: usize, kind: ^0_1 }` is still a lot for not much information. not entirely sure what to do about that so not dealing with it yet. Need to do formatting for `ConstKind::Expr` at some point too since rn it sucks (doesn't even print anything with `Display`) not gonna do that in this PR either. r? `@compiler-errors`
| * | | | | | | | | format `Const`'s less verboselyBoxy2023-05-164-41/+71
| | | | | | | | | |
* | | | | | | | | | Auto merge of #111556 - cjgillot:copy-prop-nrvo, r=oli-obkbors2023-05-162-42/+50
|\ \ \ \ \ \ \ \ \ \ | |_|_|_|_|_|_|/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge return place with other locals in CopyProp. This reintroduces a limited form of NRVO. r? wg-mir-opt
| * | | | | | | | | Simplify implementation.Camille GILLOT2023-05-141-22/+16
| | | | | | | | | |
| * | | | | | | | | Merge return place with other locals in CopyProp.Camille GILLOT2023-05-142-20/+34
| | |_|_|_|_|/ / / | |/| | | | | | |
* | | | | | | | | Auto merge of #111650 - matthiaskrgr:rollup-n7w17v4, r=matthiaskrgrbors2023-05-169-44/+78
|\ \ \ \ \ \ \ \ \ | |_|_|_|_|/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rollup of 7 pull requests Successful merges: - #107680 (Hide repr attribute from doc of types without guaranteed repr) - #111488 (Use error term in projection if missing associated item in new solver) - #111533 (Handle error body in generator layout) - #111573 (Erase `ReError` properly) - #111592 (Change Vec examples to not assert exact capacity except where it is guaranteed) - #111610 (fix(diagnostic): wrap parens for ref impl trait param) - #111642 ([rustdoc] Only keep impl blocks from bodies) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| * | | | | | | | Rollup merge of #111610 - bvanjoi:fix-99597, r=compiler-errorsMatthias Krüger2023-05-161-31/+46
| |\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix(diagnostic): wrap parens for ref impl trait param Fixes https://github.com/rust-lang/rust/issues/99597 When parameters are an `impl_trait` which it needed to add trait, and it is a reference, add parentheses to the type of the parameter in the suggestion
| | * | | | | | | | fix(diagnostic): wrap parens for ref impl trait parambohan2023-05-161-31/+46
| | | |_|/ / / / / | | |/| | | | | |
| * | | | | | | | Rollup merge of #111573 - compiler-errors:erase-re-error, r=WaffleLapkinMatthias Krüger2023-05-161-1/+3
| |\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Erase `ReError` properly Fixes #111341 Since we check whether a type has free regions before erasing (to short circuit unnecesary folding), we need to consider `ReError` as a free region, or else we'll skip it when erasing a type that only mentions `ReError`. cc `@nnethercote`
| | * | | | | | | | Erase ReError properlyMichael Goulet2023-05-141-1/+3
| | | |_|_|_|_|/ / | | |/| | | | | |
| * | | | | | | | Rollup merge of #111533 - clubby789:drop-tracking-error, r=oli-obkMatthias Krüger2023-05-166-11/+14
| |\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Handle error body in generator layout Fixes #111468 I feel like making this query return `Option<GeneratorLayout>` might be better but had some issues with that approach
| | * | | | | | | | Handle error body when in generator layoutclubby7892023-05-136-11/+14
| | | | | | | | | |
| * | | | | | | | | Use error term if missing associated item in new solverMichael Goulet2023-05-161-1/+15
| | |_|_|_|/ / / / | |/| | | | | | |
* | | | | | | | | Auto merge of #108062 - Zoxc:spec-incr, r=cjgillotbors2023-05-164-17/+76
|\ \ \ \ \ \ \ \ \ | |/ / / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specialize query execution for incremental and non-incremental This specializes query execution for incremental and non-incremental by passing in a separate `dyn QueryEngine` types, taking advantage of the virtual dispatch to avoid a branch. This ends up duplicating `try_execute_query`, hopefully the compile time cost of that is relatively low. This is a performance improvement for the non-incremental path: <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.8420s</td><td align="right">1.8331s</td><td align="right"> -0.48%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2652s</td><td align="right">0.2631s</td><td align="right"> -0.78%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">1.0161s</td><td align="right">1.0062s</td><td align="right"> -0.98%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.6408s</td><td align="right">1.6197s</td><td align="right">💚 -1.28%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.3939s</td><td align="right">6.3558s</td><td align="right"> -0.60%</td></tr><tr><td>Total</td><td align="right">11.1580s</td><td align="right">11.0780s</td><td align="right"> -0.72%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9918s</td><td align="right"> -0.82%</td></tr></table> The incremental path is more neutral: <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:initial</td><td align="right">2.2210s</td><td align="right">2.2227s</td><td align="right"> 0.08%</td></tr><tr><td>🟣 <b>hyper</b>:check:initial</td><td align="right">0.3441s</td><td align="right">0.3443s</td><td align="right"> 0.05%</td></tr><tr><td>🟣 <b>regex</b>:check:initial</td><td align="right">1.2919s</td><td align="right">1.2877s</td><td align="right"> -0.33%</td></tr><tr><td>🟣 <b>syn</b>:check:initial</td><td align="right">2.0749s</td><td align="right">2.0721s</td><td align="right"> -0.14%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:initial</td><td align="right">7.9266s</td><td align="right">7.9206s</td><td align="right"> -0.07%</td></tr><tr><td>Total</td><td align="right">13.8585s</td><td align="right">13.8474s</td><td align="right"> -0.08%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9992s</td><td align="right"> -0.08%</td></tr></table> r? `@cjgillot`
| * | | | | | | | Specialize query execution for incremental and non-incrementalJohn Kåre Alsaker2023-05-144-17/+76
| | |/ / / / / / | |/| | | | | |
* | | | | | | | Auto merge of #105750 - oli-obk:valtrees, r=lcnrbors2023-05-164-54/+84
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Always fall back to PartialEq when a constant in a pattern is not recursively structural-eq Right now we destructure the constant as far as we can, but with this PR we just don't take it apart anymore. This is preparatory work for moving to always using valtrees, as these will just do a single conversion of the constant to a valtree at the start, and if that fails, fall back to `PartialEq`. This removes a few cases where we emitted the `unreachable pattern` lint, because we stop looking into the constant deeply enough to detect that a constant is already covered by another pattern. Previous work: https://github.com/rust-lang/rust/pull/70743 This is groundwork towards fixing https://github.com/rust-lang/rust/issues/83085 and https://github.com/rust-lang/rust/issues/105047
| * | | | | | | | Document how constants as opaque patterns behave differently.Oli Scherer2023-05-162-4/+20
| | | | | | | | |
| * | | | | | | | Update some commentsOli Scherer2023-05-151-9/+5
| | | | | | | | |
| * | | | | | | | Always fall back to PartialEq when a constant in a pattern is not ↵Oli Scherer2023-05-152-36/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | recursively structural-eq
| * | | | | | | | Unnest a variable in prep for the next commit which needs access to the placeOli Scherer2023-05-151-5/+8
| | |_|/ / / / / | |/| | | | | |
* | | | | | | | Rollup merge of #111605 - klensy:fixup_version, r=compiler-errorsNilstrieb2023-05-161-1/+1
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixup version placeholder for `cfi_encoding` feature Mentioned https://github.com/rust-lang/rust/pull/105452#discussion_r1184772529
| * | | | | | | | fixup version placeholder for cfi_encoding featureklensy2023-05-151-1/+1
| | | | | | | | |