Camille GILLOT
05c4eef95e
Make rev_locals a vec.
2024-01-07 13:54:05 +00:00
bors
8d76d07666
Auto merge of #116012 - cjgillot:gvn-const, r=oli-obk
...
Implement constant propagation on top of MIR SSA analysis
This implements the idea I proposed in https://github.com/rust-lang/rust/pull/110719#issuecomment-1718324700
Based on https://github.com/rust-lang/rust/pull/109597
The value numbering "GVN" pass formulates each rvalue that appears in MIR with an abstract form (the `Value` enum), and assigns an integer `VnIndex` to each. This abstract form can be used to deduplicate values, reusing an earlier local that holds the same value instead of recomputing. This part is proposed in #109597 .
From this abstract representation, we can perform more involved simplifications, for example in https://github.com/rust-lang/rust/pull/111344 .
With the abstract representation `Value`, we can also attempt to evaluate each to a constant using the interpreter. This builds a `VnIndex -> OpTy` map. From this map, we can opportunistically replace an operand or a rvalue with a constant if their value has an associated `OpTy`.
The most relevant commit is [Evaluated computed values to constants.](2767c4912e )"
r? `@oli-obk`
2023-12-30 03:45:58 +00:00
Michael Goulet
fcb42b42d6
Remove movability from TyKind::Coroutine
2023-12-28 16:35:01 +00:00
Camille GILLOT
a03c972816
Enable GVN by default.
2023-12-24 20:08:57 +00:00
Camille GILLOT
8022057ebb
Avoid overflow in GVN constant indexing.
2023-12-17 19:50:38 +00:00
surechen
40ae34194c
remove redundant imports
...
detects redundant imports that can be eliminated.
for #117772 :
In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
Ralf Jung
cb86303342
ctfe interpreter: extend provenance so that it can track whether a pointer is immutable
2023-12-07 17:46:36 +01:00
Michael Goulet
4506681e2f
Begin nightly-ifying rustc_type_ir
2023-11-18 00:20:00 +00:00
Mark Rousskov
917f6540ed
Re-format code with new rustfmt
2023-11-15 21:45:48 -05:00
George Bateman
e742f809f6
Update based on wesleywiser review
2023-10-31 23:41:40 +00:00
Camille Gillot
24be43356e
Apply suggestions from code review
...
Co-authored-by: Ralf Jung <post@ralfj.de >
2023-10-27 20:51:25 +02:00
Camille GILLOT
856161886a
Directly check provenance from the AllocId.
2023-10-25 17:59:30 +00:00
Camille GILLOT
72f0e0e795
Rename has_provance and tweaks comments.
2023-10-25 17:59:30 +00:00
Camille GILLOT
d80eb3a498
Verify that the alloc_id is Memory.
2023-10-25 17:59:30 +00:00
Camille GILLOT
c4cc9ca060
Do not merge fn pointer casts.
2023-10-25 06:47:04 +00:00
Camille GILLOT
5e78b9cdb3
Disambiguate non-deterministic constants.
2023-10-25 06:46:48 +00:00
Camille GILLOT
f08dc9be17
Take an AllocId in intern_const_alloc_for_constprop.
2023-10-25 06:46:48 +00:00
Camille GILLOT
e3538d11f1
Do not require absence of metadata.
2023-10-25 06:46:48 +00:00
Camille GILLOT
59235a7907
Fortify transmute check.
2023-10-25 06:46:48 +00:00
Camille GILLOT
fbf0a0c5ff
Explain why we check variant equality.
2023-10-25 06:46:48 +00:00
Camille GILLOT
ff6812cd20
Move provenance checks out of interning method.
2023-10-25 06:46:48 +00:00
Camille GILLOT
ebc87bf567
Directly intern values instead of copying them.
2023-10-25 06:46:48 +00:00
Camille GILLOT
8162dc2433
Do not intern GVN temps.
2023-10-25 06:46:48 +00:00
Camille GILLOT
dbf9ea30dd
Transform large arrays into Repeat expressions when possible.
2023-10-25 06:46:48 +00:00
Camille GILLOT
80a5e8522d
Extract simplify_aggregate.
2023-10-25 06:46:47 +00:00
Camille GILLOT
23d4857080
Do not compute actual aggregate type.
2023-10-25 06:46:47 +00:00
Camille GILLOT
f110f22060
Simplify repeat expressions.
2023-10-25 06:46:47 +00:00
Camille GILLOT
48d2157a89
Simplify aggregate projections.
2023-10-25 06:46:47 +00:00
Camille GILLOT
692e528647
Simplify projections in GVN.
2023-10-25 06:46:47 +00:00
Camille GILLOT
9389373127
Do not transmute immediates to non-immediates.
2023-10-25 06:46:47 +00:00
Camille GILLOT
db9bd9bd8c
Do not intern too large aggregates.
2023-10-25 06:46:47 +00:00
Camille GILLOT
38c86b0798
Evaluate computed values to constants.
2023-10-25 06:46:47 +00:00
Camille GILLOT
afd631cc0c
Do not visit rvalues twice.
2023-10-25 06:46:47 +00:00
Camille GILLOT
d28405972f
Do not remove unused definitions inside GVN.
2023-10-25 06:46:45 +00:00
Oli Scherer
60956837cf
s/Generator/Coroutine/
2023-10-20 21:10:38 +00:00
Michael Goulet
b2d2184ede
Format all the let chains in compiler
2023-10-13 08:59:36 +00:00
Camille GILLOT
37f080edbc
Also consider call and yield as MIR SSA.
2023-10-08 16:05:26 +00:00
ouz-a
cd7f471931
Add docs, remove code, change subtyper code
2023-10-02 23:39:44 +03:00
Camille GILLOT
901be42bc0
Explicit simplify_place.
2023-09-26 16:41:40 +00:00
Camille GILLOT
b2ff77cb78
Do not clone valtree and slice constants.
2023-09-24 09:09:05 +00:00
Camille GILLOT
5f9d64d72f
Embed simplification into VnState.
2023-09-24 09:09:04 +00:00
Camille GILLOT
3311536740
Workaround issue 112651.
2023-09-24 09:09:04 +00:00
Camille GILLOT
db50bd96e5
Add a paragraph about the assume bitwise equal.
2023-09-24 09:09:04 +00:00
Camille GILLOT
1ea9399803
Do not check copiability.
2023-09-24 09:09:04 +00:00
Camille GILLOT
6fa55d0aff
Add documentation.
2023-09-24 09:09:04 +00:00
Camille GILLOT
8b848af325
Add global value numbering pass.
2023-09-24 09:09:04 +00:00