Commit Graph

570 Commits

Author SHA1 Message Date
sfzhu93
7ad307dc9d finish a pattern in enum.rs 2024-01-20 08:22:07 -08:00
sfzhu93
edba94907d update misuse of check-label 2024-01-20 08:09:14 -08:00
sfzhu93
5747eceef8 add FIXME for default_boxed_slice.rs 2024-01-14 22:35:00 -08:00
sfzhu93
cd77d59f97 update enum.rs for code review 2024-01-12 20:50:28 -08:00
sfzhu93
1c886d794c resolve code reviews 2024-01-11 23:36:09 -08:00
sfzhu93
d63f10b7ad resolve code reviews 2024-01-11 23:22:33 -08:00
sfzhu93
7135168d08 Add FileCheck for enum.rs 2024-01-08 21:58:01 -08:00
sfzhu93
1adda9a170 Add FileCheck to terminator.rs and tuple.rs 2024-01-08 20:21:23 -08:00
sfzhu93
732f6a1303 Add FileCheck to struct.rs 2024-01-08 20:21:06 -08:00
sfzhu93
d765e3ae1f Add FileCheck to slice_len.rs 2024-01-08 20:20:53 -08:00
sfzhu93
3ab1d5d450 Add FileCheck to 3 tests: self_assign_add, self_assign, and sibling_ptr 2024-01-08 20:20:27 -08:00
sfzhu93
e9152e2b6c Add FileCheck to 3 tests: ref_without_sb, repeat, repr_transparent 2024-01-08 20:19:59 -08:00
sfzhu93
9452d7ed1a Add FileCheck to 3 tests: large_array_index, mult_by_zero, and offset_of 2024-01-08 20:18:59 -08:00
sfzhu93
24aefa0e5d Add FileCheck for if.rs, inherit_overflow.rs, issue_81605.rs 2024-01-08 17:01:13 -08:00
sfzhu93
33e5d851a9 Add FileCheck for enum.rs 2024-01-07 22:03:42 -08:00
sfzhu93
e05c779ee3 Add FileCheck for checked.rs and default_boxed_slice.rs. 2024-01-07 21:16:55 -08:00
sfzhu93
1eaeaaf08b Add FileCheck for array_index.rs, boolean_identities.rs and cast.rs 2024-01-07 21:16:22 -08:00
Martin Nordholts
95eb5bcb67 rustc_mir_transform: Make DestinationPropagation stable for queries
By using FxIndexMap instead of FxHashMap, so that the order of visiting
of locals is deterministic.

We also need to bless
copy_propagation_arg.foo.DestinationPropagation.panic*.diff. Do not
review the diff of the diff. Instead look at the diff file before and
after this commit. Both before and after this commit, 3 statements are
replaced with nop. It's just that due to change in ordering, different
statements are replaced. But the net result is the same.
2024-01-05 20:55:32 +01:00
Michael Goulet
3a983ad3b0
Rollup merge of #119577 - tmiasko:lint, r=oli-obk
Migrate memory overlap check from validator to lint

The check attempts to identify potential undefined behaviour, rather
than whether MIR is well-formed. It belongs in the lint not validator.

Follow up to changes from #119077.
2024-01-05 10:57:22 -05:00
Michael Goulet
e74a0cdfed
Rollup merge of #119566 - Zalathar:remove-spanview, r=Swatinem,Nilstrieb
Remove `-Zdump-mir-spanview`

The `-Zdump-mir-spanview` flag was added back in #76074, as a development/debugging aid for the initial work on what would eventually become `-Cinstrument-coverage`. It causes the compiler to emit an HTML file containing a function's source code, with various spans highlighted based on the contents of MIR.

When the suggestion was made to [triage and remove unnecessary `-Z` flags (Zulip)](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60-Z.60.20option.20triage), I noted that this flag could potentially be worth removing, but I wanted to keep it around to see whether I found it useful for my own coverage work.

