about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2021-10-08clippy::complexity fixesMatthias Krüger-3/+2
2021-10-06opt-level >= 4Alexander-3/+3
2021-10-06fix importAlexander-1/+1
2021-10-06reset and cleanupAlexander-0/+289
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-1/+1
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-04Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplettJubilee-1/+1
Stabilize `const_panic` Closes #51999 FCP completed in #89006 ```@rustbot``` label +A-const-eval +A-const-fn +T-lang cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04Auto merge of #89489 - FabianWolff:issue-89485, r=oli-obkbors-8/+34
Fix unsound optimization with explicit variant discriminants Fixes #89485.
2021-10-04Stabilize `const_panic`Jacob Pratt-1/+1
2021-10-03Disable `SimplifyBranchSame` optimization for nowFabian Wolff-0/+6
2021-10-03Update commentsFabian Wolff-8/+18
2021-10-03Remove re-export.Camille GILLOT-1/+1
2021-10-03Fix unsound optimization with explicit variant discriminantsFabian Wolff-4/+14
2021-10-02Make diangostic item names consistentCameron Steffen-1/+1
2021-10-01Auto merge of #88880 - cjgillot:no-krate, r=oli-obkbors-4/+2
Rework HIR API to make invocations of the hir_crate query harder. `hir_crate` forces the recomputation of queries that depend on it. This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.
2021-10-01Rollup merge of #89415 - wesleywiser:inliner_caller_callsite_message, ↵Manish Goregaokar-1/+1
r=michaelwoerister Correct caller/callsite confusion in inliner message `callee_body` is the MIR `Body` for the `callsite.callee` so this message basically says `"Inline {bar span} into bar"` when it should say `"Inline bar into foo"`. Extracted out of #82280
2021-09-30Correct caller/callsite confusion in inliner messageWesley Wiser-1/+1
2021-09-29Move body_owners to tcx.hir().Camille GILLOT-1/+1
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-3/+1
2021-09-28Rebase resume argument projections during state transformTomasz Miąsko-2/+3
When remapping a resume argument with projections rebase them on top of the new base. The case where resume argument has projections is unusual, but might arise with box syntax where the assignment is performed directly into the box without an intermediate temporary.
2021-09-25Auto merge of #89030 - nbdd0121:box2, r=jonas-schievinkbors-0/+4
Introduce `Rvalue::ShallowInitBox` Polished version of #88700. Implements MCP rust-lang/compiler-team#460, and should allow #43596 to go forward. In short, creating an empty box is split from a nullary-op `NullOp::Box` into two steps, first a call to `exchange_malloc`, then a `Rvalue::ShallowInitBox` which transmutes `*mut u8` to a shallow-initialized `Box<T>`. This allows the `exchange_malloc` call to unwind. Details can be found in the MCP. `NullOp::Box` is not yet removed, purely to make reverting easier in case anything goes wrong as the result of this PR. If revert is needed a reversion of "Use Rvalue::ShallowInitBox for box expression" commit followed by a test bless should be sufficient. Experiments in #88700 showed a very slight compile-time perf regression due to (supposedly) slightly more time spent in LLVM. We could omit unwind edge generation (in non-`oom=panic` case) in box expression MIR construction to restore perf; but I don't think it's necessary since runtime perf isn't affected and perf difference is rather small.
2021-09-25Introduce `Rvalue::ShallowInitBox`Gary Guo-0/+4
2021-09-22Support `#[track_caller]` on closures and generatorsAaron Hill-1/+1
This PR allows applying a `#[track_caller]` attribute to a closure/generator expression. The attribute as interpreted as applying to the compiler-generated implementation of the corresponding trait method (`FnOnce::call_once`, `FnMut::call_mut`, `Fn::call`, or `Generator::resume`). This feature does not have its own feature gate - however, it requires `#![feature(stmt_expr_attributes)]` in order to actually apply an attribute to a closure or generator. This is implemented in the same way as for functions - an extra location argument is appended to the end of the ABI. For closures, this argument is *not* part of the 'tupled' argument storing the parameters - the final closure argument for `#[track_caller]` closures is no longer a tuple. For direct (monomorphized) calls, the necessary support was already implemented - we just needeed to adjust some assertions around checking the ABI and argument count to take closures into account. For calls through a trait object, more work was needed. When creating a `ReifyShim`, we need to create a shim for the trait method (e.g. `FnOnce::call_mut`) - unlike normal functions, closures are never invoked directly, and always go through a trait method. Additional handling was needed for `InstanceDef::ClosureOnceShim`. In order to pass location information throgh a direct (monomorphized) call to `FnOnce::call_once` on an `FnMut` closure, we need to make `ClosureOnceShim` aware of `#[tracked_caller]`. A new field `track_caller` is added to `ClosureOnceShim` - this is used by `InstanceDef::requires_caller` location, allowing codegen to pass through the extra location argument. Since `ClosureOnceShim.track_caller` is only used by codegen, we end up generating two identical MIR shims - one for `track_caller == true`, and one for `track_caller == false`. However, these two shims are used by the entire crate (i.e. it's two shims total, not two shims per unique closure), so this shouldn't a big deal.
2021-09-20Migrate to 2021Mark Rousskov-1/+1
2021-09-18Do not collapse goto chains beginning with the start blockTomasz Miąsko-25/+0
If any block on a goto chain has more than one predecessor, then the new start block would have basic block predecessors. Skip the transformation for the start block altogether, to avoid violating the new invariant that the start block does not have any basic block predecessors.
2021-09-16Auto merge of #89019 - Manishearth:rollup-5qp8a5s, r=Manishearthbors-1/+1
Rollup of 10 pull requests Successful merges: - #88292 (Enable --generate-link-to-definition for rustc's docs) - #88729 (Recover from `Foo(a: 1, b: 2)`) - #88875 (cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented) - #88892 (Move object safety suggestions to the end of the error) - #88928 (Document the closure arguments for `reduce`.) - #88976 (Clean up and add doc comments for CStr) - #88983 (Allow calling `get_body_with_borrowck_facts` without `-Z polonius`) - #88985 (Update clobber_abi list to include k[1-7] regs) - #88986 (Update the backtrace crate) - #89009 (Fix typo in `break` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-15Make rustc_mir_dataflow::framework::graphviz and ↵Will Crichton-1/+1
rustc_mir_transform::MirPass public
2021-09-15Disable RemoveZsts in generators to avoid query cyclesTomasz Miąsko-0/+4
Querying layout of a generator requires its optimized MIR. Thus computing layout during MIR optimization of a generator might create a query cycle. Disable RemoveZsts in generators to avoid the issue (similar approach is used in ConstProp transform already).
2021-09-12Auto merge of #88839 - nbdd0121:alignof, r=nagisabors-2/+7
Introduce NullOp::AlignOf This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`. The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
2021-09-13Introduce NullOp::AlignOfGary Guo-2/+7
2021-09-12Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddybbors-4/+6
Add -Z panic-in-drop={unwind,abort} command-line option This PR changes `Drop` to abort if an unwinding panic attempts to escape it, making the process abort instead. This has several benefits: - The current behavior when unwinding out of `Drop` is very unintuitive and easy to miss: unwinding continues, but the remaining drops in scope are simply leaked. - A lot of unsafe code doesn't expect drops to unwind, which can lead to unsoundness: - https://github.com/servo/rust-smallvec/issues/14 - https://github.com/bluss/arrayvec/issues/3 - There is a code size and compilation time cost to this: LLVM needs to generate extra landing pads out of all calls in a drop implementation. This can compound when functions are inlined since unwinding will then continue on to process drops in the callee, which can itself unwind, etc. - Initial measurements show a 3% size reduction and up to 10% compilation time reduction on some crates (`syn`). One thing to note about `-Z panic-in-drop=abort` is that *all* crates must be built with this option for it to be sound since it makes the compiler assume that dropping `Box<dyn Any>` will never unwind. cc https://github.com/rust-lang/lang-team/issues/97
2021-09-12Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnrManish Goregaokar-1/+0
generic_const_exprs: use thir for abstract consts instead of mir Changes `AbstractConst` building to use `thir` instead of `mir` so that there's less chance of consts unifying when they shouldn't because lowering to mir dropped information (see `abstract-consts-as-cast-5.rs` test) r? `@lcnr`
2021-09-11Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkovbors-1/+5
Encode spans relative to the enclosing item The aim of this PR is to avoid recomputing queries when code is moved without modification. MCP at https://github.com/rust-lang/compiler-team/issues/443 This is achieved by : 1. storing the HIR owner LocalDefId information inside the span; 2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache; 3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation. Since all client code uses `Span`, step 3 ensures that all manipulations of span byte positions actually create the dependency edge between the caller and the `source_span(LocalDefId)`. This query return the actual absolute span of the parent item. As a consequence, any source code motion that changes the absolute byte position of a node will either: - modify the distance to the parent's beginning, so change the relative span's hash; - dirty `source_span`, and trigger the incremental recomputation of all code that depends on the span's absolute byte position. With this scheme, I believe the dependency tracking to be accurate. For the moment, the spans are marked during lowering. I'd rather do this during def-collection, but the AST MutVisitor is not practical enough just yet. The only difference is that we attach macro-expanded spans to their expansion point instead of the macro itself.
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-5/+3
2021-09-10Keep a parent LocalDefId in SpanData.Camille GILLOT-1/+5
2021-09-10Treat drop_in_place as nounwind with -Z panic-in-drop=abortAmanieu d'Antras-4/+6
The AbortUnwindCalls MIR pass will eliminate any unnecessary cleanups and will prevent any unwinds from leaking out by forcing an abort.
2021-09-09Ignore automatically derived impls of `Clone` and `Debug` in dead code analysisFabian Wolff-1/+1
2021-09-08Bump stage0 compiler to 1.56Mark Rousskov-1/+0
2021-09-09rename mir -> thir around abstract constsEllen-1/+0
2021-09-08Rebase fallout.Camille GILLOT-1/+2
2021-09-07Rename rustc_mir to rustc_const_eval.Camille GILLOT-9/+9
2021-09-07Move the dataflow framework to its own crate.Camille GILLOT-63/+56
2021-09-07Move rustc_mir::transform to rustc_mir_transform.Camille GILLOT-0/+17732