Commit Graph

266 Commits

Author SHA1 Message Date
bors
6d77e45f01 Auto merge of #66866 - oli-obk:const_fn_memoization, r=RalfJung
Only memoize const fn calls during const eval

Miri and other engines may want to execute the function in order to detect UB inside of them.

r? @RalfJung
2019-12-04 17:48:19 +00:00
bors
fdc0011561 Auto merge of #64736 - Nashenas88:mir_predecessors_cache_cleanup, r=oli-obk
Remove interior mutability in mir predecessors cache
2019-12-02 14:51:02 +00:00
Paul Daniel Faria
b2fe254c98 Remove HasLocalDecls impl from BodyCache's, properly reborrow to Body, rename all body_cache back to body 2019-12-02 08:40:56 -05:00
Paul Daniel Faria
67b7a78231 Fix tidy errors 2019-12-02 08:38:16 -05:00
Paul Daniel Faria
35590b5cc8 Fix typos caused during rebase 2019-12-02 08:37:23 -05:00
Paul Daniel Faria
4de31b26d1 Fix remaining compilation issues 2019-12-02 08:37:04 -05:00
Paul Daniel Faria
fc6b58d0a8 Simplify BodyCache impl and fix all remaining type errors in librustc_mir (lifetime errors still exist) 2019-12-02 08:35:08 -05:00
Ralf Jung
5e51a153f9 fix init_allocation_extra 2019-12-02 09:03:16 +01:00
Ralf Jung
9a52543aae Assert terminator is never executed in ConstProp 2019-12-02 09:03:16 +01:00
Ralf Jung
96ea142c89 make alloc_extra machine hook a bit nicer 2019-12-02 09:03:16 +01:00
Ralf Jung
a8eea623f5 expose span to M::assert_panic, and provide helper to turn that into CallerLocation 2019-12-02 08:55:42 +01:00
Ralf Jung
b1aa3cac5b Miri: add machine hook for MIR-level assertion panics 2019-12-02 08:55:42 +01:00
Mazdak Farrokhzad
cd47551a0e
Rollup merge of #66926 - RalfJung:miri-stop, r=oli-obk
add reusable MachineStop variant to Miri engine error enum

Replace the Miri-tool-specific `Exit` error variant with something dynamically typed that all clients of the Miri engine can use.

r? @oli-obk
Cc https://github.com/rust-lang/rust/issues/66902
2019-12-02 04:09:07 +01:00
Mazdak Farrokhzad
fd09fad064
Rollup merge of #66789 - eddyb:mir-source-scope-local-data, r=oli-obk
rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.

By having one `ClearCrossCrate<SourceScopeLocalData>` for each scope, as opposed to a single `ClearCrossCrate` for all the `SourceScopeLocalData`s, we can represent the fact that some scopes have `SourceScopeLocalData` associated with them, and some don't.

This is useful when doing MIR inlining across crates, because the `ClearCrossCrate` will be `Clear` for the cross-crate MIR scopes and `Set` for the local ones.

Also see https://github.com/rust-lang/rust/pull/66203#issuecomment-555589574 for some context around this approach.

Fixes #51314.
2019-12-02 04:09:00 +01:00
Ralf Jung
4b81dd43e0 add reusable MachineStop variant to Miri engine error enum 2019-12-01 11:49:40 +01:00
Mazdak Farrokhzad
d91e63b7a2
Rollup merge of #66832 - RalfJung:const-prop-no-alloc, r=oli-obk
const_prop: detect and avoid catching Miri errors that require allocation

r? @wesleywiser @oli-obk
2019-12-01 04:49:27 +01:00
Oliver Scherer
f15197e83c find_fn -> find_mir_or_eval_fn rename 2019-11-30 17:53:02 +01:00
Eduard-Mihai Burtescu
a9976d89ed rustc: move mir::SourceScopeLocalData to a field of SourceScopeData. 2019-11-30 01:37:42 +02:00
Eduard-Mihai Burtescu
30a9978c6c rustc: move MIR source_scope_local_data's ClearCrossCrate to be around elements. 2019-11-30 01:36:51 +02:00
Ralf Jung
5d23518a12 const_prop: detect and avoid catching Miri errors that require allocation 2019-11-28 09:03:00 +01:00
David Haig
ec41fda58b Squash 2019-11-28 07:43:53 +00:00
Eduard-Mihai Burtescu
563ed27c01 rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
bors
876a72a251 Auto merge of #66677 - wesleywiser:fix_const_prop_alloc_id_ice, r=oli-obk
[const prop] Fix "alloc id without corresponding allocation" ICE

