Commit Graph

642 Commits

Author SHA1 Message Date
Camille GILLOT
1d3f5b49d6 Test drop_tracking_mir before querying generator. 2023-01-29 13:50:07 +00:00
bors
3cdd0197e7 Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk
Use stable metric for const eval limit instead of current terminator-based logic

This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only.

The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made).

Also see: #103877
2023-01-29 04:11:27 +00:00
bors
bcb064a7f4 Auto merge of #107406 - cjgillot:eliminate-witnesses, r=compiler-errors
Only compute mir_generator_witnesses query in drop_tracking_mir mode.

Attempt to fix the perf regression in https://github.com/rust-lang/rust/pull/101692

r? `@ghost`
2023-01-29 01:27:11 +00:00
Camille GILLOT
15d6325747 Remove HirId -> LocalDefId map from HIR. 2023-01-28 09:55:26 +00:00
Camille GILLOT
3175d03d3b Take a LocalDefId in hir::Visitor::visit_fn. 2023-01-28 09:51:50 +00:00
Camille GILLOT
4db4860503 Only compute mir_generator_witnesses query in drop_tracking_mir mode. 2023-01-28 08:41:22 +00:00
Camille GILLOT
65c3c90f3e Restrict amount of ignored locals. 2023-01-27 22:01:12 +00:00
Camille GILLOT
400cb9aa41 Separate witness type computation from the generator transform. 2023-01-27 19:00:26 +00:00
Camille GILLOT
e2387ad484 Remember where a type was kept in MIR. 2023-01-27 18:59:32 +00:00
Kyle Matsuda
a969c194d8 fix up subst_identity vs skip_binder; add some FIXMEs as identified in review 2023-01-26 20:28:31 -07:00
Kyle Matsuda
c2414dfaa4 change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add EarlyBinder to fn_sig in metadata 2023-01-26 20:28:25 -07:00
Kyle Matsuda
e982971ff2 replace usages of fn_sig query with bound_fn_sig 2023-01-26 20:15:36 -07:00
Jakob Degen
f8aaf9aadb Disable ConstGoto opt in cleanup blocks 2023-01-26 03:50:37 -08:00
bors
885bf62887 Auto merge of #105582 - saethlin:instcombine-assert-inhabited, r=cjgillot
InstCombine away intrinsic validity assertions

This optimization (currently) fires 246 times on the standard library. It seems to fire hardly at all on the big crates in the benchmark suite. Interesting.
2023-01-26 03:10:52 +00:00
Jakob Degen
ad7393668f Delete SimplifyArmIdentity and SimplifyBranchSame mir opts 2023-01-24 04:13:52 -08:00
Ben Kimock
5bfad5cc85 Thread a ParamEnv down to might_permit_raw_init 2023-01-23 19:25:10 -05:00
Bryan Garza
1bbd655888 Improve efficiency of has_back_edge(...) 2023-01-24 00:01:37 +00:00
Bryan Garza
7618163a1c Add comments and remove unnecessary code 2023-01-23 23:56:22 +00:00
Bryan Garza
999d19d8aa Move CtfeLimit MirPass to inner_mir_for_ctfe 2023-01-23 23:56:22 +00:00
Bryan Garza
d3c13a0102 Revert "Move CtfeLimit to mir_const's set of passes"
This reverts commit 332542a92223b2800ed372d2d461921147f29477.
2023-01-23 23:56:22 +00:00
Bryan Garza
08de246cd7 Move CtfeLimit to mir_const's set of passes 2023-01-23 23:56:22 +00:00
Bryan Garza
8d99b0fc8d Abstract out has_back_edge fn 2023-01-23 23:56:22 +00:00
Bryan Garza
009beb00bc Change code to use map insead of for-loop 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
026a67377f Clean up CtfeLimit MirPass 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
Tomasz Miąsko
955e7fbb16 Consistently use dominates instead of is_dominated_by
There is a number of APIs that answer dominance queries. Previously they
were named either "dominates" or "is_dominated_by". Consistently use the
"dominates" form.

