Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce MIR dump file count for MIR-opt tests #110773

Merged
merged 1 commit into from
May 5, 2023

Conversation

mj10021
Copy link
Contributor

@mj10021 mj10021 commented Apr 24, 2023

As referenced in issue #109502 , mir-opt tests previously used the -Zdump-mir=all flag, which generates very large output. This PR only dumps the passes under test, greatly reducing dump output.

@rustbot
Copy link
Collaborator

rustbot commented Apr 24, 2023

r? @oli-obk

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 24, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

just a bunch of impl nits.

Please also add some comments explaining the new field and argument

src/tools/compiletest/src/runtest.rs Outdated Show resolved Hide resolved
src/tools/compiletest/src/runtest.rs Outdated Show resolved Hide resolved
src/tools/compiletest/src/runtest.rs Outdated Show resolved Hide resolved
expected_file =
format!("{}{}{}", test_name.trim_end_matches(extension), bit_width, extension,);
from_file = test_name.to_string();
assert!(test_names.next().is_none(), "two mir pass names specified for MIR dump");
to_file = None;
let temp = test_name.split('.').collect::<Vec<&str>>();
passes.push(temp[temp.len() - 3].to_string());
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this magic number 3 mean? (Add the answer as a comment to the code)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha got it, adding

Copy link
Contributor

Choose a reason for hiding this comment

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

You could also use rsplit and the nth(3) operation on the iterator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the comment I added good or is there more info that is missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh sorry, github didn't send my comment because I used a review

Copy link
Contributor Author

Choose a reason for hiding this comment

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

O no worries, thanks for the update 🙂

@mj10021 mj10021 force-pushed the issue-109502-fix branch 2 times, most recently from fe36aec to 0812a49 Compare April 27, 2023 23:28
let test_against = format!("{}.after.mir", trimmed);
from_file = format!("{}.before.mir", trimmed);
expected_file = format!("{}{}.diff", trimmed, bit_width);
assert!(test_names.next().is_none(), "two mir pass names specified for MIR diff");
to_file = Some(test_against);
} else if let Some(first_pass) = test_names.next() {
let second_pass = test_names.next().unwrap();
passes.push(first_pass.split('.').collect::<Vec<&str>>()[0].to_string());
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to use split_once here to avoid collecting or iterating

expected_file =
format!("{}{}{}", test_name.trim_end_matches(extension), bit_width, extension,);
from_file = test_name.to_string();
assert!(test_names.next().is_none(), "two mir pass names specified for MIR dump");
to_file = None;
let temp = test_name.split('.').collect::<Vec<&str>>();
passes.push(temp[temp.len() - 3].to_string());
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also use rsplit and the nth(3) operation on the iterator

expected_file =
format!("{}{}{}", test_name.trim_end_matches(extension), bit_width, extension,);
from_file = test_name.to_string();
assert!(test_names.next().is_none(), "two mir pass names specified for MIR dump");
to_file = None;
let temp = test_name.split('.').collect::<Vec<&str>>();
passes.push(temp[temp.len() - 3].to_string());
Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh sorry, github didn't send my comment because I used a review

@mj10021 mj10021 force-pushed the issue-109502-fix branch from 0812a49 to 1056ff3 Compare May 4, 2023 22:51
@rustbot
Copy link
Collaborator

rustbot commented May 4, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

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.

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@mj10021
Copy link
Contributor Author

mj10021 commented May 4, 2023

oops fixing

@mj10021 mj10021 force-pushed the issue-109502-fix branch from 1056ff3 to c19959f Compare May 4, 2023 22:56
@oli-obk
Copy link
Contributor

oli-obk commented May 5, 2023

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 5, 2023

📌 Commit c19959f has been approved by oli-obk

It is now in the queue for this repository.

@bors bors 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 May 5, 2023
Comment on lines -350 to +351
let proc_res = self.compile_test(should_run, self.should_emit_metadata(pm));
let proc_res = self.compile_test(should_run, self.should_emit_metadata(pm), Vec::new());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why changing compile_test function at all, if in all places except one, last parameter will be Vec::new()? You can just add something like compile_test_with_passes and use it exactly in that one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, I'll make a follow up with that change

╾─alloc18─╼ 03 00 00 00 │ ╾──╼....
╾─alloc19─╼ 03 00 00 00 │ ╾──╼....
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this affects alloc numbers at all?

bors added a commit to rust-lang-ci/rust that referenced this pull request May 5, 2023
Rollup of 6 pull requests

Successful merges:

 - rust-lang#103056 (Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` has more than `i64::MAX` seconds)
 - rust-lang#108801 (Implement RFC 3348, `c"foo"` literals)
 - rust-lang#110773 (Reduce MIR dump file count for MIR-opt tests)
 - rust-lang#110876 (Added default target cpu to `--print target-cpus` output and updated docs)
 - rust-lang#111068 (Improve check-cfg implementation)
 - rust-lang#111238 (btree_map: `Cursor{,Mut}::peek_prev` must agree)

Failed merges:

 - rust-lang#110694 (Implement builtin # syntax and use it for offset_of!(...))

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit de7e29e into rust-lang:master May 5, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 5, 2023
JohnTitor added a commit to JohnTitor/rust that referenced this pull request May 6, 2023
…oli-obk

Issue 109502 follow up, remove unnecessary Vec::new() from compile_test()

As mentioned in comment on PR rust-lang#110773 , adding a separate function to pass the test passes into the `dump-mir` is a bit nicer
@mj10021 mj10021 deleted the issue-109502-fix branch November 1, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants