summary refs log tree commit diff
path: root/compiler/rustc_mir/src/interpret
AgeCommit message (Collapse)AuthorLines
2021-01-31Auto merge of #81327 - RalfJung:codegen-no-const-fail, r=oli-obkbors-0/+4
codegen: assume constants cannot fail to evaluate https://github.com/rust-lang/rust/pull/80579 landed, so we can finally remove this old hack from codegen and instead assume that consts never fail to evaluate. :) r? `@oli-obk`
2021-01-30codegen: assume constants cannot fail to evaluateRalf Jung-0/+4
also don't submit code to LLVM when the session has errors
2021-01-30Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-seYuki Okushi-2/+2
Stabilize `unsigned_abs` Resolves #74913. This PR stabilizes the `i*::unsigned_abs()` method, which returns the absolute value of an integer _as its unsigned equivalent_. This has the advantage that it does not overflow on `i*::MIN`. I have gone ahead and used this in a couple locations throughout the repository.
2021-01-28Auto merge of #81441 - tmiasko:ctfe-inline, r=oli-obkbors-0/+1
Try inlining trivial functions used by CTFE r? `@ghost`
2021-01-28Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakisYuki Okushi-9/+6
Refractor a few more types to `rustc_type_ir` In the continuation of #79169, ~~blocked on that PR~~. This PR: - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance` - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler. ~~I will split up that commit to make this easier to review and to have a better commit history.~~ EDIT: done, I split the PR in commits of 200-ish lines each r? `````@nikomatsakis````` cc `````@jackh726`````
2021-01-27Inline MemPlace::offsetTomasz Miąsko-0/+1
2021-01-27Rollup merge of #80900 - camelid:readpointerasbytes-ice, r=oli-obkYuki Okushi-1/+5
Fix ICE with `ReadPointerAsBytes` validation error Fixes #79690. r? ``````@oli-obk``````
2021-01-21mir: Improve size_of handling when arg is unsizedÖmer Sinan Ağacan-0/+1
2021-01-19Fix ICE in mir when evaluating SizeOf on unsized typeÖmer Sinan Ağacan-4/+7
Fixes #80742
2021-01-18Use ty::{IntTy,UintTy,FloatTy} in rustcLeSeulArtichaut-9/+6
2021-01-18Fix ICE with `ReadPointerAsBytes` validation errorCamelid-1/+5
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-3/+2
2021-01-13Use unsigned_abs throughout repositoryJacob Pratt-2/+2
2021-01-12Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelixbors-10/+11
Make CTFE able to check for UB... ... by not doing any optimizations on the `const fn` MIR used in CTFE. This means we duplicate all `const fn`'s MIR now, once for CTFE, once for runtime. This PR is for checking the perf effect, so we have some data when talking about https://github.com/rust-lang/const-eval/blob/master/rfcs/0000-const-ub.md To do this, we now have two queries for obtaining mir: `optimized_mir` and `mir_for_ctfe`. It is now illegal to invoke `optimized_mir` to obtain the MIR of a const/static item's initializer, an array length, an inline const expression or an enum discriminant initializer. For `const fn`, both `optimized_mir` and `mir_for_ctfe` work, the former returning the MIR that LLVM should use if the function is called at runtime. Similarly it is illegal to invoke `mir_for_ctfe` on regular functions. This is all checked via appropriate assertions and I don't think it is easy to get wrong, as there should be no `mir_for_ctfe` calls outside the const evaluator or metadata encoding. Almost all rustc devs should keep using `optimized_mir` (or `instance_mir` for that matter).
2021-01-10Add ABI argument to `find_mir_or_eval_fn`Nym Seddon-5/+10
Add ABI argument for called function in `find_mir_or_eval_fn` and `call_extra_fn`. Useful for comparing with expected ABI in interpreters. Related to [miri/1631](https://github.com/rust-lang/miri/issues/1631)
2021-01-04Move MIR body loading to a machine functionoli-10/+11
2021-01-04Differentiate between the availability of ctfe MIR and runtime MIRoli-1/+1
2021-01-04Keep an unoptimized duplicate of `const fn` aroundoli-1/+1
This allows CTFE to reliably detect UB, as otherwise optimizations may hide UB.
2020-12-30Rollup merge of #80491 - RalfJung:dangling-of-val, r=oli-obkMara Bos-3/+5
Miri: make size/align_of_val work for dangling raw ptrs This is needed for https://github.com/rust-lang/rust/issues/80365#issuecomment-752128105. r? `@oli-obk`
2020-12-30Auto merge of #80510 - JohnTitor:rollup-gow7y0l, r=JohnTitorbors-1/+1
Rollup of 7 pull requests Successful merges: - #80185 (Fix ICE when pointing at multi bytes character) - #80260 (slightly more typed interface to panic implementation) - #80311 (Improvements to NatVis support) - #80337 (Use `desc` as a doc-comment for queries if there are no doc comments) - #80381 (Revert "Cleanup markdown span handling") - #80492 (remove empty wraps, don't return Results from from infallible functions) - #80509 (where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-30Auto merge of #79684 - usbalbin:const_copy, r=oli-obkbors-0/+23
Make copy[_nonoverlapping] const Constifies * `intrinsics::copy` and `intrinsics::copy_nonoverlapping` * `ptr::read` and `ptr::read_unaligned` * `*const T::read` and `*const T::read_unaligned` * `*mut T::read` and `*mut T::read_unaligned` * `MaybeUninit::assume_init_read`
2020-12-30where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)Matthias Krüger-1/+1
2020-12-29Miri: make size/align_of_val work for dangling raw ptrsRalf Jung-3/+5
2020-12-26Constify intrinsics::copy[_nonoverlapping]Albin Hedman-0/+23
2020-12-20promoteds in statics may refer to staticsRalf Jung-8/+12
2020-12-17Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakisbors-1/+1
Move binder for dyn to each list item This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`. This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.` r? `@nikomatsakis`
2020-12-15Always run intrinsics lowering passTomasz Miąsko-23/+8
Move intrinsics lowering pass from the optimization phase (where it would not run if -Zmir-opt-level=0), to the drop lowering phase where it runs unconditionally. The implementation of those intrinsics in code generation and interpreter is unnecessary. Remove it.
2020-12-13Rollup merge of #79942 - JCTyblaidd:static-mem-init, r=RalfJungYuki Okushi-5/+14
Add post-init hook for static memory for miri. Adds a post-initialization hook to treat memory initialized using the interpreter as if it was initialized in a static context. See: https://github.com/rust-lang/miri/pull/1644 & https://github.com/rust-lang/miri/issues/1643
2020-12-12Auto merge of #79931 - RalfJung:no-redundant-storage-live, r=oli-obkbors-23/+16
make redundant StorageLive UB The interesting behavior of StorageLive in loops (https://github.com/rust-lang/rust/issues/42371) has been fixed, so we can now finally make it a hard error to mark a local as live that is already live. :) r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/42371
2020-12-11Move binder for dyn to each list itemJack Huey-1/+1
2020-12-11RustfmtJCTyblaidd-5/+1
2020-12-11Fix rustfmt failureJCTyblaidd-1/+1
2020-12-11Add post-initialization hook for static memory initialized using the ↵JCTyblaidd-1/+14
interpereter.
2020-12-11make redundant StorageLive UBRalf Jung-23/+16
2020-12-10CTFE: tweak abort-on-uninhabited messageRalf Jung-1/+7
2020-12-10Auto merge of #79621 - usbalbin:constier_maybe_uninit, r=RalfJungbors-3/+13
Constier maybe uninit I was playing around trying to make `[T; N]::zip()` in #79451 be `const fn`. One of the things I bumped into was `MaybeUninit::assume_init`. Is there any reason for the intrinsic `assert_inhabited<T>()` and therefore `MaybeUninit::assume_init` not being `const`? --- I have as best as I could tried to follow the instruction in [library/core/src/intrinsics.rs](https://github.com/rust-lang/rust/blob/master/library/core/src/intrinsics.rs#L11). I have no idea what I am doing but it seems to compile after some slight changes after the copy paste. Is this anywhere near how this should be done? Also any ideas for name of the feature gate? I guess `const_maybe_assume_init` is quite misleading since I have added some more methods. Should I add test? If so what should be tested?
2020-12-09Also generate `StorageDead` in constantsoli-16/+6
2020-12-07Add comment for assert_inhabited in ↵Albin Hedman-0/+2
compiler/rustc_mir/src/interpret/intrinsics.rs Co-authored-by: Ralf Jung <post@ralfj.de>
2020-12-07small `TypeVisitor` refactorBastian Kauschke-4/+5
2020-12-06Fix comments related to abort()Albin Hedman-6/+4
2020-12-05abort() now takes a msg parameterAlbin Hedman-5/+7
2020-12-03move interpret::MemoryKind::Heap to const evalVishnunarayan K I-20/+20
2020-12-03move intrinsic to CTFE, add FIXMEVishnunarayan K I-19/+3
2020-12-02Undo fn -> const fn for all intrinsics but assert_inhabitedAlbin Hedman-17/+1
2020-12-02rename MemoryKind::Heap to ConstHeap; bless testVishnunarayan K I-6/+12
2020-12-02Make some of MaybeUninit's methods constAlbin Hedman-0/+24
2020-12-01review commentsVishnunarayan K I-3/+3
2020-12-01add const_allocate intrisicVishnunarayan K I-3/+21
2020-11-26Fix new 'unnecessary trailing semicolon' warningsAaron Hill-1/+1
2020-11-21List all variants of TyKindNgo Iok Ui-1/+20