But when I actually tried to use it, I ran into various issues (e.g. it crashes on `tests/coverage/closure.rs`). If I can't trust it to work properly without a full overhaul, then instead of diving down a rabbit hole of trying to fix arcane span-handling bugs, it seems better to just remove this obscure old code entirely.

---

````@rustbot```` label +A-code-coverage
2024-01-05 10:57:21 -05:00
Tomasz Miąsko
df116ec246 Migrate memory overlap check from validator to lint
The check attempts to identify potential undefined behaviour, rather
than whether MIR is well-formed. It belongs in the lint not validator.
2024-01-04 23:32:22 +01:00
Tomasz Miąsko
a084e063e6 Fix validation and linting of injected MIR
Reevaluate `body.should_skip()` after updating the MIR phase to ensure
that injected MIR is processed correctly.

Update a few custom MIR tests that were ill-formed for the injected
phase.
2024-01-04 23:06:42 +01:00
Matthias Krüger
a919d97aaa
Rollup merge of #119325 - RalfJung:custom-mir, r=compiler-errors
custom mir: make it clear what the return block is

Custom MIR recently got support for specifying the "unwind action", so now there's two things coming after the actual call part of `Call` terminators. That's not very self-explaining so I propose we change the syntax to imitate keyword arguments:
```
Call(popped = Vec::pop(v), ReturnTo(drop), UnwindContinue())
```

Also fix some outdated docs and add some docs to `Call` and `Drop`.
2024-01-04 15:33:58 +01:00
Zalathar
af3205421f Remove -Zdump-mir-spanview 2024-01-04 13:43:27 +11:00
Nilstrieb
ffafcd8819 Update to bitflags 2 in the compiler
This involves lots of breaking changes. There are two big changes that
force changes. The first is that the bitflag types now don't
automatically implement normal derive traits, so we need to derive them
manually.

Additionally, bitflags now have a hidden inner type by default, which
breaks our custom derives. The bitflags docs recommend using the impl
form in these cases, which I did.
2023-12-30 18:17:28 +01:00
bors
8d76d07666 Auto merge of #116012 - cjgillot:gvn-const, r=oli-obk
Implement constant propagation on top of MIR SSA analysis

This implements the idea I proposed in https://github.com/rust-lang/rust/pull/110719#issuecomment-1718324700

Based on https://github.com/rust-lang/rust/pull/109597

The value numbering "GVN" pass formulates each rvalue that appears in MIR with an abstract form (the `Value` enum), and assigns an integer `VnIndex` to each. This abstract form can be used to deduplicate values, reusing an earlier local that holds the same value instead of recomputing. This part is proposed in #109597.

From this abstract representation, we can perform more involved simplifications, for example in https://github.com/rust-lang/rust/pull/111344.

With the abstract representation `Value`, we can also attempt to evaluate each to a constant using the interpreter. This builds a `VnIndex -> OpTy` map. From this map, we can opportunistically replace an operand or a rvalue with a constant if their value has an associated `OpTy`.

The most relevant commit is [Evaluated computed values to constants.](2767c4912e)"

r? `@oli-obk`
2023-12-30 03:45:58 +00:00
Michael Goulet
fcb42b42d6 Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
Ralf Jung
0f9baa8a31 custom mir: make it clear what the return block is 2023-12-26 20:15:26 +01:00
bors
2fe50cd72c Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebank
rework `-Zverbose`

implements the changes described in https://github.com/rust-lang/compiler-team/issues/706

the first commit is only a name change from `-Zverbose` to `-Zverbose-internals` and does not change behavior. the second commit changes diagnostics.

