243 Commits

Author SHA1 Message Date
ljedrz
021a140dcd hir: remove NodeId from Block 2019-02-24 17:09:26 +01:00
Oliver Scherer
27e438ad94 Make may_normalize explicit in the type system 2019-02-16 14:54:48 +01:00
Oliver Scherer
525983a2a4 Make validity checking use MPlaceTy instead of OpTy 2019-02-16 14:54:48 +01:00
Oliver Scherer
f7c493121d Reuse the Pointer type instead of passing reassembling it at many use sites 2019-02-16 14:29:27 +01:00
Oliver Scherer
b2bf37aec0 Burn some invariants we keep up into code 2019-02-16 13:27:54 +01:00
Oliver Scherer
235a6b7d06 Expose const -> op functions that don't allow violiting const eval invariants 2019-02-16 12:32:22 +01:00
Ralf Jung
b376ae6671 make bin_op and unary_op APIs consistently work on ImmTy 2019-02-13 10:14:56 +01:00
Ralf Jung
e73f96abe7 make OpTy.op private, and ImmTy.imm public instead 2019-02-13 10:14:56 +01:00
Alexander Regueiro
c3e182cf43 rustc: doc comments 2019-02-10 23:42:32 +00:00
Taiki Endo
725af30809 librustc_mir => 2018 2019-02-08 06:28:15 +09:00
Oliver Scherer
fe50b4eb1d ConstValue::ScalarPair only needs to represent slices 2019-01-27 21:41:35 +01:00
Mazdak Farrokhzad
141fa859b8
Rollup merge of #57734 - oli-obk:fixes_and_cleanups, r=pnkfelix
Fix evaluating trivial drop glue in constants

```rust
struct A;
impl Drop for A {
    fn drop(&mut self) {}
}

const FOO: Option<A> = None;

const BAR: () = (FOO, ()).1;
```

was erroring with

```
error: any use of this value will cause an error
 --> src/lib.rs:9:1
  |
9 | const BAR: () = (FOO, ()).1;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^-^
  |                           |
  |                           calling non-const function `std::ptr::real_drop_in_place::<(std::option::Option<A>, ())> - shim(Some((std::option::Option<A>, ())))`
  |
  = note: #[deny(const_err)] on by default

error: aborting due to previous error
```

before this PR. According to godbolt this last compiled successfully in 1.27
2019-01-25 16:59:27 +01:00
Oliver Scherer
f6da141b5f Span fixup 2019-01-22 17:22:30 +01:00
Oliver Scherer
a59eabbc36 Get rid of the fake stack frame 2019-01-22 17:22:29 +01:00
Björn Steinbrink
98d4f33626 const_eval: Predetermine the layout of all locals when pushing a stack frame
Usually the layout of any locals is required at least three times, once
when it becomes live, once when it is written to, and once it is read
from. By adding a cache for them, we can reduce the number of layout
queries speeding up code that is heavy on const_eval.
2019-01-20 19:08:14 +01:00
Oliver Scherer
efda6816bd Allow evaluating trivial drop glue in constants 2019-01-18 13:31:05 +01:00
Mazdak Farrokhzad
035eff1c1f
Rollup merge of #57351 - oli-obk:cheap_const_ops, r=RalfJung
Don't actually create a full MIR stack frame when not needed

r? @dotdash

