about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2019-12-18Make slice drop shims use AddressOfMatthew Jasper-9/+9
2019-12-18Start generating AddressOf rvalues in MIRMatthew Jasper-27/+20
`hir::BorrowKind::Raw` borrows and casting a reference to a raw pointer no longer do a reborrow followed by a cast. Instead we dereference and take the address.
2019-12-14add `#![feature(never_type)]` to tests as neededNiko Matsakis-0/+1
2019-12-14Revert "Remove `#![feature(never_type)]` from tests."Niko Matsakis-0/+2
This reverts commit 8f6197f39f7d468dfc5b2bd41dae4769992a2f83.
2019-12-13Const prop should finish propagation into user defined variablesWesley Wiser-4/+153
Fixes #66638
2019-12-11Auto merge of #66650 - matthewjasper:nonuniform-array-move, r=pnkfelixbors-57/+5
Remove uniform array move MIR passes This PR fixes a number of bugs caused by limitations of this pass * Projections from constant indexes weren't being canonicalized * Constant indexes from the start weren't being canonicalized (they could have different min_lengths) * It didn't apply to non-moves This PR makes the following changes to support removing this pass: * ConstantIndex of arrays are now generated in a canonical form (from the start, min_length is the actual length). * Subslices are now split when generating move paths and when checking subslices have been moved. Additionally * The parent move path of a projection from an array element is now calculated correctly closes #66502
2019-12-11Rollup merge of #67164 - matthewjasper:never-remove-const, r=oli-obkMazdak Farrokhzad-0/+28
Ensure that panicking in constants eventually errors based on #67134 closes #66975 r? @oli-obk
2019-12-09Remove `uniform_array_move_out` passesMatthew Jasper-57/+5
These passes were buggy, MIR building is now responsible for canonicalizing `ConstantIndex` projections and `MoveData` is responsible for splitting `Subslice` projections.
2019-12-09Ensure that unevaluated constants of type `!` are present in the MIRMatthew Jasper-0/+28
2019-12-06const-prop: Restrict scalar pair propagationÖmer Sinan Ağacan-0/+72
We now only propagate a scalar pair if the Rvalue is a tuple with two scalars. This for example avoids propagating a (u8, u8) value when Rvalue has type `((), u8, u8)` (see the regression test). While this is a correct thing to do, implementation is tricky and will be done later. Fixes #66971 Fixes #66339 Fixes #67019
2019-12-02Rollup merge of #66850 - eddyb:span-free-formats, r=oli-obkMazdak Farrokhzad-10/+10
rustc: hide HirId's fmt::Debug output from -Z span_free_formats. This replaces the only occurrences of `HirId {...}` from tests with paths, i.e.: ```rust [closure@HirId { owner: DefIndex(4), local_id: 15 } q:&i32, t:&T] ``` becomes, after this PR: ```rust [closure@foo<T>::{{closure}}#0 q:&i32, t:&T] ``` r? @oli-obk cc @michaelwoerister
2019-11-29SimplifyArmIdentity only for locals with the same typeTomasz Miąsko-0/+75
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-28rustc: hide HirId's fmt::Debug output from -Z span_free_formats.Eduard-Mihai Burtescu-10/+10
2019-11-27rustc: move debug info from LocalDecl and UpvarDecl into a dedicated ↵Eduard-Mihai Burtescu-37/+185
VarDebugInfo.
2019-11-27Auto merge of #66677 - wesleywiser:fix_const_prop_alloc_id_ice, r=oli-obkbors-7/+7
[const prop] Fix "alloc id without corresponding allocation" ICE r? @oli-obk
2019-11-23[const prop] Fix "alloc id without corresponding allocation" ICEWesley Wiser-7/+7
Fixes #66345
2019-11-22Rollup merge of #66587 - matthewjasper:handle-static-as-const, r=oli-obkMazdak Farrokhzad-5/+7
Handle statics in MIR as const pointers This is the first PR towards the goal of removing `PlaceBase::Static`. In this PR: * Statics are lowered to dereferencing a const pointer. * The temporaries holding such pointers are tracked in MIR, for the most part this is only used for diagnostics. There are two exceptions: * The borrow checker has some checks for thread-locals that directly use this data. * Const checking will suppress "cannot dereference raw pointer" diagnostics for pointers to `static mut`/`extern static`. This is to maintain the current behaviour (12 tests fail otherwise). The following are left to future PRs (I think that @spastorino will be working on the first 3): * Applying the same treatments to promoted statics. * Removing `PlaceBase::Static`. * Replacing `PlaceBase` with `Local`. * Moving the ever growing collection of metadata that we have for diagnostics in MIR passes somewhere more appropriate. r? @oli-obk
2019-11-21Bless remaining test outputMatthew Jasper-5/+7
2019-11-21Introduce MIR optimizations for simplifying `x?` on `Result`s.Mazdak Farrokhzad-0/+193
This optimization depends on inlining for the identity conversions introduced by the lowering of the `?`. To take advantage of `SimplifyArmIdentity`, `-Z mir-opt-level=2` is required because that triggers the inlining MIR optimization.
2019-11-21Remove `#![feature(never_type)]` from tests.Mazdak Farrokhzad-2/+0
Also remove `never_type` the feature-gate test.
2019-11-14Auto merge of #66233 - cjgillot:constkind, r=oli-obkbors-1/+1
Split ConstValue into two enums Hello, Issue #59210 appeared abandoned, so I gave it a go. Some further cleanup and refactoring may be mandated. I did not test beyond `x.py check`, since my home computer dies compiling librustc. Fixes #59210
2019-11-12Bless mir-dump test.Camille GILLOT-1/+1
2019-11-11Fix soundness issue with index bounds checksMatthew Jasper-11/+11
An expression like `x[1][{ x = y; 2}]` would perform the bounds check for the inner index operation before evaluating the outer index. This would allow out of bounds memory accesses.
2019-11-10Auto merge of #66259 - JohnTitor:rollup-x9nk1e2, r=JohnTitorbors-0/+54
Rollup of 7 pull requests Successful merges: - #65719 (Refactor sync::Once) - #65831 (Don't cast directly from &[T; N] to *const T) - #66048 (Correct error in documentation for Ipv4Addr method) - #66058 (Correct deprecated `is_global` IPv6 documentation) - #66216 ([mir-opt] Handle return place in ConstProp and improve SimplifyLocals pass) - #66217 (invalid_value lint: use diagnostic items) - #66235 (rustc_metadata: don't let LLVM confuse rmeta blobs for COFF object files.) Failed merges: r? @ghost
2019-11-10Rollup merge of #66216 - wesleywiser:const_prop_codegen_improvements, r=oli-obkYuki Okushi-0/+54
[mir-opt] Handle return place in ConstProp and improve SimplifyLocals pass Temporarily rebased on top of #66074. The top 2 commits are new. r? @oli-obk
2019-11-09Auto merge of #65694 - wesleywiser:uninhabited_enum_variants_pass, r=oli-obkbors-0/+224
[mir-opt] Implement pass to remove branches on uninhabited variants Based on discussion [here](https://github.com/rust-lang/rust/pull/64890#discussion_r333612125), this is a pass to eliminate dead code that is caused by branching on an enum with uninhabited variants. r? @oli-obk
2019-11-08[mir-opt] Handle aggregates in SimplifyLocals passWesley Wiser-3/+0
2019-11-08[mir-opt] Handle const-prop for the return placeWesley Wiser-0/+57
2019-11-08Use new `PromoteTemps` for promotionDylan MacKenzie-6/+6
2019-11-06Implement pass to remove branches on uninhabited variantsWesley Wiser-0/+224
2019-11-05rustc: remove "GlobalMetaData" dead code from hir::map::definitions.Eduard-Mihai Burtescu-8/+8
2019-11-01Auto merge of #65459 - ecstatic-morse:graphviz-subgraph, r=estebankbors-7/+4
Fix `-Zunpretty=mir-cfg` to render multiple items `-Zunpretty=mir-cfg` outputs DOT to stdout for all items being compiled. However, it puts all of these items in separate `digraph`s, which means the result of redirecting that output to a file is not valid. Most dot renderers (I have tried `dot` and `xdot`) cannot render the output. This PR checks to see if `write_mir_graphviz` will process multiple items, and writes them each as a `subgraph` in a single, top-level `digraph`. As a result, DOT can be viewed without manually editing the output file. The output is unchanged when printing a single item (e.g.`-Zunpretty=mir-cfg=item_name`). Here's the output of `xdot` for a rust file containing three items: ![three-items](https://user-images.githubusercontent.com/29463364/66889712-4bf62200-ef98-11e9-83b5-60faa2a300dd.png) The borders are a result of the nonstandard–but well-supported–[`cluster` prefix](https://graphviz.gitlab.io/_pages/doc/info/lang.html) (search for "Subgraphs and Clusters"). They will not appear if your renderer does not support this extension, but the graph will still render properly.
2019-10-25Re-enable Emscripten's exception handling supportThomas Lively-8/+8
Passes LLVM codegen and Emscripten link-time flags for exception handling if and only if the panic strategy is `unwind`. Sets the default panic strategy for Emscripten targets to `unwind`. Re-enables tests that depend on unwinding support for Emscripten, including `should_panic` tests.
2019-10-20Improve SimplifyLocals pass so it can remove unused constsWesley Wiser-1/+92
The `ConstProp` can cause many locals to be initialized to a constant value and then never read from. `ConstProp` can also evaluate ZSTs into constant values. Previously, many of these would be removed by other parts of the MIR optimization pipeline. However, evaluating ZSTs (especially `()`) into constant values defeated those parts of the optimizer and so in a2e3ed5c054b544df6ceeb9e612d39af819f4aae, I added a hack to `ConstProp` that skips evaluating ZSTs to avoid that regression. This commit changes `SimplifyLocals` so that it doesn't consider writes of const values to a local to be a use of that local. In doing so, `SimplifyLocals` is able to remove otherwise unused locals left behind by other optimization passes (`ConstProp` in particular).
2019-10-18[const-prop] Handle MIR Rvalue::BoxWesley Wiser-0/+56
2019-10-18[const-prop] Handle MIR Rvalue::DiscriminantWesley Wiser-0/+53
2019-10-18[const-prop] Handle MIR Rvalue::AggregatesWesley Wiser-0/+25
2019-10-18[const-prop] Handle MIR Rvalue::RepeatWesley Wiser-0/+37
2019-10-16Upgrade Emscripten targets to use upstream LLVM backendThomas Lively-8/+8
- Compatible with Emscripten 1.38.46-upstream or later upstream. - Refactors the Emscripten target spec to share code with other wasm targets. - Replaces the old incorrect wasm32 C call ABI with the correct one, preserving the old one as wasm32_bindgen_compat for wasm-bindgen compatibility. - Updates the varargs ABI used by Emscripten and deletes the old one. - Removes the obsolete wasm32-experimental-emscripten target. - Uses EMCC_CFLAGS on CI to avoid the timeout problems with #63649.
2019-10-16Bless graphviz test with unique identifiersDylan MacKenzie-7/+4
2019-10-11Rollup merge of #64986 - skinny121:fn-ptr-const-generics, r=varkorTyler Mandry-1/+1
Function pointers as const generic arguments Makes function pointers as const generic arguments usable. Fixes #62395 r? @varkor
2019-10-09Revert "Make `into` schedule drop for the destination"Matthew Jasper-35/+29
This reverts commit 37026837a3f23486d3cf1009d9136927168ddb33.
2019-10-09Fix reify_fn_ptr test as we now pretty print const function pointers.ben-1/+1
2019-10-04Make `into` schedule drop for the destinationMatthew Jasper-29/+35
2019-09-28Allow reading non-mutable statics in const propWesley Wiser-0/+29
2019-09-27[const-prop] Replace `Cast` handling with use of `InterpCx`Wesley Wiser-1/+1
2019-09-27[const-prop] Replace `eval_place()` with use of `InterpCx`Wesley Wiser-1/+1
2019-09-19add a mir-opt test that we don't add the spurious dropNiko Matsakis-0/+24
2019-09-19fix mir-opt testsNiko Matsakis-24/+17
2019-09-08Update tests wrt. bind_by_by_move_pattern_guards stabilization.Mazdak Farrokhzad-2/+0