Commit Graph

1400 Commits

Author SHA1 Message Date
bors
650991d62c Auto merge of #117363 - saethlin:cross-crate-inline-when-inline, r=tmiasko
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-31 00:51:25 +00:00
Guillaume Gomez
824e3677c2
Rollup merge of #117068 - nnethercote:clean-up-Cargo-toml, r=wesleywiser
Clean up `compiler/rustc*/Cargo.toml`

Mostly by sorting dependencies, plus some other minor things.

r? ``@wesleywiser``
2023-10-30 17:33:15 +01:00
León Orell Valerian Liehr
288ab16895
Rollup merge of #117385 - RalfJung:deduce_param_attrs, r=oli-obk
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-30 10:48:21 +01:00
Ralf Jung
3f7e50696f deduce_param_attrs: explain a read-only case 2023-10-30 10:29:08 +01:00
Zalathar
10c4734c79 coverage: Use a tracing span to group the parts of a sum-up expression 2023-10-30 12:46:43 +11:00
Zalathar
2f1be08473 coverage: Inline the "recursive" worker methods for assigning counters
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-30 12:46:43 +11:00
Zalathar
6d69eb1f2e coverage: Replace manual debug indents with nested tracing spans 2023-10-30 12:46:43 +11:00
Nicholas Nethercote
8ff624a9f2 Clean up rustc_*/Cargo.toml.
- 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-30 08:46:02 +11:00
Ben Kimock
e53b18f033 Enable cross-crate-inlining when MIR inlining is enabled 2023-10-29 13:20:51 -04:00
bors
83c9732e0c Auto merge of #116270 - cjgillot:gvn-aggregate, r=oli-obk,RalfJung
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-29 14:50:53 +00:00
bors
2106b63b7b Auto merge of #117335 - workingjubilee:rollup-jsomm41, r=workingjubilee
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-29 01:58:46 +00:00
bors
2cad938a81 Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errors
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-29 00:03:52 +00:00
Ralf Jung
f7985afe4f explain why we don't inline when target features differ 2023-10-28 16:50:40 +02:00
Camille Gillot
24be43356e
Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-10-27 20:51:25 +02:00
bors
10143e781b Auto merge of #117166 - oli-obk:mir_const_qualif_perf, r=petrochenkov
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-27 16:06:02 +00:00
Oli Scherer
eb66d10cc3 Fuse gen blocks 2023-10-27 15:20:44 +00:00
Oli Scherer
c892b28c02 Basic generators work 2023-10-27 13:05:48 +00:00
Camille GILLOT
856161886a Directly check provenance from the AllocId. 2023-10-25 17:59:30 +00:00
Camille GILLOT
72f0e0e795 Rename has_provance and tweaks comments. 2023-10-25 17:59:30 +00:00
Camille GILLOT
d80eb3a498 Verify that the alloc_id is Memory. 2023-10-25 17:59:30 +00:00
Matthias Krüger
a1ab16792b
Rollup merge of #117141 - tmiasko:inline-target-features, r=oli-obk
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-25 19:51:14 +02:00
Oli Scherer
57d6a6f588 Only call mir_const_qualif if absolutely necessary 2023-10-25 14:32:14 +00:00
Camille GILLOT
c4cc9ca060 Do not merge fn pointer casts. 2023-10-25 06:47:04 +00:00
Camille GILLOT
5e78b9cdb3 Disambiguate non-deterministic constants. 2023-10-25 06:46:48 +00:00
Camille GILLOT
f08dc9be17 Take an AllocId in intern_const_alloc_for_constprop. 2023-10-25 06:46:48 +00:00
Camille GILLOT
e3538d11f1 Do not require absence of metadata. 2023-10-25 06:46:48 +00:00
Camille GILLOT
59235a7907 Fortify transmute check. 2023-10-25 06:46:48 +00:00
Camille GILLOT
fbf0a0c5ff Explain why we check variant equality. 2023-10-25 06:46:48 +00:00
Camille GILLOT
ff6812cd20 Move provenance checks out of interning method. 2023-10-25 06:46:48 +00:00
Camille GILLOT
ebc87bf567 Directly intern values instead of copying them. 2023-10-25 06:46:48 +00:00
Camille GILLOT
8162dc2433 Do not intern GVN temps. 2023-10-25 06:46:48 +00:00
Camille GILLOT
dbf9ea30dd Transform large arrays into Repeat expressions when possible. 2023-10-25 06:46:48 +00:00
Camille GILLOT
80a5e8522d Extract simplify_aggregate. 2023-10-25 06:46:47 +00:00
Camille GILLOT
23d4857080 Do not compute actual aggregate type. 2023-10-25 06:46:47 +00:00
Camille GILLOT
f110f22060 Simplify repeat expressions. 2023-10-25 06:46:47 +00:00
Camille GILLOT
48d2157a89 Simplify aggregate projections. 2023-10-25 06:46:47 +00:00
Camille GILLOT
692e528647 Simplify projections in GVN. 2023-10-25 06:46:47 +00:00
Camille GILLOT
9389373127 Do not transmute immediates to non-immediates. 2023-10-25 06:46:47 +00:00
Camille GILLOT
db9bd9bd8c Do not intern too large aggregates. 2023-10-25 06:46:47 +00:00
Camille GILLOT
38c86b0798 Evaluate computed values to constants. 2023-10-25 06:46:47 +00:00
Camille GILLOT
afd631cc0c Do not visit rvalues twice. 2023-10-25 06:46:47 +00:00
Camille GILLOT
d28405972f Do not remove unused definitions inside GVN. 2023-10-25 06:46:45 +00:00
bors
df871fbf05 Auto merge of #115796 - cjgillot:const-prop-rvalue, r=oli-obk
Generate aggregate constants in DataflowConstProp.
2023-10-24 21:47:53 +00:00
Tomasz Miąsko
011b260cc8 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-24 22:49:15 +02:00
bors
cd674d6179 Auto merge of #116300 - cjgillot:split-move, r=petrochenkov
Separate move path tracking between borrowck and drop elaboration.

The primary goal of this PR is to skip creating a `MovePathIndex` for path that do not need dropping in drop elaboration.

The 2 first commits are cleanups.

The next 2 commits displace `move` errors from move-path builder to borrowck. Move-path builder keeps the same logic, but does not carry error information any more.

The remaining commits allow to filter `MovePathIndex` creation according to types. This is used in drop elaboration, to avoid computing dataflow for paths that do not need dropping.
2023-10-24 00:25:32 +00:00
bors
1322f92634 Auto merge of #107009 - cjgillot:jump-threading, r=pnkfelix
Implement jump threading MIR opt

This pass is an attempt to generalize `ConstGoto` and `SeparateConstSwitch` passes into a more complete jump threading pass.

This pass is rather heavy, as it performs a truncated backwards DFS on MIR starting from each `SwitchInt` terminator. This backwards DFS remains very limited, as it only walks through `Goto` terminators.

It is build to support constants and discriminants, and a propagating through a very limited set of operations.

The pass successfully manages to disentangle the `Some(x?)` use case and the DFA use case. It still needs a few tests before being ready.
2023-10-23 18:05:44 +00:00
Camille GILLOT
8c1b039d48 Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
Camille GILLOT
31d101093c Generate ValTrees in DataflowConstProp. 2023-10-21 16:20:46 +00:00
Camille GILLOT
c8f33ec35f Typo. 2023-10-21 12:14:17 +00:00
Camille GILLOT
547af00019 Remove on_all_drop_children_bits.
As drop elaboration only tracks places that need dropping, is has become
equivalent to `on_all_children_bits`.
2023-10-21 10:33:37 +00:00