about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2020-04-15Rollup merge of #71100 - RalfJung:miri-frame-hook, r=oli-obkMazdak Farrokhzad-2/+5
Miri: expand frame hooks This is needed to make https://github.com/rust-lang/miri/pull/1330 work. r? @oli-obk @eddyb
2020-04-15Rollup merge of #70891 - lcnr:replace-rvalue_aggregate, r=eddybMazdak Farrokhzad-1/+5
unit rvalue, use constant `()` instead of tuple fixes #70886 r? @eddyb
2020-04-15remove rustfmt-induced spurious trailing commaRalf Jung-1/+1
2020-04-15remove an impossible branch from check_constsRalf Jung-16/+5
2020-04-15Auto merge of #71106 - jonas-schievink:remove-call-guard-pass, ↵bors-5/+7
r=ecstatic-morse,RalfJung Don't always run `add_call_guards` pass It is only needed when `add_retag` runs. (the pass is run again to split critical edges before codegen, that one is required)
2020-04-15Move early needs_subst bailout to _after_ linting.jumbatm-5/+5
This ensures we get still get lints for generic contexts.
2020-04-13unit rvalue: use constant `()` instead of tupleBastian Kauschke-1/+5
2020-04-13Don't always run `add_call_guards` passJonas Schievink-5/+7
2020-04-13Miri: let machine hook dynamically decide about alignment checksRalf Jung-1/+4
2020-04-13Miri: let push_frame hook also access and mutate the rest of the frame dataRalf Jung-2/+5
2020-04-12Rollup merge of #71013 - jonas-schievink:visit-projection, r=eddybDylan DPC-35/+0
Pass the `PlaceElem::Index` local to `visit_local` Fixes https://github.com/rust-lang/rust/issues/71008 cc @rust-lang/wg-mir-opt r? @spastorino
2020-04-11Auto merge of #71014 - Centril:rollup-3lc8cnt, r=Centrilbors-1/+4
Rollup of 5 pull requests Successful merges: - #69573 (tests encoding current behavior for various cases of "binding" to _.) - #70881 (bootstrap: work around "unused attribute" errors in incremental stdlib rebuilds.) - #70957 (Normalize MIR locals' types for generator layout computation.) - #70962 (added machine hooks to track deallocations) - #70982 (Normalize function signature in function casting check procedure) Failed merges: r? @ghost
2020-04-11Rollup merge of #70957 - oli-obk:lazy_repeat_length_eval_ice, r=matthewjasperMazdak Farrokhzad-1/+4
Normalize MIR locals' types for generator layout computation. fixes #70905
2020-04-11Pass the `PlaceElem::Index` local to `visit_local`Jonas Schievink-35/+0
2020-04-10Auto merge of #70986 - marmeladema:issue70853/librustc_middle-local-def-id, ↵bors-2/+2
r=eddyb rustc_middle: return `LocalDefId` where possible in hir::map module This changes the return type of the following functions to return a `LocalDefId` instead of a `DefId`: * opt_local_def_id_from_node_id * opt_local_def_id * body_owner_def_id * local_def_id_from_node_id * get_parent_id This is another step in the right direction for #70853 This pull request will be followed by another (substantial one) which changes the return type of `local_def_id` function but this change being more invasive, we might want to wait for #70956 or #70961 (or some other form it) to land first.
2020-04-10Rollup merge of #69745 - estebank:predicate-obligations-3, r=nikomatsakis,eddybMazdak Farrokhzad-1/+1
Use `PredicateObligation`s instead of `Predicate`s Keep more information about trait binding failures. Use more specific spans by pointing at bindings that introduce obligations. Subset of #69709. r? @eddyb
2020-04-10librustc_middle: return LocalDefId instead of DefId in body_owner_def_idmarmeladema-2/+2
2020-04-09Explain why we remove `self` from storage live localsDylan MacKenzie-0/+1
2020-04-09Use new utility in `transform/generator.rs`Dylan MacKenzie-34/+40
2020-04-09Normalize MIR locals' types for generator layout computation.Oliver Scherer-1/+4
2020-04-08Use `PredicateObligation`s instead of `Predicate`sEsteban Küber-1/+1
Keep more information about trait binding failures.
2020-04-06ty: switch `Ty::walk` from `Ty` to `GenericArg`.Eduard-Mihai Burtescu-1/+10
2020-04-06Auto merge of #70771 - RalfJung:ctfe-loop, r=oli-obkbors-2/+4
Miri terminator handling: only do progress sanity check for 'Call' terminator This will still catch mistakes in bad intrinsic/foreign-item shims, which is the main source of errors here. Fixes https://github.com/rust-lang/rust/issues/70723 r? @oli-obk
2020-04-05set span more accurately during const_propRalf Jung-2/+4
2020-04-05Stop importing int/float modules in librustc_*Linus Färnstrand-1/+1
2020-04-03Rollup merge of #70595 - wesleywiser:remove_unused_discriminant_reads, r=oli-obkMazdak Farrokhzad-11/+15
Remove unused discriminant reads from MIR bodies Allow the `SimplifyLocals` pass to remove reads of discriminants if the read is never used. Fixes #70531 r? @oli-obk
2020-04-02Remove unused discriminant reads from MIR bodiesWesley Wiser-11/+15
Allow the `SimplifyLocals` pass to remove reads of discriminants if the read is never used.
2020-04-02direct imports for langitem stuffMazdak Farrokhzad-1/+1
2020-04-02nix rustc_target::abi::* reexport in ty::layoutMazdak Farrokhzad-6/+6
2020-04-01Rollup merge of #70590 - RalfJung:miri-backtrace, r=oli-obkDylan DPC-3/+0
Miri: make backtrace function names and spans match up Currently, Miri backtraces are a bit confusing: ``` error: Undefined Behavior: entering unreachable code --> tests/compile-fail/never_transmute_void.rs:10:11 | 10 | match v {} //~ ERROR entering unreachable code | ^ entering unreachable code | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information note: inside call to `f` at tests/compile-fail/never_transmute_void.rs:17:5 --> tests/compile-fail/never_transmute_void.rs:17:5 | 17 | f(v); //~ inside call to `f` | ^^^^ = note: inside call to `main` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:34 = note: inside call to closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:73 = note: inside call to closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:130:5 ``` When reading this like a normal backtrace, one would expect that e.g. the backrace involves the "main" function at "libstd/rt.rs:67:34". But that is not actually where we are in the main function, that is *where the main function is called*. This is not how backtraces are usually rendered (including e.g. with `RUST_BACKTRACE=1`). Usually we print next to each function name where inside that function the frame is currently executing, not where the *parent* frame is executing. With this PR and the Miri side at https://github.com/rust-lang/miri/pull/1283, the backtrace now looks as follows: ``` error: Undefined Behavior: entering unreachable code --> tests/compile-fail/never_transmute_void.rs:10:11 | 10 | match v {} //~ ERROR entering unreachable code | ^ entering unreachable code | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information = note: inside `f` at tests/compile-fail/never_transmute_void.rs:10:11 note: inside `main` at tests/compile-fail/never_transmute_void.rs:17:5 --> tests/compile-fail/never_transmute_void.rs:17:5 | 17 | f(v); //~ inside `main` | ^^^^ = note: inside closure at /home/r/src/rust/rustc/src/libstd/rt.rs:67:34 = note: inside closure at /home/r/src/rust/rustc/src/libstd/rt.rs:52:73 = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(1:6034 ~ std[87db]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/src/rust/rustc/src/libstd/sys_common/backtrace.rs:130:5 ``` Now function name and printed line numbers match up in the notes. This code is partially shared with const-eval, so the change also affects const-eval: instead of printing what is being called at some span, we print which function/constant this span is inside. With this, we can also remove the `span` field from Miri's stack frames (which used to track the *caller span* of that frame, quite confusing), and then get of a whole lot of `span` arguments that ultimately just served to fill that field (and as a fallback for `caller_location`, which however was never actually used). r? @oli-obk
2020-04-01Rollup merge of #70627 - spastorino:use-place-directly-its-copy, r=oli-obkMazdak Farrokhzad-41/+42
Use place directly its copy r? @oli-obk
2020-04-01Rollup merge of #70511 - ecstatic-morse:mir-dataflow-graphviz, r=davidtwcoMazdak Farrokhzad-1/+1
Add `-Z dump-mir-dataflow` flag for dumping dataflow results visualization Previously, to visualize the results of a MIR dataflow pass, one had to add a `#[rustc_mir(borrowck_graphviz_postflow)]` attribute to functions of interest. However, there is no way to specify this attribute on closures and generators, so it was impossible to view results for these MIR bodies. This PR adds a flag, `-Z dump-mir-dataflow`, which will output the dataflow results for any functions specified in `-Z dump-mir` to the output directory specified by `-Z dump-mir-dir`. This behavior is modeled on the `-Z dump-mir-graphviz` flag.
2020-03-31Use Place directly in peek_at, it's CopySantiago Pastorino-4/+4
2020-03-31Use Place directly in place_as_reborrow, it's CopySantiago Pastorino-3/+3
2020-03-31Use Place directly on Operand::place and friends, it's CopySantiago Pastorino-3/+3
2020-03-31Use Place directly, it's Copy even more use casesSantiago Pastorino-23/+24
2020-03-31Use Place directly, it's Copy more use casesSantiago Pastorino-6/+6
2020-03-31Use Place directly on check_mut_borrowing_layout_constrained_field, it's CopySantiago Pastorino-2/+2
2020-03-31remove unnecessary relocation check in const_propRalf Jung-7/+4
2020-03-30stop unnecessarily passing around span argument for Miri function callsRalf Jung-2/+0
2020-03-30remove caller span from Miri stack frameRalf Jung-1/+0
2020-03-30Use if let instead of match when only matching a single variant ↵Matthias Krüger-59/+49
(clippy::single_match) Makes code more compact and reduces nestig.
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-42/+42
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-103/+103
2020-03-30Auto merge of #70449 - ecstatic-morse:visit-body, r=oli-obkbors-6/+6
Make `Visitor::visit_body` take a plain `&Body` `ReadOnlyBodyAndCache` has replaced `&Body` in many parts of the code base that don't care about basic block predecessors. This includes the MIR `Visitor` trait, which I suspect resulted in many unnecessary changes in #64736. This reverts part of that PR to reduce the number of places where we need to pass a `ReadOnlyBodyAndCache`. In the long term, we should either give `ReadOnlyBodyAndCache` more ergonomic name and replace all uses of `&mir::Body` with it at the cost of carrying an extra pointer everywhere, or use it only in places that actually need access to the predecessor cache. Perhaps there is an even nicer alternative. r? @Nashenas88
2020-03-29Use `&` to do deref coercion for `ReadOnlyBodyAndCache`Dylan MacKenzie-6/+6
2020-03-29Rollup merge of #69702 - anyska:tylayout-rename, r=oli-obkDylan DPC-6/+6
Rename TyLayout to TyAndLayout.
2020-03-29Make `Visitor::visit_body` take a simple `Body`Dylan MacKenzie-6/+6
2020-03-28`dump_enabled` takes a `DefId` instead of `MirSource`Dylan MacKenzie-1/+1
2020-03-27Rename TyLayout to TyAndLayout.Ana-Maria Mihalache-6/+6