| Age | Commit message (Collapse) | Author | Lines |
|
Propagate locals, even if they have unpropagatable assignments somewhere
Second try for https://github.com/rust-lang/rust/pull/71946#discussion_r422967292
r? @wesleywiser
cc @rust-lang/wg-mir-opt @RalfJung
|
|
|
|
obligation. This delays
the need to evaluate consts eagerly and therefore gets around const eval query cycles.
|
|
|
|
|
|
|
|
|
|
|
|
Remove `lang_items\(\).*\.unwrap\(\)`
Follows up #72170 to remove the remaining uses of `lang_items\(\).*\.unwrap\(\)` (avoids a bunch of potential ICEs when working in `#![no_core]`).
Resolves #72195
|
|
Miri interning: replace ICEs by proper errors
Fixes https://github.com/rust-lang/rust/issues/71316
I also did some refactoring, as I kept being confused by all the parameters to `intern_shallow`, some of which have invalid combinations (such as a mutable const). So instead `InternMode` now contains all the information that is needed and invalid combinations are ruled out by the type system.
Also I removed interpreter errors from interning. We already ignored almost all errors, and the `ValidationFailure` errors that we handled separately actually cannot ever happen here. The only interpreter failure that was actually reachable was the UB on dangling pointers -- and arguably, a dangling raw pointer is not UB, so the error was not even correct. It's just that the rest of the compiler does not like "dangling" `AllocId`.
It should be possible to review the 3 commits separately.
r? @oli-obk
Cc @rust-lang/wg-const-eval
|
|
[const-prop] Don't replace Rvalues that are already constants
This cleans up a few mir-opt tests which have slight changes to spans for `consts` as a result of replacing them with new Rvalues.
|
|
|
|
|
|
|
|
use `require_lang_item` over `unwrap`.
Does not yet replace all uses of `lang_items\(\)\.*\.unwrap\(\)`, as there are more
than I expected :sweat_smile:
Fixes #72099
r? @RalfJung
*edit: The goal of this this PR is to change ICE from missing lang items to a fatal error.*
|
|
Rollup of 12 pull requests
Successful merges:
- #71525 (`prefix` should not be mutable.)
- #71741 (Pointer printing: do not print 0 offset)
- #71870 (Be slightly more precise about any::type_name()'s guarantees.)
- #71909 (Document From trait for Option implementations)
- #71964 (Fix bootstrap failing on win32)
- #72137 (Clean up E0581 explanation)
- #72138 (Add doc comment for `rustc_middle::mir::mono::Linkage`)
- #72150 (Remove UnnormalizedProjection)
- #72151 (Update books)
- #72163 (docs: remove comment referencing non-existent method)
- #72169 (Clean up E0582 explanation)
- #72183 (Fix Arc::decr_strong_count doc test)
Failed merges:
r? @ghost
|
|
Remove UnnormalizedProjection
This was only used for the old chalk integration with chalk-engine
r? @nikomatsakis
|
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
Fixes #66855
|
|
|
|
|
|
|
|
|
|
strings do not have to be valid UTF-8 any more
Cc https://github.com/rust-lang/reference/pull/792
r? @oli-obk
|
|
Make MIR typeck use `LocalDefId` and fix docs
The docs on `fn type_check` were not in sync with the arguments it takes.
r? @matthewjasper
|
|
Visit move out of `_0` when visiting `return`
Closes https://github.com/rust-lang/rust/issues/72032
|
|
|
|
|
|
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
|
|
use min_specialization for some rustc crates where it requires no changes
and add FIXME for the rest
Cc @matthewjasper
|
|
|
|
Const prop aggregates even if partially or fully modified
r? @wesleywiser
cc @rust-lang/wg-mir-opt I'm moderately scared of this change, but I'm confident in having reviewed all the cases.
|
|
|
|
Co-Authored-By: Oliver Scherer <github35764891676564198441@oli-obk.de>
|
|
|
|
|
|
|
|
signature more precise
|
|
Rework MIR drop tree lowering
This PR changes how drops are generated in MIR construction. This is the first half of the fix for #47949.
Rather than generating the drops for a given unwind/break/continue/return/generator drop path as soon as they are needed, the required drops are recorded and get generated later.
The motivation for this is
* It simplifies the caching scheme, because it's now possible to walk up the currently scheduled drop tree to recover state.
* The basic block order for MIR more closely resembles execution order.
This PR also:
* Highlights cleanup blocks in the graphviz MIR output.
* Removes some unnecessary drop flag assignments.
|
|
|
|
|
|
Remove ast::{Ident, Name} reexports.
The reexport of `Symbol` into `Name` confused me.
|
|
Simplify the `tcx.alloc_map` API
This PR changes all functions that require manually locking the `alloc_map` to functions on `TyCtxt` that lock the map internally. In the same step we make the `TyCtxt::alloc_map` field private.
r? @RalfJung
|
|
|
|
|
|
|
|
Rollup of 8 pull requests
Successful merges:
- #70834 (Add core::future::{pending,ready})
- #71839 (Make BTreeMap::new and BTreeSet::new const)
- #71890 (Simplify the error Registry methods a little)
- #71942 (Shrink `LocalDecl`)
- #71947 (Dead-code pass highlights too much of impl functions)
- #71981 (Fix `strip-priv-imports` pass name in the rustdoc documentation)
- #72018 (Fix canonicalization links)
- #72031 (Better documentation for io::Read::read() return value)
Failed merges:
r? @ghost
|
|
Closure is non-capturing
|
|
Shrink `LocalDecl`
`LocalDecl` contributes 4-8% of peak heap memory usage on a range of benchmarks. This PR reduces its size from 128 bytes to 56 bytes on 64-bit, and does some clean-ups as well.
r? @matthewjasper
|
|
Renamed "undef" -> "uninit"
1. InvalidUndefBytes -> InvalidUninitBytes
2. ScalarMaybeUndef -> ScalarMaybeUninit
3. UndefMask -> InitMask
Related issue #71193
|
|
Remove old `util/liveness.rs` module
The liveness dataflow analysis now lives in the `dataflow` module, so this one is no longer necessary. I've copied the relevant bits of the module docs for `util::liveness` to `MaybeLiveLocals`. The example in the docs is now a `mir-dataflow` test: https://github.com/rust-lang/rust/blob/a08c47310c7d49cbdc5d7afb38408ba519967ecd/src/test/ui/mir-dataflow/liveness-ptr.rs#L6-L26
The borrow-checker used the same notion of "defs" and "uses", so I've moved it into a submodule. I would have moved it to `util/def_use.rs`, since it seems generally useful, but there's already a slightly [different version](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/util/def_use.rs) of the same abstraction needed for copy propagation.
|