Skip to content

Commit 0c4d55c

Browse files
Jaic1oli-obk
authored andcommitted
refine mir passes doc
1 parent 8ec48c0 commit 0c4d55c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/mir/passes.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
If you would like to get the MIR:
44

5-
- for a function - you can use the `optimized_mir(def_id)` query;
6-
- for a promoted - you can use the `promoted_mir(def_id)` query.
5+
- for a function - you can use the `optimized_mir` query (typically used by codegen) or the `mir_for_ctfe` query (typically used by compile time function evaluation, i.e., *CTFE*);
6+
- for a promoted - you can use the `promoted_mir` query.
77

88
These will give you back the final, optimized MIR. For foreign def-ids, we simply read the MIR
99
from the other crate's metadata. But for local def-ids, the query will
@@ -13,8 +13,8 @@ This section describes how those queries and passes work and how you can extend
1313

1414
To produce the optimized MIR for a given def-id `D`, `optimized_mir(D)`
1515
goes through several suites of passes, each grouped by a
16-
query. Each suite consists of passes which perform analysis, transformation or optimization.
17-
Each query represent a useful intermediate point
16+
query. Each suite consists of passes which perform linting, analysis, transformation or
17+
optimization. Each query represent a useful intermediate point
1818
where we can access the MIR dialect for type checking or other purposes:
1919

2020
- `mir_built(D)` – it gives the initial MIR just after it's built;
@@ -62,7 +62,7 @@ fields:
6262
pub struct CleanupNonCodegenStatements;
6363
```
6464

65-
for which we then implement the `MirPass` trait:
65+
for which we implement the `MirPass` trait:
6666

6767
```rust
6868
impl<'tcx> MirPass<'tcx> for CleanupNonCodegenStatements {
@@ -95,11 +95,9 @@ ensure that, before the MIR at a particular phase in the processing
9595
pipeline is stolen, anyone who may want to read from it has already
9696
done so.
9797

98-
<!-- FIXME - What is force? Do we still have it in rustc? -->
9998
Concretely, this means that if you have a query `foo(D)`
100-
that wants to access the result of `mir_const(D)` or
101-
`mir_promoted(D)`, you need to have the successor pass "force"
102-
`foo(D)` using `ty::queries::foo::force(...)`. This will force a query
99+
that wants to access the result of `mir_promoted(D)`, you need to have `foo(D)`
100+
calling the `mir_const(D)` query first. This will force it
103101
to execute even though you don't directly require its result.
104102

105103
> This mechanism is a bit dodgy. There is a discussion of more elegant

0 commit comments

Comments
 (0)