No functional changes.
2023-01-21 12:15:02 +01:00
Guillaume Gomez
dee88e0fa2
Rollup merge of #107037 - tmiasko:rank, r=oli-obk
Fix Dominators::rank_partial_cmp to match documentation

The only use site is also updated accordingly and there is no change in end-to-end behaviour.
2023-01-19 11:19:36 +01:00
Arpad Borsos
96931a787a
Transform async ResumeTy in generator transform
- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-19 09:03:05 +01:00
Tomasz Miąsko
b8c5821ad8 Fix Dominators::rank_partial_cmp to match documentation
The only use site is also updated accordingly and there is no change in
end-to-end behaviour.
2023-01-18 17:11:43 +01:00
Matthias Krüger
68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
Tomasz Miąsko
d21696ae46 Remove ineffective run of SimplifyConstCondition
There are no constant conditions at this stage.
2023-01-16 00:00:00 +00:00
Ben Kimock
662199f125 InstCombine away intrinsic validity assertions 2023-01-15 16:51:42 -05:00
Camille GILLOT
389d52c1eb Remove visit_place. 2023-01-14 17:04:02 +00:00
Camille GILLOT
de9a5b076a Make the inlining destination a Local. 2023-01-14 12:09:06 +00:00
Albert Larsan
40ba0e84d5
Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
bors
89e0576bd3 Auto merge of #106340 - saethlin:propagate-operands, r=oli-obk
Always permit ConstProp to exploit arithmetic identities

Fixes https://github.com/rust-lang/rust/issues/72751

Initially, I thought I would need to enable operand propagation then do something else, but actually https://github.com/rust-lang/rust/pull/74491 already has the fix for the issue in question! It looks like this optimization was put under MIR opt level 3 due to possible soundness/stability implications, then demoted further to MIR opt level 4 when MIR opt level 2 became associated with `--release`.

Perhaps in the past we were doing CTFE on optimized MIR? We aren't anymore, so this optimization has no stability implications.

r? `@oli-obk`
2023-01-09 11:59:51 +00:00
bors
b1691f6413 Auto merge of #105323 - cjgillot:simplify-const-prop, r=davidtwco
Perform SimplifyLocals before ConstProp.

MIR before `ConstProp` may have a lot of dead writes, this makes `ConstProp` do unnecessary work.

r? `@ghost`
2023-01-07 16:13:18 +00:00
Tomasz Miąsko
3eabea9e2c Remove duplicated elaborate box derefs pass
The pass runs earlier as a part of `run_runtime_lowering_passes`.
2023-01-03 00:00:00 +00:00
Jakob Degen
ee6503a706 Reenable limited top-down MIR inlining 2023-01-01 22:01:29 -08:00
Ben Kimock
82f0973dd5 Always take advantage of arithmetic identities 2023-01-01 23:12:29 -05:00
Camille GILLOT
edc73f9719 Give the correct track-caller location with MIR inlining. 2022-12-25 18:48:13 +00:00
Camille GILLOT
e300abb593 Remove Nop in simplify_locals.
It's cheap and does not change anything.
2022-12-25 18:01:07 +00:00
Camille GILLOT
028b4745f4 Move SimplifyLocals before ConstProp. 2022-12-25 18:01:07 +00:00
Matthias Krüger
d23cb738d2
Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholk
rustc: Remove needless lifetimes
2022-12-24 00:31:41 +01:00
Jakob Degen
c359ab0b5d Retag argument to drop_in_place unconditionally 2022-12-21 14:59:55 -08:00
Jakob Degen
102040ce76 Retag as FnEntry on drop_in_place 2022-12-21 14:59:55 -08:00
Jeremy Stucki
42d100aad0
Add missing anonymous lifetime 2022-12-20 22:28:22 +01:00
Jeremy Stucki
3dde32ca97
rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00