Commit Graph

266 Commits

Author SHA1 Message Date
Wesley Wiser
a99f255015 Allow reading non-mutable statics in const prop 2019-09-28 07:51:38 -04:00
Wesley Wiser
dcc6c28c53 Introduce a ConstPropMachine
This allows us to avoid changing things directly in the miri engine just
for const prop.
2019-09-27 20:11:13 -04:00
Wesley Wiser
9333514102 Move Ref-from-arg checking from step.rs to const_prop.rs 2019-09-27 20:11:13 -04:00
Wesley Wiser
15d2b7ae81 Respond to code review feedback and fix tidy 2019-09-27 20:11:12 -04:00
Wesley Wiser
fadfd92c2f Don't run the ConstProp MIR pass on generators
This can cause cycles as `ConstProp` uses `layout_of` which, for
generators, uses `optimized_mir` which runs `ConstProp`.
2019-09-27 20:11:12 -04:00
Wesley Wiser
c0c8ce80b3 [const-prop] Replace Ref handling with use of InterpCx 2019-09-27 20:11:12 -04:00
Wesley Wiser
9ec928ca06 [const-prop] Replace some Binaryp handling with use of InterpCx 2019-09-27 20:11:12 -04:00
Wesley Wiser
11eb91f412 [const-prop] Replace CheckedBinaryOp handling with use of InterpCx 2019-09-27 20:11:12 -04:00
Wesley Wiser
644d4f3ee9 [const-prop] Replace most UnaryOp handling with use of InterpCx 2019-09-27 20:11:12 -04:00
Wesley Wiser
1c219bb34b [const-prop] Replace NullaryOp handling with use of InterpCx 2019-09-27 20:11:12 -04:00
Wesley Wiser
ecc4cc2fc4 [const-prop] Replace Cast handling with use of InterpCx 2019-09-27 20:11:12 -04:00
Wesley Wiser
86c7c4d7be [const-prop] Replace Use handling with use of InterpCx 2019-09-27 20:11:12 -04:00
Wesley Wiser
bc17936c8a [const-prop] Replace eval_place() with use of InterpCx 2019-09-27 20:11:12 -04:00
varkor
e2e0f9af85 Rename sty to kind 2019-09-25 15:50:04 +01:00
Santiago Pastorino
87420cd1bc
Make Place Boxed on Statement to reduce size from 64 bytes to 32 bytes 2019-09-11 16:28:06 -03:00
Santiago Pastorino
e9c41148c0
Convert Place's projection to a boxed slice 2019-09-09 18:16:49 -03:00
Yuki Okushi
0cd9c1623f Fix condition and tests' flags 2019-09-02 03:40:35 +09:00
Yuki Okushi
8e9825aeb9 Fix overflow_check 2019-09-02 03:06:11 +09:00
Yuki Okushi
4a0872b37e Add overflow_check check 2019-09-02 02:18:16 +09:00
Yuki Okushi
3a6aadaa8c Add opt-level check 2019-09-02 01:05:38 +09:00
Yuki Okushi
35c9e5f122 Fix const_err with -(-0.0) 2019-09-01 22:05:50 +09:00
Ralf Jung
7677d1f771 const_prop: only call error_to_const_error if we are actually showing something 2019-08-27 22:18:25 +02:00
Wesley Wiser
4d62545687 Move def_id out add substsref 2019-08-22 06:36:30 -04:00
Wesley Wiser
f13faf58d9 Remove eval_promoted const-prop hack 2019-08-22 06:36:30 -04:00
Wesley Wiser
73814654b2 Move promoted out of mir::Body 2019-08-22 06:36:30 -04:00
Wesley Wiser
666180c324 Move 'tcx lifetime on MirPass 2019-08-22 06:36:30 -04:00
Ralf Jung
5ac2045d1e use ImmTy::from_uint in a few more spots 2019-08-17 12:56:46 +02:00
Ralf Jung
3edf099266 make both unary_op and binary_op fully typed, including a return type 2019-08-17 12:56:44 +02:00
Eduard-Mihai Burtescu
b565ece5d8 Remove redundant ty fields from mir::Constant and hair::pattern::PatternRange. 2019-08-16 15:20:27 +03:00
Ralf Jung
1b132a2f41 be less British 2019-08-02 23:31:21 +02:00
Saleem Jaffer
00d32e8687 code review fixes 2019-08-01 12:13:49 +05:30
Saleem Jaffer
0c4513e8ed code review fixes 2019-08-01 09:49:01 +05:30
Saleem Jaffer
152f0d347e code review fixes 2019-07-31 12:48:54 +05:30
Saleem Jaffer
35417e722b renaming throw_err_* to throw_* 2019-07-30 20:18:50 +05:30
Saleem Jaffer
69daf844da adding throw_ and err_ macros for InterpError 2019-07-30 15:25:12 +05:30
Saleem Jaffer
96205212e5 code review fixes 2019-07-30 12:32:43 +05:30
Saleem Jaffer
9f8b099846 code review fixes 2019-07-29 20:17:52 +05:30
Saleem Jaffer
654519d3c5 use PanicInfo and UnsupportedOpInfo 2019-07-29 13:35:59 +05:30
Saleem Jaffer
8e9d0faff2 adding a err macro for each of the InterpError variants 2019-07-29 13:35:59 +05:30
Saleem Jaffer
aa3d40cd71 tidy fixes 2019-07-29 13:35:10 +05:30
Saleem Jaffer
307798aa38 fixing fallout due to InterpError refactor 2019-07-29 13:35:09 +05:30
Ralf Jung
495f9509fe use PanicMessage type for MIR assertion errors 2019-07-24 10:24:55 +02:00
Ralf Jung
c0420b1a59 do not use InterpError::description outside librustc::mir 2019-07-24 09:12:21 +02:00
Mark Rousskov
52e9e44c7f
Rollup merge of #60951 - saleemjaffer:mir_better_error_enum, r=oli-obk
more specific errors in src/librustc/mir/interpret/error.rs

