about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2022-07-09Rollup merge of #99022 - pierwill:always-storage-live-locals, r=pierwillMatthias Krüger-2/+2
MIR dataflow: Rename function to `always_storage_live_locals` Related to #99021. r? ```@JakobDegen``` (as discussed on Zulip)
2022-07-09Rollup merge of #98980 - RalfJung:const-prop-ice, r=oli-obkDylan DPC-5/+10
fix ICE in ConstProp Fixes https://github.com/rust-lang/rust/issues/96169
2022-07-09Auto merge of #98961 - zeevm:issue-98958-fix, r=oli-obkbors-11/+2
Only enable ConstProp on opt level >= 1 r? `@JakobDegen`
2022-07-08Fix unreachable coverage generation for inlined functionsTomasz Miąsko-32/+40
To generate a function coverage we need at least one coverage counter, so a coverage from unreachable blocks is retained only when some live counters remain. The previous implementation incorrectly retained unreachable coverage, because it didn't account for the fact that those live counters can belong to another function due to inlining.
2022-07-08Use extend instead of repeatedly pushing into a vecTomasz Miąsko-4/+4
2022-07-07Use map_boundJack Huey-5/+4
2022-07-07Auto merge of #99024 - matthiaskrgr:rollup-8ygpcpg, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #97917 (Implement ExitCodeExt for Windows) - #98844 (Reword comments and rename HIR visiting methods.) - #98979 (interpret: use AllocRange in UninitByteAccess) - #98986 (Fix missing word in comment) - #98994 (replace process exit with more detailed exit in src/bootstrap/*.rs) - #98995 (Add a test for #80471) - #99002 (suggest adding a derive for #[default] applied to variants) - #99004 (Add a test for #70408) - #99017 (Replace boolean argument for print_where_clause with an enum to make code more clear) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-07MIR dataflow: Rename function to `always_storage_live_locals`pierwill-2/+2
Related to #99021.
2022-07-07Rollup merge of #98844 - cjgillot:deep-visit, r=jyn514Matthias Krüger-1/+1
Reword comments and rename HIR visiting methods. Sparked by this discussion in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Confused.20by.20comment.20on.20.60deep_visit_item_likes_in_module.60) r? ``@jyn514`` ``@camsteffen``
2022-07-07Auto merge of #95573 - cjgillot:lower-query, r=michaelwoeristerbors-9/+2
Make lowering a query Split from https://github.com/rust-lang/rust/pull/88186. This PR refactors the relationship between lowering and the resolver outputs in order to make lowering itself a query. In a first part, lowering is changed to avoid modifying resolver outputs, by maintaining its own data structures for creating new `NodeId`s and so. Then, the `TyCtxt` is modified to allow creating new `LocalDefId`s from inside it. This is done by: - enclosing `Definitions` in a lock, so as to allow modification; - creating a query `register_def` whose purpose is to declare a `LocalDefId` to the query system. See `TyCtxt::create_def` and `TyCtxt::iter_local_def_id` for more detailed explanations of the design.
2022-07-07make a name less ambiguousRalf Jung-4/+4
2022-07-07Reword comments and rename HIR visiting methods.Camille GILLOT-1/+1
2022-07-07Move `predecessors` from Body to BasicBlocksTomasz Miąsko-4/+4
2022-07-07Make MIR basic blocks field publicTomasz Miąsko-36/+36
This makes it possible to mutably borrow different fields of the MIR body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`. To preserve validity of control flow graph caches in the presence of modifications, a new struct `BasicBlocks` wraps together basic blocks and control flow graph caches. The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`. On the other hand a mutable access requires explicit `as_mut()` call.
2022-07-06Allow to create definitions inside the query system.Camille GILLOT-9/+2
2022-07-06fix a strange ConstProp ICERalf Jung-2/+10
2022-07-06interpret: remove LocalValue::Unallocated, add Operand::UninitRalf Jung-27/+40
Operand::Uninit is an *allocated* operand that is fully uninitialized. This lets us lazily allocate the actual backing store of *all* locals (no matter their ABI). I also reordered things in pop_stack_frame at the same time. I should probably have made that a separate commit...
2022-07-06fix ICE in ConstPropRalf Jung-3/+8
2022-07-06Rollup merge of #98884 - davidtwco:translation-on-lints-derive, r=oli-obkDylan DPC-2/+1
macros: `LintDiagnostic` derive - Move `LintDiagnosticBuilder` into `rustc_errors` so that a diagnostic derive can refer to it. - Introduce a `DecorateLint` trait, which is equivalent to `SessionDiagnostic` or `AddToDiagnostic` but for lints. Necessary without making more changes to the lint infrastructure as `DecorateLint` takes a `LintDiagnosticBuilder` and re-uses all of the existing logic for determining what type of diagnostic a lint should be emitted as (e.g. error/warning). - Various refactorings of the diagnostic derive machinery (extracting `build_field_mapping` helper and moving `sess` field out of the `DiagnosticDeriveBuilder`). - Introduce a `LintDiagnostic` derive macro that works almost exactly like the `SessionDiagnostic` derive macro except that it derives a `DecorateLint` implementation instead. A new derive is necessary for this because `SessionDiagnostic` is intended for when the generated code creates the diagnostic. `AddToDiagnostic` could have been used but it would have required more changes to the lint machinery. ~~At time of opening this pull request, ignore all of the commits from #98624, it's just the last few commits that are new.~~ r? `@oli-obk`
2022-07-06Update TypeVisitor pathsAlan Egerton-4/+5
2022-07-06enable on opt level 1Ze'ev Maor-1/+1
2022-07-05only enable ConstProp on opt level 2Ze'ev Maor-11/+2
2022-07-05lint: `LintDiagnosticBuilder` into `rustc_errors`David Wood-2/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05Auto merge of #98872 - JakobDegen:no-invalidate, r=davidtwcobors-6/+12
Add method to mutate MIR body without invalidating CFG caches. In addition to adding this method, a handful of passes are updated to use it. There's still quite a few passes that could in principle make use of this as well, but do not at the moment because they use `VisitorMut` or `MirPatch`, which needs additional support for this. The method name is slightly unwieldy, but I don't expect anyone to be writing it a lot, and at least it says what it does. If anyone has a suggestion for a better name though, would be happy to rename. r? rust-lang/mir-opt
2022-07-03Add method to mutate MIR body without invalidating CFG caches.Jakob Degen-6/+12
In addition to adding this method, a handful of passes are updated to use it.
2022-07-02Fix rust-call ICE in mir-inlinerMichael Goulet-5/+9
2022-07-02Auto merge of #97235 - nbdd0121:unwind, r=Amanieubors-6/+176
Fix FFI-unwind unsoundness with mixed panic mode UB maybe introduced when an FFI exception happens in a `C-unwind` foreign function and it propagates through a crate compiled with `-C panic=unwind` into a crate compiled with `-C panic=abort` (#96926). To prevent this unsoundness from happening, we will disallow a crate compiled with `-C panic=unwind` to be linked into `panic-abort` *if* it contains a call to `C-unwind` foreign function or function pointer. If no such call exists, then we continue to allow such mixed panic mode linking because it's sound (and stable). In fact we still need the ability to do mixed panic mode linking for std, because we only compile std once with `-C panic=unwind` and link it regardless panic strategy. For libraries that wish to remain compile-once-and-linkable-to-both-panic-runtimes, a `ffi_unwind_calls` lint is added (gated under `c_unwind` feature gate) to flag any FFI unwind calls that will cause the linkable panic runtime be restricted. In summary: ```rust #![warn(ffi_unwind_calls)] mod foo { #[no_mangle] pub extern "C-unwind" fn foo() {} } extern "C-unwind" { fn foo(); } fn main() { // Call to Rust function is fine regardless ABI. foo::foo(); // Call to foreign function, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. unsafe { foo(); } //~^ WARNING call to foreign function with FFI-unwind ABI let ptr: extern "C-unwind" fn() = foo::foo; // Call to function pointer, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. ptr(); //~^ WARNING call to function pointer with FFI-unwind ABI } ``` Fix #96926 `@rustbot` label: T-compiler F-c_unwind
2022-07-02Auto merge of #91743 - cjgillot:enable_mir_inlining_inline_all, r=oli-obkbors-33/+69
Enable MIR inlining Continuation of https://github.com/rust-lang/rust/pull/82280 by `@wesleywiser.` #82280 has shown nice compile time wins could be obtained by enabling MIR inlining. Most of the issues in https://github.com/rust-lang/rust/issues/81567 are now fixed, except the interaction with polymorphization which is worked around specifically. I believe we can proceed with enabling MIR inlining in the near future (preferably just after beta branching, in case we discover new issues). Steps before merging: - [x] figure out the interaction with polymorphization; - [x] figure out how miri should deal with extern types; - [x] silence the extra arithmetic overflow warnings; - [x] remove the codegen fulfilment ICE; - [x] remove the type normalization ICEs while compiling nalgebra; - [ ] tweak the inlining threshold.
2022-07-01cleanup mir visitor for `rustc::pass_by_value`lcnr-12/+12
2022-06-30Allow inlining `#[inline]` functions.Camille GILLOT-3/+3
2022-06-30Test enabling MIR inlinerWesley Wiser-10/+23
2022-06-30Do not error on the param_env during inlining.Camille GILLOT-8/+0
This created unexpected diagnostics while compiling alga: cannot satisfy `<Self as Module>::Ring == _` Turns out that we don't need this diagnostic as we disable inlining when it would trigger an ICE.
2022-06-30Skip inlining if there are normalization issues.Camille GILLOT-0/+40
2022-06-30Do not ICE when failing to resolve.Camille GILLOT-1/+1
2022-06-30Check history earlier.Camille GILLOT-14/+5
2022-06-28emit Retag for compound types with reference fieldsRalf Jung-5/+18
2022-06-21Auto merge of #95576 - DrMeepster:box_erasure, r=oli-obkbors-10/+270
Remove dereferencing of Box from codegen Through #94043, #94414, #94873, and #95328, I've been fixing issues caused by Box being treated like a pointer when it is not a pointer. However, these PRs just introduced special cases for Box. This PR removes those special cases and instead transforms a deref of Box into a deref of the pointer it contains. Hopefully, this is the end of the Box<T, A> ICEs.
2022-06-20Rollup merge of #98267 - compiler-errors:suggest-wildcard-arm, r=oli-obkMatthias Krüger-2/+2
Don't omit comma when suggesting wildcard arm after macro expr * Also adds `Span::eq_ctxt` to consolidate the various usages of `span.ctxt() == other.ctxt()` * Also fixes an unhygenic usage of spans which caused the suggestion to render weirdly when we had one arm match in a macro * Also always suggests a comma (i.e. even after a block) if we're rendering a wildcard arm in a single-line match (looks prettier :rose:) Fixes #94866
2022-06-20Rollup merge of #98235 - liuw:mir-gen-drop-magic-value, r=davidtwcoMatthias Krüger-2/+6
Drop magic value 3 from code Magic value 3 is used to create state for a yield point. It is in fact the number of reserved variants. Lift RESERVED_VARIANTS out to module scope and use it instead.
2022-06-20Drop magic value 3 from codeWei Liu-2/+6
Magic value 3 is used to create state for a yield point. It is in fact the number of reserved variants. Lift RESERVED_VARIANTS out to module scope and use it instead.
2022-06-19Use `Span::eq_ctxt` method instead of `.ctxt() == .ctxt()`Michael Goulet-2/+2
2022-06-19Rollup merge of #98165 - WaffleLapkin:once_things_renamings, r=m-ou-seMatthias Krüger-2/+2
once cell renamings This PR does the renamings proposed in https://github.com/rust-lang/rust/issues/74465#issuecomment-1153703128 - Move/rename `lazy::{OnceCell, Lazy}` to `cell::{OnceCell, LazyCell}` - Move/rename `lazy::{SyncOnceCell, SyncLazy}` to `sync::{OnceLock, LazyLock}` (I used `Lazy...` instead of `...Lazy` as it seems to be more consistent, easier to pronounce, etc) ```@rustbot``` label +T-libs-api -T-libs
2022-06-17Auto merge of #97863 - JakobDegen:bitset-choice, r=nnethercotebors-1/+2
`BitSet` related perf improvements This commit makes two changes: 1. Changes `MaybeLiveLocals` to use `ChunkedBitSet` 2. Overrides the `fold` method for the iterator for `ChunkedBitSet` I have local benchmarks verifying that each of these changes individually yield significant perf improvements to #96451 . I'm hoping this will be true outside of that context too. If that is not the case, I'll try to gate things on where they help as needed r? `@nnethercote` who I believe was working on closely related things, cc `@tmiasko` because of the destprop pr
2022-06-16Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock`Maybe Waffle-2/+2
2022-06-15fix box derefs in var debug infoDrMeepster-0/+31
2022-06-15condense duplicate code into seperate functionsDrMeepster-22/+45
2022-06-15fix typos & docsDrMeepster-6/+7
2022-06-15remove box derefs from codgenDrMeepster-10/+215
2022-06-14`BitSet` perf improvementsJakob Degen-1/+2
This commit makes two changes: 1. Changes `MaybeLiveLocals` to use `ChunkedBitSet` 2. Overrides the `fold` method for the iterator for `ChunkedBitSet`
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-23/+20