Scott McMurray
05a665f21a
Lower intrinsics::offset
to mir::BinOp::Offset
...
They're semantically the same, so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-25 19:23:45 -07:00
Camille GILLOT
b275d2c30b
Remove WithOptconstParam.
2023-04-20 17:48:32 +00:00
Gary Guo
5e6ed132fa
Add UnwindAction::Unreachable
...
This also makes eval machine's `StackPopUnwind`
redundant so that is replaced.
2023-04-06 09:34:16 +01:00
Gary Guo
daeb844e0c
Refactor unwind from Option to a new enum
2023-04-06 09:34:16 +01:00
Ben Kimock
8ccf53332e
A MIR transform that checks pointers are aligned
2023-03-23 18:23:06 -04:00
Oli Scherer
f066d6785d
Detect uninhabited types early in const eval.
2023-03-21 11:09:27 +00:00
Oli Scherer
83dec62b26
Add a layout argument to enforce_validity
.
...
This is in preparation of checking the validity only of certain types.
2023-03-21 08:52:31 +00:00
Oli Scherer
38b7cdf393
Use target instead of machine for mir interpreter integer handling.
...
The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform
2023-02-15 08:56:18 +00:00
Maybe Waffle
fd649a3cc5
Replace enum ==
s with match
es where it makes sense
2023-01-30 12:26:26 +00:00
Bryan Garza
7618163a1c
Add comments and remove unnecessary code
2023-01-23 23:56:22 +00:00
Bryan Garza
172662dede
Add back Machine::before_terminator(...) method
...
Added it back because it's used by Miri, but in the compiler itself, it
will not do anything (just return `Ok(())`.
2023-01-23 23:56:22 +00:00
Bryan Garza
eea42733ac
Replace terminator-based const eval limit
...
- Remove logic that limits const eval based on terminators, and use the
stable metric instead (back edges + fn calls)
- Add unstable flag `tiny-const-eval-limit` to add UI tests that do not
have to go up to the regular 2M step limit
2023-01-23 23:56:22 +00:00
Bryan Garza
b763f9094f
Remove debugging-related code
2023-01-23 23:56:22 +00:00
Bryan Garza
360db516cc
Create stable metric to measure long computation in Const Eval
...
This patch adds a `MirPass` that tracks the number of back-edges and
function calls in the CFG, adds a new MIR instruction to increment a
counter every time they are encountered during Const Eval, and emit a
warning if a configured limit is breached.
2023-01-23 23:56:22 +00:00
bors
56ee85274e
Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstrieb
...
Remove some `ref` patterns from the compiler
Previous PR: https://github.com/rust-lang/rust/pull/105368
r? `@Nilstrieb`
2023-01-20 04:52:28 +00:00
Scott McMurray
925dc37313
Stop using BREAK
& CONTINUE
in compiler
...
Switching them to `Break(())` and `Continue(())` instead.
libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
2023-01-17 23:17:51 -08:00
Maybe Waffle
6a28fb42a8
Remove double spaces after dots in comments
2023-01-17 08:09:33 +00:00
Maybe Waffle
3dca58e249
rustc_const_eval
: remove ref
patterns (+some pattern matching imps)
2023-01-17 07:48:19 +00:00
Ralf Jung
5a06b1e67c
simplify alignment_check_failed a bit
2022-12-15 16:48:30 +00:00
Oli Scherer
b05c790fd6
Reuse the ctfe error emitting logic for the future incompat lint
2022-12-15 16:48:24 +00:00
Oli Scherer
d9d92ed7da
Move alignment failure error reporting to machine
2022-12-15 16:07:35 +00:00
Oli Scherer
d66824dbc4
Make alignment checks a future incompat lint
2022-12-15 16:07:28 +00:00
Rageking8
58110572fb
fix dupe word typos
2022-12-05 16:42:36 +08:00
Lukas Markeffsky
3d7e9c4b7f
Revert "don't call align_offset
during const eval, ever"
...
This reverts commit f3a577bfae376c0222e934911865ed14cddd1539.
2022-11-19 16:58:02 +01:00
Lukas Markeffsky
9e5d497b67
fix const align_offset
implementation
2022-11-19 16:57:58 +01:00
Lukas Markeffsky
60f352fd7d
replace potential ICE with graceful error (no_core
only)
2022-11-19 16:47:42 +01:00
Lukas Markeffsky
a906f6cb69
don't call align_offset
during const eval, ever
2022-11-19 16:47:42 +01:00
Lukas Markeffsky
211743b2c8
make const align_offset
useful
2022-11-19 16:36:08 +01:00
Lukas Markeffsky
f770fecfe1
unify inherent impls of CompileTimeEvalContext
2022-11-19 16:36:08 +01:00
CastilloDel
c3a1ca6be7
Remove allow(rustc::potential_query_instability) in rustc_const_eval
...
The use of FxHashMap has been replaced with FxIndexMap. For
more information see https://github.com/rust-lang/rust/issues/84447
2022-10-18 17:44:01 +02:00
Oli Scherer
f632dbe46f
The <*const T>::guaranteed_*
methods now return an option for the unknown case
2022-09-09 15:16:04 +00:00
Deadbeef
075084f772
Make const_eval_select
a real intrinsic
2022-09-04 20:35:23 +08:00
Ralf Jung
f29c3c421b
entirely get rid of NeedsRfc CTFE errors
2022-08-28 13:40:24 -04:00
Ralf Jung
a9f9145b09
CTFE: exposing pointers and calling extern fn doesn't need an RFC, it is just impossible
2022-08-28 13:32:48 -04:00
Matthias Krüger
5b8081490f
Rollup merge of #101038 - RalfJung:interning-alignment, r=oli-obk
...
no alignment check during interning
This should fix https://github.com/rust-lang/rust/issues/101034
r? `@oli-obk`
Unfortunately we don't have a self-contained testcase for this problem. I am not sure how it can be triggered...
2022-08-28 09:35:19 +02:00
Ralf Jung
30fa931f92
make read_immediate error immediately on uninit, so ImmTy can carry initialized Scalar
2022-08-26 13:20:57 -04:00
Ralf Jung
b85178a5fc
no alignment check during interning
2022-08-26 08:15:29 -04:00
Ralf Jung
d7ee421870
fix ICE with extra-const-ub-checks
2022-08-21 20:00:38 -04:00
Ralf Jung
be6bb56ee0
add -Zextra-const-ub-checks to enable more UB checking in const-eval
2022-08-07 09:54:40 -04:00
Ralf Jung
a10d8e4581
rename get_global_alloc to try_get_global_alloc
2022-07-20 17:09:22 -04:00
Ralf Jung
0ec3269db8
interpret: rename Tag/PointerTag to Prov/Provenance
...
Let's avoid using two different terms for the same thing -- let's just call it "provenance" everywhere.
In Miri, provenance consists of an AllocId and an SbTag (Stacked Borrows tag), which made this even more confusing.
2022-07-19 15:38:32 -04:00
5225225
27412d1e3e
Use constant eval to do strict validity checks
2022-07-14 22:55:17 +01:00
Ralf Jung
1e0f3cb566
make a name less ambiguous
2022-07-07 12:01:36 -04:00
Oli Scherer
4d390de4a3
Add a helper function for checking whether a default function in a trait can be treated as const
2022-05-30 08:52:25 +00:00
Deadbeef
257f06587c
Remove #[default..]
and add #[const_trait]
2022-05-30 08:52:24 +00:00
Jakob Degen
09b0936db2
Refactor call terminator to always hold a destination place
2022-05-23 17:49:04 -04:00
Jacob Pratt
49c82f31a8
Remove crate
visibility usage in compiler
2022-05-20 20:04:54 -04:00
carbotaniuman
bd5fce65c6
Rustc changes for permissive provenance
2022-05-13 12:30:25 -05:00
Ralf Jung
38004b72bc
interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal
2022-04-07 16:24:48 -04:00
Ralf Jung
fcdfc3e1c1
interp: pass TyCtxt to Machine methods that do not take InterpCx
2022-04-05 13:31:51 -04:00