This should significantly reduce overhead during const propagation and reduce overhead *after* copy propagation (cc https://github.com/rust-lang/rust/issues/36673)
2019-01-13 05:26:43 +01:00
Oliver Scherer
dec79e4470 Not seeing the forest because there are too many trees in the way 2019-01-09 16:34:31 +01:00
Oliver Scherer
cd5a9e04da Explain the arguments of the mk_*_eval_cx functions 2019-01-09 16:27:33 +01:00
Oliver Scherer
f174b73caf Document the mk_*_eval_cx functions 2019-01-09 16:08:07 +01:00
Oliver Scherer
cea282bcfd Make mk_eval_cx private to const eval 2019-01-08 10:54:40 +01:00
Oliver Scherer
14e662d8c5 Manually push a stack frame where no valid frame is needed 2019-01-08 10:54:24 +01:00
Oliver Scherer
c0f0f457b8 Don't actually create a full MIR stack frame when not needed 2019-01-05 12:55:30 +01:00
Oliver Scherer
37a0df3e9d <&'tcx ty::Const as Deref>::deref 2019-01-01 20:05:02 +01:00
Oliver Scherer
bb9f717a80 const_to_op is now lazy_const_to_op 2019-01-01 20:05:02 +01:00
Oliver Scherer
b903cb9d60 Move the Unevaluated constant arm upwards in the type structure 2019-01-01 20:05:02 +01:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
kennytm
40dc787474
Rollup merge of #56981 - RalfJung:miri-infallible-alloc, r=oli-obk
miri: allocation is infallible
2018-12-23 02:12:08 +08:00
Ralf Jung
81a45e2038 miri: allocation is infallible 2018-12-19 14:11:01 +01:00
Dan Robertson
e7e17f9d1b
static eval: Do not ICE on layout size overflow
Layout size overflow and typeck eval errors are reported. Trigger a bug
only when the eval error is strictly labeled as TooGeneric.
2018-12-17 17:45:14 +00:00
John Kåre Alsaker
a70babed03 Use a function to access the Hir map to be able to turn it into a query later 2018-12-06 17:24:36 +01:00
Ralf Jung
261faf3ce2 machine hooks for stack push and pop, frame machine data 2018-11-25 10:49:43 +01:00
Ralf Jung
6cca7165ea pass MemoryExtra to find_foreign_static and adjust_static_allocation; they might have to create allocations 2018-11-25 10:49:43 +01:00
Ralf Jung
4c090fe310 bring back MemoryExtra 2018-11-25 10:49:43 +01:00
Eduard-Mihai Burtescu
5b4747ded7 rustc_target: avoid using AbiAndPrefAlign where possible. 2018-11-22 05:01:49 +02:00
Eduard-Mihai Burtescu
3ce8d444af rustc_target: separate out an individual Align from AbiAndPrefAlign. 2018-11-22 04:38:00 +02:00
Ralf Jung
ba82f54b04 use RawConst in miri 2018-11-19 22:42:46 +01:00
Ralf Jung
b50c1b243e Make const_eval_raw query return just an AllocId 2018-11-19 22:42:46 +01:00
Ralf Jung
303dbccf04 CTFE: dynamically make sure we do not call non-const-fn 2018-11-16 18:05:08 +01:00
bors
4ec0ba9545 Auto merge of #55716 - RalfJung:escape-to-raw, r=oli-obk
Add escape-to-raw MIR statement

Add a new MIR "ghost state statement": Escaping a ptr to permit raw accesses.

~~This includes #55549, [click here](https://github.com/RalfJung/rust/compare/miri-visitor...RalfJung:escape-to-raw) for just the new commits.~~
2018-11-15 01:12:01 +00:00
Oliver Scherer
4a9ed3f25a Use type safe VariantIdx instead of usize everywhere 2018-11-12 14:24:45 +01:00
Oliver Scherer
740fb0cbaa Use IndexVec instead of usize in librustc 2018-11-12 12:33:16 +01:00
Ralf Jung
b9a35dcb49 calling the ptr hooks no longer needs expensive preparation, remove the opt-out 2018-11-07 16:54:31 +01:00
Ralf Jung
873041009d make ValueVisitor mut-polymorphic 2018-11-05 10:15:25 +01:00
Ralf Jung
5b5e076b47 generalize the traversal part of validation to a ValueVisitor 2018-11-05 09:15:46 +01:00
Oliver Scherer
e8a22b692a Rename Value to Immediate for miri 2018-11-02 16:56:59 +01:00
Oliver Scherer
e0106d99d6 Assert that promoteds don't fail to be evaluated for being too generic 2018-10-29 14:50:30 +01:00
bors
4e88b7363b Auto merge of #55270 - RalfJung:stacked-borrows-ng, r=oli-obk
miri engine: Stacked Borrows NG

For more refined tracking in miri, we do return untagged pointers from the memory abstraction after allocations and let the caller decide how to tag these.

Also refactor the `tag_(de)reference` hooks so they can be more easily called in the ref-to-place and place-to-ref methods, and reorder things in validation: validation calls ref-to-place which (when running in miri) triggers some checks, so we want to run it rather late and catch other problems first. We also do not need to redundantly check the ref to be allocated any more, the checks miri does anyway imply thath.

r? @oli-obk
2018-10-29 03:28:31 +00:00
bors
96064eb61d Auto merge of #54487 - RalfJung:ctfe-backtrace, r=oli-obk
Delayed CTFE backtraces

This renames the env var that controls CTFE backtraces from `MIRI_BACKTRACE` to `RUST_CTFE_BACKTRACE` so that we can use `MIRI_BACKTRACE` in the miri tool to only show backtraces of the main miri execution.

It also makes `RUST_CTFE_BACKTRACE` only show backtraces that actually get rendered as errors, instead of showing them eagerly when the `Err` happens. The current behavior is near useless in miri because it shows about one gazillion backtraces for errors that we later catch and do not care about. However, @oli-obk likes the current behavior for rustc CTFE work so it is still available via `RUST_CTFE_BACKTRACE=immediate`.

NOTE: This is based on top of https://github.com/rust-lang/rust/pull/53821. Only [the last three commits](https://github.com/oli-obk/rust/compare/sanity_query...RalfJung:ctfe-backtrace) are new.

Fixes https://github.com/rust-lang/rust/issues/53355
2018-10-28 18:49:46 +00:00
Ralf Jung
b2612cbaf7 don't tag new memory inside memory.rs; add machine hook to tag new memory 2018-10-28 11:49:02 +01:00