about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/interpret
AgeCommit message (Collapse)AuthorLines
2021-02-22New mir-opt pass to simplify gotos with const valuesSimon Vandel Sillesen-0/+1
Fixes #77355
2021-02-21rustc_mir: remove redundant wrapping of return type in numeric_intrinsic()Matthias Krüger-7/+3
2021-02-20Rollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obkGuillaume Gomez-1/+1
fix MIR fn-ptr pretty-printing An uninitialized function pointer would get printed as `{{uninit fn()}` (notice the unbalanced parentheses), and a dangling fn ptr would ICE. This fixes both of that. However, I have no idea how to add tests for this. Also, I don't understand this MIR pretty-printing code. Somehow the print function `pretty_print_const_scalar` actually *returns* a transformed form of the const (but there is no doc comment explaining what is being returned); some match arms do `p!` while others do `self =`, and there's a wild mixture of `p!` and `write!`... all very mysterious and confusing.^^ r? ``@oli-obk``
2021-02-20all InterpError allocate now, so adjust alloc-error-checkRalf Jung-8/+0
2021-02-20Auto merge of #82124 - tmiasko:op-ty-ref, r=oli-obkbors-303/+346
Pass large interpreter types by reference, not value r? `@ghost`
2021-02-17remove useless ?s (clippy::needless_question_marks)Matthias Krüger-1/+1
Example code: ``` fn opts() -> Option<String> { let s: Option<String> = Some(String::new()); Some(s?) // this can just be "s" } ```
2021-02-17Reduce size of InterpErrorInfo to 8 bytesTomasz Miąsko-13/+16
2021-02-16./x.py fmtTomasz Miąsko-23/+31
2021-02-16Pass MPlaceTy by reference not valueTomasz Miąsko-59/+66
2021-02-16Pass ImmTy by reference not valueTomasz Miąsko-10/+10
2021-02-16Pass PlaceTy by reference not valueTomasz Miąsko-74/+78
2021-02-16Pass OpTy by reference not valueTomasz Miąsko-159/+159
2021-02-16Add size assertions for interpreter data structuresTomasz Miąsko-0/+24
2021-02-16fix MIR fn-ptr pretty-printingRalf Jung-1/+1
2021-02-16validation: fix invalid-fn-ptr error messageRalf Jung-1/+4
2021-02-13CTFE validation: catch ReadPointerAsBytes and better errorRalf Jung-13/+29
2021-02-11Auto merge of #81350 - tmiasko:instrument-debug, r=lcnrbors-1/+1
Reduce log level used by tracing instrumentation from info to debug Restore log level to debug to avoid make info log level overly verbose (the uses of instrument attribute modified there, were for the most part a replacement for `debug!`; one use was novel).
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-24Reduce log level used by tracing instrumentation from info to debugTomasz Miąsko-1/+1
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