Implements [this](https://github.com/rust-rfcs/const-eval/issues/4)
2019-07-23 12:51:02 -04:00
Saleem Jaffer
3730ed9e5b renames EvalErrorPanic to PanicMessage 2019-07-23 16:42:46 +05:30
Saleem Jaffer
90426ed642 moving some variants from InterpError to EvalErrorPanic 2019-07-23 13:37:04 +05:30
Santiago Pastorino
d0accade3e Migrate from Place enum to Place struct 2019-07-20 05:08:38 +02:00
Ralf Jung
fc918a395a rename InterpretCx -> InterpCx
That's more consistent with InterpResult and InterpError.
2019-06-27 13:23:34 +02:00
bors
166c49d7a1 Auto merge of #62012 - wesleywiser:const_prop_use_ecx, r=oli-obk
Use ecx for const-prop local storage

r? @oli-obk
2019-06-24 07:48:29 +00:00
Wesley Wiser
c686130a38 Fix nits 2019-06-21 07:46:27 -04:00
Wesley Wiser
164ed087ab [const-prop] Move local storage into a Frame on InterpCx
This moves us closer to just using `InterpCx` for interpretation.
2019-06-20 21:12:10 -04:00
Wesley Wiser
573b61ae26 [const-prop] Introduce getter/setter functions 2019-06-20 21:12:10 -04:00
ljedrz
73cb9ab526 rename hir::map::get_by_hir_id to get 2019-06-20 12:50:06 +02:00
Oliver Scherer
d6fa4070be Fix rebase fallout 2019-06-19 09:52:35 +02:00
Oliver Scherer
4b6f3868b3 Make interning explicitly care about types and the mutability of memory 2019-06-19 09:52:35 +02:00
Eduard-Mihai Burtescu
afc39bbf24 Run rustfmt --file-lines ... for changes from previous commits. 2019-06-14 18:58:32 +03:00
Eduard-Mihai Burtescu
f3f9d6dfd9 Unify all uses of 'gcx and 'tcx. 2019-06-14 18:58:23 +03:00
Eduard-Mihai Burtescu
fff08cb043 Run rustfmt --file-lines ... for changes from previous commits. 2019-06-12 13:38:28 +03:00
Eduard-Mihai Burtescu
21ac960334 rustc: remove some unnecessary lifetimes in -> TyCtxt methods. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
17cdd356da rustc: replace TyCtxt<'tcx, 'gcx, 'tcx> with TyCtxt<'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
2441253508 Fix fallout from deny(unused_lifetimes). 2019-06-12 13:38:27 +03:00
Eduard-Mihai Burtescu
37799a5552 rustc: replace TyCtxt<'a, 'gcx, 'tcx> with TyCtxt<'tcx, 'gcx, 'tcx>. 2019-06-12 13:38:27 +03:00
Jad Ghalayini
80ff07f30d Changed usages of mir in librustc::mir and librustc_mir to body 2019-06-09 16:05:05 -04:00
Ralf Jung
8f05ff3e33 rename EvalResult -> InterpResult and EvalError -> InterpErrorInfo 2019-06-08 11:39:48 +02:00
Wesley Wiser
dee05ab2cc [const-prop] Handle Rvalue::Len 2019-06-06 08:31:54 -04:00
Wesley Wiser
1e50e01bb7 [const-prop] Handle ProjectionElem::Deref 2019-06-06 08:31:54 -04:00
Wesley Wiser
9f4d94b908 [const-prop] Handle Rvalue::Ref 2019-06-06 08:31:54 -04:00
Wesley Wiser
529b94ea6a [const-prop] Fix ICE when casting function pointers
This fixes an ICE when building libcore with `-Z mir-opt-level=3`.
2019-06-06 08:31:28 -04:00
Wesley Wiser
b2536781af Whitespace fixes 2019-06-04 06:30:36 -04:00
Christian Poveda
31ab573052 Add const-eval support for indirects 2019-06-03 23:53:46 -05:00
Mazdak Farrokhzad
ee08261c8c
Rollup merge of #60928 - TheSirC:fix/60229, r=eddyb
Changes the type `mir::Mir` into `mir::Body`

Fixes part 1 of #60229 (previously attempted in #60242).

I stumbled upon the issue and it seems that the previous attempt at solving it was not merged. This is a second try more up-to-date.

The commit should have changed comments as well.
At the time of writting, it passes the tidy and check tool.
2019-05-29 00:19:55 +02:00
Claude-Alban RANÉLY-VERGÉ-DÉPRÉ
6e5e0daff2 Changes the type mir::Mir into mir::Body
The commit should have changed comments as well.
At the time of writting, it passes the tidy and check tool.

Revisions asked by eddyb :
- Renamed of all the occurences of {visit/super}_mir
- Renamed test structures `CachedMir` to `Cached`

Fixing the missing import on `AggregateKind`
2019-05-28 19:17:51 +02:00
Mazdak Farrokhzad
16ef483b79
Rollup merge of #61164 - RalfJung:scalar, r=oli-obk
rename Scalar::Bits to Scalar::Raw and bits field to data

Also use this opportunity to seal some abstraction leaks (other modules constructing `Scalar::Bits` directly instead of using a constructor).

r? @oli-obk
2019-05-28 18:15:39 +02:00
Mazdak Farrokhzad
1dc9bbbffe
Rollup merge of #61247 - spastorino:eval-place-iterate, r=wesleywiser
Make eval_place iterate instead of recurse

r? @oli-obk
2019-05-28 11:49:08 +02:00
Santiago Pastorino
c3e71f210e Make eval_place iterate instead of recurse 2019-05-27 22:52:03 +02:00
Andrew Xu
46b9ed4fa1 Rename "Associated*" to "Assoc*"
We are going to uniform the terminology of all associated items.
Methods that may or may not have `self` are called "associated
functions". Because `AssociatedFn` is a bit long, we rename `Associated`
to `Assoc`.
2019-05-26 17:49:02 +08:00
Ralf Jung
082da0c698 rename Scalar::Bits to Scalar::Raw and bits field to data 2019-05-26 11:08:03 +02:00
Mazdak Farrokhzad
d8b828beea
Rollup merge of #61184 - wesleywiser:const_prop_tracing, r=oli-obk
Add additional trace statements to the const propagator

This makes it easier to figure out when const propagation fails.
2019-05-26 02:13:32 +02:00
Wesley Wiser
9bfbbd2a78 Add additional trace statements to the const propagator
This makes it easier to figure out when const propagation fails.
2019-05-25 11:02:59 -04:00
varkor
e694807650 Fix missing tcx 2019-05-25 10:07:02 +02:00
Oliver Scherer
e694b63cd1 Don't use ty::Const without immediately interning 2019-05-25 10:07:01 +02:00
Wesley Wiser
ec853ba026 [const-prop] Don't const-prop into terminators unless mir-opt-level >= 2 2019-05-19 16:47:03 -04:00
Wesley Wiser
2baab0eaaa [const-prop] Remove catch all match and add FIXME 2019-05-19 16:47:03 -04:00
Wesley Wiser
3f5c743b53 [const-prop] Support propagating into SwitchInt's discr Operand 2019-05-19 16:46:51 -04:00
Wesley Wiser
8e99c76089 [const-prop] Support propagating into Assert's cond Operand 2019-05-19 16:13:08 -04:00
Wesley Wiser
45214edf9e Run const propagation at O2 2019-05-15 06:07:06 -04:00
Wesley Wiser
317daf77de Do some simple constant propagation in the ConstProp pass 2019-05-15 06:07:06 -04:00
Eduard-Mihai Burtescu
b92b1a76e1 rustc: use DefKind instead of Def, where possible. 2019-05-03 22:50:09 +03:00
Eduard-Mihai Burtescu
a3fcab36d2 rustc: factor most DefId-containing variants out of Def and into DefKind. 2019-05-03 22:48:27 +03:00
Wesley Wiser
16fe8ccce9 Remove the self.mir field from ConstPropagator 2019-05-02 07:02:34 -04:00
Mazdak Farrokhzad
12bf981552
Rollup merge of #60428 - wesleywiser:refactor_const_eval, r=oli-obk
Refactor `eval_body_using_ecx` so that it doesn't need to query for MIR

This is the first step toward removing the `mir` field of `ConstPropagator` which will eventually allow us to actually const propagate in MIR.

r? @oli-obk
2019-05-02 01:09:28 +02:00
Wesley Wiser
eadf48e796 Refactor eval_body_using_ecx so that it doesn't need to query for MIR 2019-05-01 08:27:06 -04:00
Mazdak Farrokhzad
ada68c9d19
Rollup merge of #60276 - matthewjasper:cleanup-mir-visitor, r=estebank
Cleanup the MIR visitor

* Remove useless `BasicBlock` parameters on methods with `Location`s.
* Prefer `visit_terminator_kind` to `visit_terminator`.
* Remove `Region` from PlaceContexts. `visit_rvalue` should be used when the region is important.
* Remove unused visitor methods.
2019-04-30 03:28:38 +02:00
flip1995
e1da67e69c
Fix lint findings in librustc_mir 2019-04-28 21:19:27 +02:00
Matthew Jasper
22226fa7fb Remove region from borrow place contexts 2019-04-26 21:35:10 +01:00
Matthew Jasper
0eeab6b9a6 Remove BasicBlock parameter from mir visitor methods 2019-04-26 21:35:10 +01:00
Ralf Jung
dec24471be add Miri error variant for process exit 2019-04-19 18:48:02 +02:00
Mazdak Farrokhzad
a96e3883c1
Rollup merge of #59514 - tmandry:remove-adt-def-from-projection-elem, r=eddyb
Remove adt_def from projections and downcasts in MIR

As part of optimizing generator layouts in MIR, we'd like to allow downcasting generators to variants which do not have a corresponding `def_id`, since they are created by the compiler.

This refactor hopes to allow that, without regressing perf.

r? @eddyb
2019-04-03 04:36:12 +02:00
Tyler Mandry
4122d2221e Remove adt_def from PlaceTy and make it a struct 2019-04-02 12:02:17 -07:00
kenta7777
3c8caaca7d renames EvalErrorKind to InterpError 2019-04-02 01:02:18 +09:00