possible follow up work:
- `ty::pretty` could print more info with `--verbose` than it does currently. `-Z verbose-internals` shows too much info in a way that's not helpful to users. michael had ideas about this i didn't fully understand: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408984200
- `--verbose` should imply `-Z write-long-types-to-disk=no`. the code in `ty_string_with_limit` should take `--verbose` into account (apparently this affects `Ty::sort_string`, i'm not familiar with this code). writing a file to disk should suggest passing `--verbose`.

r? `@compiler-errors` cc `@estebank`
2023-12-26 12:27:29 +00:00
jyn
cb6d033316 don't elide shared parts of types in diagnostics when --verbose is passed
this also changes some parts of lifetime printing, which previously were not gated behind `-Z verbose`
2023-12-24 16:47:18 -05:00
Camille GILLOT
2837727471 Replace legacy ConstProp by GVN. 2023-12-24 20:08:57 +00:00
Camille GILLOT
a03c972816 Enable GVN by default. 2023-12-24 20:08:57 +00:00
Tomasz Miąsko
ba430a36c0 Enable -Zlint-mir by default for mir-opt tests 2023-12-21 00:00:00 +00:00
bors
f704f3b93b Auto merge of #119112 - Nadrieril:remove-target_blocks-hack, r=matthewjasper
match lowering: Remove the `make_target_blocks` hack

This hack was introduced 4 years ago in [`a1d0266` (#60730)](a1d0266878) to improve LLVM optimization time, specifically noticed in the `encoding` benchmark. Measurements today indicate it is no longer needed.

r? `@matthewjasper`
2023-12-19 21:15:31 +00:00
jyn
b5d8361909 rename to verbose-internals 2023-12-19 13:35:37 -05:00
Nadrieril
31bad13f82 Remove the make_target_blocks hack
It was introduced 4 years ago in a1d0266878 to improve LLVM
optimization time. Measurements today indicate it is no longer needed.
2023-12-19 11:37:39 +01:00
Camille GILLOT
8022057ebb Avoid overflow in GVN constant indexing. 2023-12-17 19:50:38 +00:00
Tomasz Miąsko
ef1831a21f End locals' live range before suspending coroutine
State transforms retains storage statements for locals that are not
stored inside a coroutine. It ensures those locals are live when
resuming by inserting StorageLive as appropriate. It forgot to end the
storage of those locals when suspending, which is fixed here.

While the end of live range is implicit when executing return, it is
nevertheless useful for inliner which would otherwise extend the live
range beyond return.
2023-12-11 23:11:20 +01:00
bors
c71c246876 Auto merge of #118550 - cjgillot:filecheck-const-prop, r=Mark-Simulacrum
Add FileCheck annotations to const_prop tests

Unblocks https://github.com/rust-lang/rust/pull/116012
Advances https://github.com/rust-lang/rust/issues/116971
2023-12-10 03:00:58 +00:00
Ralf Jung
29c95e98e3 also print 'immutable' flag 2023-12-07 17:46:36 +01:00
Camille GILLOT
30a95b7c0a FileCheck while_let_loops. 2023-12-02 21:10:04 +00:00
Camille GILLOT
c00068e49f FileCheck tuple_literal_propagation. 2023-12-02 21:08:55 +00:00
Camille GILLOT
87522d0007 FileCheck return_place. 2023-12-02 21:08:12 +00:00
Camille GILLOT
a12027e128 FileCheck switch_int. 2023-12-02 21:06:48 +00:00
Camille GILLOT
19767eb7a6 FileCheck slice_len. 2023-12-02 21:06:38 +00:00
Camille GILLOT
3e90c1b434 FileCheck scalar_literal_propagation. 2023-12-02 21:02:42 +00:00
Camille GILLOT
f3743aec51 FileCheck repeat. 2023-12-02 21:01:48 +00:00
Camille GILLOT
343ef6a9cb FileCheck reify_fn_ptr. 2023-12-02 21:00:59 +00:00
Camille GILLOT
6baec3ccc2 FileCheck ref_deref. 2023-12-02 20:58:45 +00:00
Camille GILLOT
c8c9207e4c FileCheck read_immutable_static. 2023-12-02 20:56:26 +00:00