summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/interpret
AgeCommit message (Collapse)AuthorLines
2022-05-14Auto merge of #95826 - carbotaniuman:miri-permissive-provenance, r=RalfJungbors-5/+8
Initial work on Miri permissive-exposed-provenance Rustc portion of the changes for portions of a permissive ptr-to-int model for Miri. The main changes here are changing `ptr_get_alloc` and `get_alloc_id` to return an Option, and also making ptr-to-int casts have an expose side effect.
2022-05-13Rustc changes for permissive provenancecarbotaniuman-5/+8
2022-05-02fix most compiler/ doctestsElliot Roberts-5/+5
2022-04-21deduplicate a lot of codeb-naber-5/+1
2022-04-21implement valtree -> constvalue conversionb-naber-1/+6
2022-04-20Rollup merge of #96160 - RalfJung:interpret-debug, r=oli-obkDylan DPC-0/+8
Miri/interpreter debugging tweaks Some changes I made to make debugging Miri with trace logging less terrible. r? ``@oli-obk``
2022-04-19Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obkDylan DPC-0/+17
Miri provenance cleanup Reviewing https://github.com/rust-lang/rust/pull/95826 by ``@carbotaniuman`` made me realize that we could clean things up a little here. ``@carbotaniuman`` please let me know if you're okay with landing this (it will create a lot of conflicts with your PR), or if you'd prefer incorporating the ideas from this PR into yours. I think we want to end up in a situation where the function you called `ptr_reify_alloc` returns just two things, a concrete tag and an offset. Getting an `AllocId` from a concrete tag should be infallible like now. However a concrete tag and `Tag` don't have to be the same type. r? ``@oli-obk``
2022-04-18avoid an unnecessary call to Pointer::into_parts, and caution against ↵Ralf Jung-0/+4
into_pointer_or_addr
2022-04-18add method to get absolute address of a pointer (useful only for Miri)Ralf Jung-0/+10
2022-04-18avoid pairing up AllocId and PointerTag, which is redundantRalf Jung-0/+3
2022-04-17explain why prepare_relocation_copy works the way it doesRalf Jung-4/+11
2022-04-17add caution to some commentsRalf Jung-1/+7
2022-04-17when writing uninit to an allocation, also clear relocations like other ↵Ralf Jung-3/+9
writes do
2022-04-17add log warnings for when we overwrite parts of a pointer, and de-init the restRalf Jung-0/+8
2022-04-09Rollup merge of #95785 - RalfJung:interpret-size-mismatch, r=oli-obkDylan DPC-16/+46
interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal We did this a while ago already for `to_i32()` and friends, but missed this one. That became quite annoying when I was debugging an ICE caused by `read_pointer` in a Miri shim where the code was passing an argument at the wrong type. Having `scalar_to_ptr` be fallible is consistent with all the other `Scalar::to_*` methods being fallible. I added `unwrap` only in code outside the interpreter, which is no worse off than before now in terms of panics. r? ````@oli-obk````
2022-04-07interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internalRalf Jung-16/+46
2022-04-05trivial cfg(bootstrap) changesPietro Albini-1/+1
2022-03-31interpret: make isize::MAX the limit for dynamic value sizesRalf Jung-0/+5
2022-03-30Rollup merge of #95461 - nyurik:spelling, r=lcnrDylan DPC-1/+1
Spellchecking some comments This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30Spellchecking compiler codeYuri Astrakhan-1/+1
Address some spelling mistakes in strings, private function names, and function params.
2022-03-30Spellchecking some commentsYuri Astrakhan-1/+1
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-25Rollup merge of #95179 - b-naber:eval-in-try-unify, r=lcnrDylan DPC-0/+11
Try to evaluate in try unify and postpone resolution of constants that contain inference variables We want code like that in [`ui/const-generics/generic_const_exprs/eval-try-unify.rs`](https://github.com/rust-lang/rust/compare/master...b-naber:eval-in-try-unify?expand=1#diff-8027038201cf07a6c96abf3cbf0b0f4fdd8a64ce6292435f01c8ed995b87fe9b) to compile. To do that we need to try to evaluate constants in `try_unify_abstract_consts`, this requires us to be more careful about what constants we try to resolve, specifically we cannot try to resolve constants that still contain inference variables. r? `@lcnr`
2022-03-22erase region in ParamEnvAnd and make ConstUnifyCtxt privateb-naber-1/+4
2022-03-22fix previous failures and address reviewb-naber-1/+1
2022-03-21stall on on constants that contain infer vars in const_eval_resolveb-naber-0/+8
2022-03-17Rollup merge of #94960 - codehorseman:master, r=oli-obkDylan DPC-1/+1
Fix many spelling mistakes Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-16rustc_error: make ErrorReported impossible to constructmark-2/+2
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-15Support other types of pluralization in pluralize macroest31-1/+1
2022-03-10adjust offset_from logic: check that both pointers are in-boundsRalf Jung-0/+6
2022-03-07Introduce `ConstAllocation`.Nicholas Nethercote-18/+50
Currently some `Allocation`s are interned, some are not, and it's very hard to tell at a use point which is which. This commit introduces `ConstAllocation` for the known-interned ones, which makes the division much clearer. `ConstAllocation::inner()` is used to get the underlying `Allocation`. In some places it's natural to use an `Allocation`, in some it's natural to use a `ConstAllocation`, and in some places there's no clear choice. I've tried to make things look as nice as possible, while generally favouring `ConstAllocation`, which is the type that embodies more information. This does require quite a few calls to `inner()`. The commit also tweaks how `PartialOrd` works for `Interned`. The previous code was too clever by half, building on `T: Ord` to make the code shorter. That caused problems with deriving `PartialOrd` and `Ord` for `ConstAllocation`, so I changed it to build on `T: PartialOrd`, which is slightly more verbose but much more standard and avoided the problems.
2022-03-03Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obkbors-0/+6
Miri/CTFE: properly treat overflow in (signed) division/rem as UB To my surprise, it looks like LLVM treats overflow of signed div/rem as UB. From what I can tell, MIR `Div`/`Rem` directly lowers to the corresponding LLVM operation, so to make that correct we also have to consider these overflows UB in the CTFE/Miri interpreter engine. r? `@oli-obk`
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-10/+10
2022-03-01Miri/CTFE: properly treat overflow in (signed) division/rem as UBRalf Jung-0/+6
2022-02-25Auto merge of #94130 - erikdesjardins:partially, r=nikicbors-0/+1
Use undef for (some) partially-uninit constants There needs to be some limit to avoid perf regressions on large arrays with undef in each element (see comment in the code). Fixes: #84565 Original PR: #83698 Depends on LLVM 14: #93577
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-1/+4
2022-02-21ScalarMaybeUninit is explicitly hexadecimal in its formattingRalf Jung-1/+1
2022-02-21Rollup merge of #94203 - RalfJung:to_sized_int, r=oli-obkMatthias Krüger-21/+25
CTFE engine: Scalar: expose size-generic to_(u)int methods This matches the size-generic constructors `Scalar::from_(u)int`, and it would have helped in https://github.com/rust-lang/miri/pull/1978. r? `@oli-obk`
2022-02-21Rollup merge of #94189 - GuillaumeGomez:scalar-lower-hex, r=RalfJungMatthias Krüger-8/+12
Implement LowerHex on Scalar to clean up their display in rustdoc Follow-up of https://github.com/rust-lang/rust/pull/94091. r? ````@RalfJung````
2022-02-20CTFE engine: Scalar: expose size-generic to_(u)int methodsRalf Jung-21/+25
2022-02-20Auto merge of #94062 - Mark-Simulacrum:drop-print-cfg, r=oli-obkbors-1/+1
Move ty::print methods to Drop-based scope guards Primary goal is reducing codegen of the TLS access for each closure, which shaves ~3 seconds of bootstrap time over rustc as a whole.
2022-02-20Implement LowerHex on Scalar to clean up their display in rustdocGuillaume Gomez-8/+12
2022-02-20Rollup merge of #94091 - GuillaumeGomez:rustdoc-const-computed-value, r=oli-obkMatthias Krüger-0/+5
Fix rustdoc const computed value Fixes #85088. It looks like this now (instead of hexadecimal): ![Screenshot from 2022-02-17 17-55-39](https://user-images.githubusercontent.com/3050060/154532115-0f9861a0-406f-4c9c-957f-32bedd8aca7d.png) r? ````@oli-obk````
2022-02-19Don't render Const computed values in hexadecimal for DisplayGuillaume Gomez-0/+5
2022-02-19switch to limiting the number of init/uninit chunksErik Desjardins-0/+1
2022-02-16Move ty::print methods to Drop-based scope guardsMark Rousskov-1/+1
2022-02-16Support pretty printing of invalid constantsTomasz Miąsko-0/+8
Make it possible to pretty print invalid constants by introducing a fallible variant of `destructure_const` and falling back to debug formatting when it fails.
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-15/+15
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-15initial revertEllen-1/+1
2021-12-20better name for AdjustForForeignAbiError error variant in InterpErrorRalf Jung-4/+5