about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform
AgeCommit message (Collapse)AuthorLines
2023-11-07Add -Zcross-crate-inline-threshold=yesBen Kimock-2/+8
2023-11-05Make the randomize feature of rustc_abi additivehkalbasi-2/+2
2023-11-04Auto merge of #113343 - saethlin:looser-alignment, r=RalfJungbors-51/+54
Update the alignment checks to match rust-lang/reference#1387 Previously, we had a special case to not check `Rvalue::AddressOf` in this pass because we weren't quite sure if pointers needed to be aligned in the Place passed to it: https://github.com/rust-lang/rust/pull/112026 Since https://github.com/rust-lang/reference/pull/1387 merged, this PR updates this pass to match. The behavior of the check is nearly unchanged, except we also avoid inserting a check for creating references. Most of the changes in this PR are cleanup and new tests.
2023-11-04Check alignment of pointers only when read/written throughBen Kimock-51/+54
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-6/+6
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-11-01Auto merge of #113970 - cjgillot:assume-all-the-things, r=nikicbors-146/+183
Replace switch to unreachable by assume statements `UnreachablePropagation` currently keeps some switch terminators alive in order to ensure codegen can infer the inequalities on the discriminants. This PR proposes to encode those inequalities as `Assume` statements. This allows to simplify MIR further by removing some useless terminators.
2023-10-31Update based on wesleywiser reviewGeorge Bateman-3/+3
2023-10-31Update MIR tests for offset_ofGeorge Bateman-3/+3
2023-10-31Support enum variants in offset_of!George Bateman-1/+1
2023-10-31Only emit `!=` assumptions if the otherwise target is reachable.Camille GILLOT-7/+6
2023-10-31Refactor UninhabitedEnumBranching to mark targets unreachable.Camille GILLOT-57/+47
2023-10-31Simplify assume of a constant.Camille GILLOT-1/+18
2023-10-31Replace SwitchInt to unreachable by an assumption.Camille GILLOT-82/+117
2023-10-31Reorder passes.Camille GILLOT-8/+4
2023-10-31coverage: Replace impossible `coverage::Error` with assertionsZalathar-67/+33
Historically, these errors existed so that the coverage debug code could dump additional information before reporting a compiler bug. That debug code was removed by #115962, so we can now simplify these methods by making them panic when they detect a bug.
2023-10-31coverage: Promote some debug-only checks to always runZalathar-12/+12
These checks should be cheap, so there's little reason for them to be debug-only.
2023-10-31Auto merge of #117419 - compiler-errors:gen, r=oli-obkbors-30/+31
Some more coroutine renamings a few places where `gen_` names leaked through but should be coroutine. r? oli-obk
2023-10-31Auto merge of #117363 - saethlin:cross-crate-inline-when-inline, r=tmiaskobors-2/+7
Enable cross-crate-inlining when MIR inlining is enabled This would make https://github.com/rust-lang/rust/issues/117355 generally less obscure, and also seems like a good idea, even if for some reason someone wants MIR opts but no codegen opts.
2023-10-30Some more coroutine renamingsMichael Goulet-30/+31
2023-10-30Rollup merge of #117068 - nnethercote:clean-up-Cargo-toml, r=wesleywiserGuillaume Gomez-10/+12
Clean up `compiler/rustc*/Cargo.toml` Mostly by sorting dependencies, plus some other minor things. r? ``@wesleywiser``
2023-10-30Rollup merge of #117385 - RalfJung:deduce_param_attrs, r=oli-obkLeón Orell Valerian Liehr-0/+1
deduce_param_attrs: explain a read-only case This takes the discussion [here](https://github.com/rust-lang/rust/pull/111517/files#r1243443625) and adds it as comment in the code. Cc `@lukas-code`
2023-10-30deduce_param_attrs: explain a read-only caseRalf Jung-0/+1
2023-10-30coverage: Use a tracing span to group the parts of a sum-up expressionZalathar-1/+4
2023-10-30coverage: Inline the "recursive" worker methods for assigning countersZalathar-21/+5
Now that we don't manually pass around indent levels, there's no need for these worker methods to exist separately from their main callers.
2023-10-30coverage: Replace manual debug indents with nested tracing spansZalathar-65/+19
2023-10-30Clean up `rustc_*/Cargo.toml`.Nicholas Nethercote-10/+12
- Sort dependencies and features sections. - Add `tidy` markers to the sorted sections so they stay sorted. - Remove empty `[lib`] sections. - Remove "See more keys..." comments. Excluded files: - rustc_codegen_{cranelift,gcc}, because they're external. - rustc_lexer, because it has external use. - stable_mir, because it has external use.
2023-10-29Enable cross-crate-inlining when MIR inlining is enabledBen Kimock-2/+7
2023-10-29Auto merge of #116270 - cjgillot:gvn-aggregate, r=oli-obk,RalfJungbors-127/+644
See through aggregates in GVN This PR is extracted from https://github.com/rust-lang/rust/pull/111344 The first 2 commit are cleanups to avoid repeated work. I propose to stop removing useless assignments as part of this pass, and let a later `SimplifyLocals` do it. This makes tests easier to read (among others). The next 3 commits add a constant folding mechanism to the GVN pass, presented in https://github.com/rust-lang/rust/pull/116012. ~This pass is designed to only use global allocations, to avoid any risk of accidental modification of the stored state.~ The following commits implement opportunistic simplifications, in particular: - projections of aggregates: `MyStruct { x: a }.x` gets replaced by `a`, works with enums too; - projections of arrays: `[a, b][0]` becomes `a`; - projections of repeat expressions: `[a; N][x]` becomes `a`; - transform arrays of equal operands into a repeat rvalue. Fixes https://github.com/rust-lang/miri/issues/3090 r? `@oli-obk`
2023-10-29Auto merge of #117335 - workingjubilee:rollup-jsomm41, r=workingjubileebors-0/+5
Rollup of 5 pull requests Successful merges: - #115773 (tvOS simulator support on Apple Silicon for rustc) - #117162 (Remove `cfg_match` from the prelude) - #117311 (-Zunpretty help: add missing possible values) - #117316 (Mark constructor of `BinaryHeap` as const fn) - #117319 (explain why we don't inline when target features differ) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-38/+105
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-28explain why we don't inline when target features differRalf Jung-0/+5
2023-10-27Apply suggestions from code reviewCamille Gillot-2/+5
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-10-27Auto merge of #117166 - oli-obk:mir_const_qualif_perf, r=petrochenkovbors-3/+23
Only call `mir_const_qualif` if absolutely necessary Pull the perf change out of https://github.com/rust-lang/rust/pull/113617 This should not have any impact on behaviour (if it does, we'll see an ICE)
2023-10-27Fuse `gen` blocksOli Scherer-14/+49
2023-10-27Basic generators workOli Scherer-32/+64
2023-10-25Directly check provenance from the AllocId.Camille GILLOT-1/+1
2023-10-25Rename has_provance and tweaks comments.Camille GILLOT-3/+9
2023-10-25Verify that the alloc_id is Memory.Camille GILLOT-1/+6
2023-10-25Rollup merge of #117141 - tmiasko:inline-target-features, r=oli-obkMatthias Krüger-4/+2
Require target features to match exactly during inlining In general it is not correct to inline a callee with a target features that are subset of the callee. Require target features to match exactly during inlining. The exact match could be potentially relaxed, but this would require identifying specific feature that are allowed to differ, those that need to match, and those that can be present in caller but not in callee. This resolves MIR part of #116573. For other concerns with respect to the previous implementation also see areInlineCompatible in LLVM.
2023-10-25Only call `mir_const_qualif` if absolutely necessaryOli Scherer-3/+23
2023-10-25Do not merge fn pointer casts.Camille GILLOT-0/+9
2023-10-25Disambiguate non-deterministic constants.Camille GILLOT-44/+67
2023-10-25Take an AllocId in intern_const_alloc_for_constprop.Camille GILLOT-7/+2
2023-10-25Do not require absence of metadata.Camille GILLOT-4/+2
2023-10-25Fortify transmute check.Camille GILLOT-4/+3
2023-10-25Explain why we check variant equality.Camille GILLOT-0/+15
2023-10-25Move provenance checks out of interning method.Camille GILLOT-4/+17
2023-10-25Directly intern values instead of copying them.Camille GILLOT-3/+6
2023-10-25Do not intern GVN temps.Camille GILLOT-22/+16
2023-10-25Transform large arrays into Repeat expressions when possible.Camille GILLOT-0/+14