Skip to content

Annotate MIR with dataflow results for testing purposes - #163721

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
tmiasko:pretty-dataflow
Oct 5, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
tmiasko:pretty-dataflow

Conversation

@tmiasko

@tmiasko tmiasko commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

When requested through an internal rustc attribute, include dataflow
results in MIR output, i.e., -Zunpretty=mir or --emit mir.

For now, supported dataflows are:

  • #[rustc_mir(rustc_pretty_live_locals)]
  • #[rustc_mir(rustc_pretty_transitive_live_locals)]

The mechanism is intended to supersede existing rustc_peek intrinsic.
For demonstration also migrates one of tests based on rustc_peek:
tests/ui/mir-dataflow/liveness-projection.rs.

To avoid name conflicts with dataflow directory (to be added in
subsequent commit).
@rustbot

rustbot commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 3, 2026
@rustbot

rustbot commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

r? @tiif

rustbot has assigned @tiif.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 18 candidates

@Amanieu

Amanieu commented Oct 3, 2026

Copy link
Copy Markdown
Member

Should this also use a MirDumper so that we can use EMIT_MIR annotations in the tests?

@tmiasko

tmiasko commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Is there something specific you would like to see implemented? I could try to include it in all MIR dumps, in a fixed stage, or at configurable point, ... . Alternatively, one could also teach compiletest to dump the complete MIR as opposed to merely checking it.

_ => {}
}
}
annotations.into_extra_data()

@Amanieu Amanieu Oct 4, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
annotations.into_extra_data()
let extra_data = annotations.into_extra_data()?;
if let Some(dumper) = MirDumper::new(tcx, "DataflowPretty", body) {
dumper.set_extra_data(&*extra_data).dump_mir(body);
}
Some(extra_data)

This allows the tests to contain full snapshots of the annotated MIR with:

// EMIT_MIR liveness.fields.DataflowPretty.0.mir

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Added with a different suffix "dataflow".

This is simpler from what I had in mind. There is a drawback that it couples -Zdump-mir and --emit mir together. That is, dumping dataflow results individually requires emitting the complete MIR.

When requested through an internal rustc attribute, include dataflow
results in MIR output, i.e., `-Zunpretty=mir` or `--emit mir`.

For now, supported dataflows are:
* `#[rustc_mir(rustc_pretty_live_locals)]`
* `#[rustc_mir(rustc_pretty_transitive_live_locals)]`

The mechanism is intended to supersede existing `rustc_peek` intrinsic.
For demonstration also migrates one of tests based on `rustc_peek`:
tests/ui/mir-dataflow/liveness-projection.rs.
@Amanieu

Amanieu commented Oct 4, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3b3e098 has been approved by Amanieu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 4, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 5, 2026
@rust-bors

rust-bors Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: Amanieu
Duration: 3h 3m 57s
Pushing 260f1ac to main...

@rust-bors
rust-bors Bot merged commit 260f1ac into rust-lang:main Oct 5, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 2822155 (parent) -> 260f1ac (this PR)

Test differences

Show 16 test diffs

Stage 1

  • [mir-opt] tests/mir-opt/dataflow.rs: pass -> [missing] (J0)
  • [mir-opt] tests/mir-opt/dataflow/liveness.rs: [missing] -> pass (J0)
  • [mir-opt] tests/mir-opt/dump_dataflow.rs: [missing] -> pass (J0)

Stage 2

  • [mir-opt] tests/mir-opt/dataflow.rs: pass -> [missing] (J1)
  • [mir-opt] tests/mir-opt/dataflow/liveness.rs: [missing] -> pass (J1)
  • [mir-opt] tests/mir-opt/dump_dataflow.rs: [missing] -> pass (J1)

Additionally, 10 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 260f1acad9d7f70b5b56a636a9dc5a7f76150417 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-loongarch64-linux: 1h 16m -> 2h 8m (+68.6%)
  2. dist-i686-mingw: 34m 28s -> 57m 10s (+65.9%)
  3. test-x86_64-mingw-2: 1h 39m -> 2h 45m (+65.5%)
  4. dist-ohos-armv7: 50m 5s -> 1h 16m (+52.1%)
  5. test-pr-check-2: 28m 36s -> 42m 1s (+46.9%)
  6. test-x86_64-gnu-next-trait-solver-polonius: 43m 10s -> 1h 2m (+44.8%)
  7. dist-powerpc64le-linux-musl: 1h 9m -> 1h 39m (+44.1%)
  8. test-x86_64-msvc-ext3: 1h 58m -> 1h 6m (-43.7%)
  9. dist-x86_64-mingw: 2h 45m -> 1h 41m (-38.6%)
  10. test-i686-gnu-2: 1h 49m -> 1h 9m (-36.6%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (260f1ac): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 1.1%, secondary -1.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.2% [-3.2%, -3.2%] 1
All ❌✅ (primary) 1.1% [1.1%, 1.1%] 1

Cycles

Results (primary -2.2%, secondary 19.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
19.7% [19.7%, 19.7%] 1
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.2% [-2.2%, -2.2%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.206s -> 490.682s (0.30%)
Artifact size: 408.62 MiB -> 408.64 MiB (0.00%)

@tmiasko
tmiasko deleted the pretty-dataflow branch October 5, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) merged-by-bors This PR was explicitly merged by bors. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants