about summary refs log tree commit diff
path: root/src/librustc/mir/interpret
AgeCommit message (Collapse)AuthorLines
2019-12-22Rollup merge of #67299 - christianpoveda:try_immty_from_int, r=RalfJungMazdak Farrokhzad-11/+27
Add `ImmTy::try_from_(u)int` methods r? @RalfJung
2019-12-22Rollup merge of #66877 - skinny121:const-eval-entry-points, r=oli-obkMazdak Farrokhzad-1/+92
Add simpler entry points to const eval for common usages. I found the `tcx.const_eval` API to be complex/awkward to work with, because of the inherent complexity from all of the different situations it is called from. Though it mainly used in one of the following ways: - Evaluates the value of a constant without any substitutions, e.g. evaluating a static, discriminant, etc. - Evaluates the value of a resolved instance of a constant. this happens when evaluating unevaluated constants or normalising trait constants. - Evaluates a promoted constant. This PR adds three new functions `const_eval_mono`, `const_eval_resolve`, and `const_eval_promoted` to `TyCtxt`, which each cater to one of the three ways `tcx.const_eval` is normally used.
2019-12-22Add error message if `Scalar::from_(u)int` failsChristian Poveda-2/+8
2019-12-22Add simpler entry points to const eval for common usages.Ben Lewis-1/+92
2019-12-21Change results to optionsChristian Poveda-6/+6
2019-12-201. ast::Mutability::{Mutable -> Mut, Immutable -> Not}.Mazdak Farrokhzad-2/+2
2. mir::Mutability -> ast::Mutability.
2019-12-14add Scalar::try_from_(u)int methodsChristian Poveda-12/+22
2019-12-07Auto merge of #66927 - RalfJung:engines-dont-panic, r=oli-obkbors-5/+21
Miri core engine: use throw_ub instead of throw_panic See https://github.com/rust-lang/rust/issues/66902 for context: panicking is not really an "interpreter error", but just part of a normal Rust execution. This is a first step towards removing the `InterpError::Panic` variant: the core Miri engine does not use it any more. ConstProp and ConstEval still use it, though. This will be addressed in future PRs. From what I can tell, all the error messages this removes are actually duplicates. r? @oli-obk @wesleywiser
2019-12-03Rollup merge of #66951 - RalfJung:miri-machine-stop, r=oli-obkMazdak Farrokhzad-0/+7
miri: add throw_machine_stop macro r? @oli-obk This helps Miri: https://github.com/rust-lang/miri/pull/1093
2019-12-02miri: add throw_machine_stop macroRalf Jung-0/+7
2019-12-02Add From instances for Pointer -> ScalarMaybeUndef and Pointer -> ImmediateRalf Jung-0/+7
2019-12-01Miri core engine: use throw_ub instead of throw_panicRalf Jung-5/+21
2019-12-01add reusable MachineStop variant to Miri engine error enumRalf Jung-16/+12
2019-12-01Rollup merge of #66832 - RalfJung:const-prop-no-alloc, r=oli-obkMazdak Farrokhzad-7/+13
const_prop: detect and avoid catching Miri errors that require allocation r? @wesleywiser @oli-obk
2019-11-29Auto merge of #66321 - ninjasource:async-fn-resume-after-completion, r=oli-obkbors-5/+9
Async fn resume after completion #65419 -- Attempting to run an async fn after completion mentions generators Not yet ready for review - work in progress Just need to run the tests on a proper build server
2019-11-28const_prop: detect and avoid catching Miri errors that require allocationRalf Jung-7/+13
2019-11-28Removed FIXME commentDavid Haig-2/+0
2019-11-28Remove duplication using single variant for errorDavid Haig-11/+11
2019-11-28SquashDavid Haig-0/+6
2019-11-28Auto merge of #66294 - davidhewitt:const_fn_memoization, r=oli-obkbors-1/+4
Add memoization for const function evaluations When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism. With thanks to @oli-obk for mentoring me through this at RustFest Barcelona. r? @oli-obk
2019-11-27Rollup merge of #66798 - bwignall:typo, r=varkorTyler Mandry-1/+1
Fix spelling typos Should be non-semantic. Uses https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines to find likely typos.
2019-11-27Add memoization for const function evaluationsDavid Hewitt-1/+4
When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism.
2019-11-27Auto merge of #66677 - wesleywiser:fix_const_prop_alloc_id_ice, r=oli-obkbors-1/+1
[const prop] Fix "alloc id without corresponding allocation" ICE r? @oli-obk
2019-11-26Fix spelling typosBrian Wignall-1/+1
2019-11-22Allow miri allocation interning to work im generic MachinesWesley Wiser-1/+1
This is necessary so that the `ComstPropMachine` can intern allocations.
2019-11-22Auto merge of #66282 - Centril:simplify-try, r=oli-obkbors-1/+1
[mir-opt] asking `?`s in a more optimized fashion This PR works towards https://github.com/rust-lang/rust/issues/66234 by providing two optimization passes meant to run in sequence: - `SimplifyArmIdentity` which transforms something like: ```rust _LOCAL_TMP = ((_LOCAL_1 as Variant ).FIELD: TY ); ((_LOCAL_0 as Variant).FIELD: TY) = move _LOCAL_TMP; discriminant(_LOCAL_0) = VAR_IDX; ``` into: ```rust _LOCAL_0 = move _LOCAL_1 ``` - `SimplifyBranchSame` which transforms `SwitchInt`s to identical basic blocks into a `goto` to the first reachable target. Together, these are meant to simplify the following into just `res`: ```rust match res { Ok(x) => Ok(x), Err(x) => Err(x), } ``` It should be noted however that the desugaring of `?` includes a function call and so the first pass in this PR relies on inlining to substitute that function call for identity on `x`. Inlining requires `mir-opt-level=2` so this might not have any effect in perf-bot but let's find out. r? @oli-obk -- This is WIP, but I'd appreciate feedback. :)
2019-11-21Introduce MIR optimizations for simplifying `x?` on `Result`s.Mazdak Farrokhzad-1/+1
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-21Aggregation of drive-by cosmetic changes.Alexander Regueiro-7/+8
2019-11-19More HashStable.Camille GILLOT-10/+3
2019-11-18Retire BraceStructLiftImpl.Camille GILLOT-1/+2
2019-11-15Rollup merge of #66410 - RalfJung:miri-machine-max, r=oli-obkYuki Okushi-0/+13
miri: helper methods for max values of machine's usize/isize We recently wanted this in Miri. r? @oli-obk
2019-11-14Update to use new librustc_error_codes libraryGuillaume Gomez-0/+2
2019-11-14miri: helper methods for max values of machine's usize/isizeRalf Jung-0/+13
2019-11-12Remove cruft.Camille GILLOT-10/+0
2019-11-12Create intermediate enum ty::ConstKind.Camille GILLOT-35/+11
2019-11-08miri: Rename to_{u,i}size to to_machine_{u,i}sizeRalf Jung-6/+6
Having a function `to_usize` that does not return a usize is somewhat confusing
2019-10-22relax ExactSizeIterator bound on write_bytes: too many iterators don't have ↵Ralf Jung-2/+5
that bound
2019-10-21Rollup merge of #65660 - varkor:canonical-const-to-bound-const, r=eddybMazdak Farrokhzad-1/+6
Rename `ConstValue::Infer(InferConst::Canonical(..))` to `ConstValue::Bound(..)` It already has the right form, so this is just a renaming. Fixes https://github.com/rust-lang/rust/issues/65655. r? @eddyb
2019-10-21Rollup merge of #65647 - nnethercote:rm-unnecessary-traits, r=CentrilMazdak Farrokhzad-2/+2
Remove unnecessary trait bounds and derivations This PR removes unnecessary trait bounds and derivations from many types. r? @nikomatsakis
2019-10-21Rename `ConstValue::Infer(InferConst::Canonical(..))` to `ConstValue::Bound(..)`varkor-1/+6
2019-10-21Remove many unnecessary trait derivations.Nicholas Nethercote-2/+2
2019-10-21remove write_repeat; it is subsumed by the new write_bytesRalf Jung-19/+0
2019-10-21points the user away from the Allocation type and towards the Memory typeRalf Jung-0/+12
2019-10-20also check the iterator is not too longRalf Jung-0/+1
2019-10-20miri add write_bytes method to Memory doing bounds-checks and supporting ↵Ralf Jung-2/+7
iterators
2019-10-18Don't ICE when evaluating writes to uninhabited enum variantsWesley Wiser-3/+4
2019-10-14Auto merge of #64987 - oli-obk:code_reuse_prevents_bugs, r=eddybbors-6/+0
Compute the layout of uninhabited structs fixes #64506 r? @eddyb
2019-10-09Pretty print function pointer const values.ben-0/+8
2019-10-04Introduce a special case in `IntRange::from_const`.Nicholas Nethercote-3/+8
The `if let Some(val) = value.try_eval_bits(...)` branch in `from_const()` is very hot for the `unicode_normalization` benchmark. This commit introduces a special-case alternative for scalars that avoids `try_eval_bits()` and all the functions it calls (`Const::eval()`, `ConstValue::try_to_bits()`, `ConstValue::try_to_scalar()`, and `Scalar::to_bits()`), instead extracting the result immediately. The type and value checking done by `Scalar::to_bits()` is replicated by moving it into a new function `Scalar::check_raw()` and using that new function in the special case. PR #64673 introduced some special-case handling of scalar types in `Const::try_eval_bits()`. This handling is now moved out of that function into the new `IntRange::integral_size_and_signed_bias` function. This commit reduces the instruction count for `unicode_normalization-check-clean` by about 10%.
2019-10-02Compute the layout of uninhabited structsOliver Scherer-6/+0