r? @oli-obk
2019-11-27 08:00:58 +00:00
Ralf Jung
b91bf7a334 miri: couple ret place and ret block together (they both exist or both don't) 2019-11-25 22:00:58 +01:00
Wesley Wiser
32e78ca2e3 Respond to CR feedback 2019-11-24 19:09:58 -05:00
Wesley Wiser
2b6815a69e [const prop] Fix "alloc id without corresponding allocation" ICE
Fixes #66345
2019-11-23 15:11:59 -05:00
Wesley Wiser
c5e762fd88 Intern allocations during constant propagation 2019-11-23 15:11:56 -05:00
bors
d1da8023da Auto merge of #66074 - wesleywiser:test_run_const_prop, r=oli-obk
[mir-opt] Turn on the `ConstProp` pass by default

perf.rlo shows that running the `ConstProp` pass results in
across-the-board wins regardless of debug or opt complilation mode. As a
result, we're turning it on to get the compile time benefits.
2019-11-19 04:38:47 +00:00
Wesley Wiser
3732b7acf1 [ConstProp] Avoid OOM crashes by not evaluating large Places
Fixes #66397
2019-11-15 18:18:50 -05:00
Wesley Wiser
d389f64cdb Fix spurious CI filures due to OOM
Fixes #66342
2019-11-15 18:18:50 -05:00
Wesley Wiser
db5fc10c21 [mir-opt] Turn on the ConstProp pass by default
perf.rlo shows that running the `ConstProp` pass results in
across-the-board wins regardless of debug or opt complilation mode. As a
result, we're turning it on to get the compile time benefits.

`ConstProp` doesn't currently intern the memory used by its `Machine` so
we can't yet propagate allocations which is why
`ConstProp::should_const_prop()` checks if the value being propagated is
a scalar or not.
2019-11-11 20:57:26 -05:00
Aaron Hill
4ecb80d5d8
Remove trampoline, pass ret and unwind when handling intrinsics 2019-11-11 15:14:37 -05:00
Aaron Hill
4f25c91a05
Fix unwinding logic 2019-11-11 15:14:33 -05:00
Aaron Hill
499eb5d831
More fixes for rustc changes 2019-11-11 15:14:32 -05:00
Wesley Wiser
8316701d37 [mir-opt] Handle const-prop for the return place 2019-11-08 22:27:27 -05:00
Adam Perry
017877cbbe Implementation of const caller_location. 2019-10-27 12:51:34 -07:00
Santiago Pastorino
d32c2865d6
Intern place projection 2019-10-22 10:33:36 -03:00
Santiago Pastorino
190802cfca
Pattern match over PlaceRef rather than Place
This prepares the code base for when projection is interned. Place's
projection field is going to be `&List<PlaceElem<'tcx>>` so we won't be
able to pattern match against it.
2019-10-22 10:33:30 -03:00
Wesley Wiser
2ec73395b9 Improve SimplifyLocals pass so it can remove unused consts
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 a2e3ed5c05, 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-20 23:49:42 -04:00
Wesley Wiser
4592a9eb3f Cleanup ConstProp::visit_statement() 2019-10-20 23:49:12 -04:00
Ralf Jung
f907fbe1a6 skip all refs-to-uninit-local, not just arguments 2019-10-20 11:22:06 +02:00
Ralf Jung
282403e6bd clarify const_prop ICE protection comment 2019-10-19 15:14:59 +02:00
Wesley Wiser
fd20dbed00 Improve comments and structure of ConstProp::const_prop()
Per code review feedback
2019-10-18 19:16:49 -04:00
Wesley Wiser
8cf6c23d66 Cleanup const_prop() some 2019-10-18 19:16:49 -04:00
Wesley Wiser
2d22063e4c [const-prop] Handle MIR Rvalue::Box 2019-10-18 19:16:49 -04:00
Wesley Wiser
4d89031e80 [const-prop] Handle MIR Rvalue::Discriminant 2019-10-18 06:29:57 -04:00
Wesley Wiser
a2e3ed5c05 [const-prop] Handle MIR Rvalue::Aggregates 2019-10-18 06:29:57 -04:00
Wesley Wiser
c8f7e18ceb [const-prop] Handle MIR Rvalue::Repeat 2019-10-18 06:29:56 -04:00
Wesley Wiser
3a8932d9b0 [const-prop] Correctly handle locals that can't be propagated
`const_prop()` now handles writing the Rvalue into the Place in the
stack frame for us. So if we're not supported to propagate that value,
we need to clear it.
2019-10-02 06:18:45 -04:00
csmoe
64f61c7888 remove indexed_vec re-export from rustc_data_structures 2019-09-29 16:48:31 +00:00