Conversation
src/librustc_interface/passes.rs
Outdated
| // Output Yorick debug sections into binary targets. | ||
| if tcx.sess.crate_types.borrow().contains(&config::CrateType::Executable) { | ||
| // Are we dumping the textual version of the TIR at the same time? | ||
| let tir_dump_fn = if tcx.sess.opts.output_types.contains_key(&OutputType::YkTir) { |
There was a problem hiding this comment.
let tir_dump_fn = tcsx.sess...contains_key(...).map(|_| Some(outputs.path(OutputType::YkTir))); or similar should work.
src/librustc_yk_sections/mir_cfg.rs
Outdated
| sorted_def_ids.sort(); | ||
|
|
||
| // Only if the user requested, open a file for the textual TIR dump. | ||
| let mut dump_file: Option<File> = dump_filename.map_or_else::<Result<Option<File>, io::Error>, _, _>( |
There was a problem hiding this comment.
Are the type annotations needed? They make this very hard to read.
There was a problem hiding this comment.
Hah, ironically I added them because I found it hard to read.
I'm not proud of this line. I think I should unroll it into something simpler.
There was a problem hiding this comment.
I'd just drop the annotations myself and then I think it'll be fine.
src/tools/compiletest/src/runtest.rs
Outdated
| self.fatal_proc_rec("compilation failed!", &proc_res); | ||
| } | ||
|
|
||
| if !proc_res.status.success() { |
There was a problem hiding this comment.
This is the same condition as the if above which seems odd.
There was a problem hiding this comment.
Oops. This is a copy/paste mistake. Nice catch.
| let mut test_lines = vec![ExpectedLine::Elision]; | ||
| for l in test_text.lines() { | ||
| if l.is_empty() { | ||
| // ignore |
There was a problem hiding this comment.
It might be easier to put continue in here. Or maybe for l in test_text.lines().filter(|x| !x.is_empty()) is even clearer?
There was a problem hiding this comment.
Just following the precedent set in the MirOpt suite. This function was a copy-paste-modify kind of affair.
There was a problem hiding this comment.
Here's the code this was based on in rustc:
https://github.com/rust-lang/rust/blob/237bf3244fffef501cf37d4bda00e1fce3fcfb46/src/tools/compiletest/src/runtest.rs#L2944-L2946
Might as well follow upstream.
| for l in test_text.lines() { | ||
| if l.is_empty() { | ||
| // ignore | ||
| } else if l.starts_with("//") && l.split_at("//".len()).1.trim() == "..." { |
There was a problem hiding this comment.
This feels like it would be clearer (and faster) as something like:
if l.starts_with("//") {
if l["".len()..].trim() == "..." { ... }
else { ... }
}There was a problem hiding this comment.
As before, let's follow upstream's example.
|
The test looks pretty much as I expected/hoped, so this looks like it's going in the right direction to me.! |
|
Great! Do you think I should take the time here to tidy up It's not essential. |
Dunno. |
|
OK, let me have a play and see if I can get some tidying done fairly quickish. |
The last commit makes the interface and internals of This was surprisingly hard to get through the borrow checker! |
src/librustc_yk_sections/mir_cfg.rs
Outdated
| // In this case the file at `tir_path` is a raw binary file which we use to make an | ||
| // object file for linkage. | ||
| let obj = YkExtraLinkObject::new(&tir_path, SECTION_NAME); | ||
| fs::remove_file(tir_path)?; // Now we have our object, we can remove the temp file. |
There was a problem hiding this comment.
We might want to suppress error if the temporary file can't be removed (it's not the end of the world)?
There was a problem hiding this comment.
Up to you. It's super unlikely to happen.
| }, | ||
| }; | ||
|
|
||
| let mut enc = match default_file { |
There was a problem hiding this comment.
let mut enc = default_file.map(|ref mut f| Some(...)); or similar?
There was a problem hiding this comment.
Hrm.
Seems the closure upsets the checker:
167 | let mut enc = default_file.map(|ref mut f| ykpack::Encoder::from(f));
| ^^^^^^^^^ - temporary value dropped here while still borrowed
| |
| temporary value does not live long enough
Any ideas?
There was a problem hiding this comment.
Although I doubt it works, does |mut f| fix things?
There was a problem hiding this comment.
Funnily enough, if I remove the ref it asks me to also remove mut, so the closest we would get is:
169 | let mut enc = default_file.map(|f| ykpack::Encoder::from(&mut f));
| ^- `f` dropped here while still borrowed
| |
| borrowed value does not live long enough
...
206 | }
| - borrowed value needs to live until here
|
One outstanding comment for you here: Besides that, I think I've covered your other comments. Note that the companion PR for ykpack needs to go in first: |
|
[I'd like to add more/better tests, but we'd need to implement more of the TIR conversions to be able to make sense of TIR dumps -- Currently there are too many 'unimplemented's to know where in the code we are]. |
|
I think we're ready to squash? |
|
Not just yet. One moment. |
|
In addition to that last commit, I propose (as a separate commit) renaming Thoughts? |
|
Fine with me. |
|
I've renamed the file and shut the tidy checker up. OK for me to squash? |
This change adds a rustc flag `--emit yk-tir` which causes ykrustc to dump the TIR in a textual format and exit. Then we add a test new test suite kind which allows us to write tests against the textual TIR dumps. It works in much the same way as the existing MirOpt test suite. In fact, we re-use a lot of that code.
The old name was a throwback to when we though we would simply serialise MIR, instead of designing our own tracing byte-code.
|
Please squash. |
4f924cf to
26a4331
Compare
|
splat. |
|
bors r+ |
11: TIR test suite. r=ltratt a=vext01 This change adds a rustc flag `--emit yk-tir` which causes ykrustc to dump the TIR in a textual format and exit. Then we add a test new test suite kind which allows us to write tests against the textual TIR dumps. It works in much the same way as the existing MirOpt test suite. Note that this needs a ykpack change to go in first. Raising a draft PR for initial discussion. What do you think of the general approach? [I think `generate_tir()` can be tidied up some in light of this change, but I didn't want to do that in this PR]. Co-authored-by: Edd Barrett <vext01@gmail.com>
Build succeeded |
remove directory libstd/sys/vxworks/backtrace which is not used any more
This is a combination of 18 commits. Commit softdevteam#2: Additional examples and some small improvements. Commit softdevteam#3: fixed mir-opt non-mir extensions and spanview title elements Corrected a fairly recent assumption in runtest.rs that all MIR dump files end in .mir. (It was appending .mir to the graphviz .dot and spanview .html file names when generating blessed output files. That also left outdated files in the baseline alongside the files with the incorrect names, which I've now removed.) Updated spanview HTML title elements to match their content, replacing a hardcoded and incorrect name that was left in accidentally when originally submitted. Commit softdevteam#4: added more test examples also improved Makefiles with support for non-zero exit status and to force validation of tests unless a specific test overrides it with a specific comment. Commit softdevteam#5: Fixed rare issues after testing on real-world crate Commit softdevteam#6: Addressed PR feedback, and removed temporary -Zexperimental-coverage -Zinstrument-coverage once again supports the latest capabilities of LLVM instrprof coverage instrumentation. Also fixed a bug in spanview. Commit softdevteam#7: Fix closure handling, add tests for closures and inner items And cleaned up other tests for consistency, and to make it more clear where spans start/end by breaking up lines. Commit softdevteam#8: renamed "typical" test results "expected" Now that the `llvm-cov show` tests are improved to normally expect matching actuals, and to allow individual tests to override that expectation. Commit softdevteam#9: test coverage of inline generic struct function Commit softdevteam#10: Addressed review feedback * Removed unnecessary Unreachable filter. * Replaced a match wildcard with remining variants. * Added more comments to help clarify the role of successors() in the CFG traversal Commit softdevteam#11: refactoring based on feedback * refactored `fn coverage_spans()`. * changed the way I expand an empty coverage span to improve performance * fixed a typo that I had accidently left in, in visit.rs Commit softdevteam#12: Optimized use of SourceMap and SourceFile Commit softdevteam#13: Fixed a regression, and synched with upstream Some generated test file names changed due to some new change upstream. Commit softdevteam#14: Stripping out crate disambiguators from demangled names These can vary depending on the test platform. Commit softdevteam#15: Ignore llvm-cov show diff on test with generics, expand IO error message Tests with generics produce llvm-cov show results with demangled names that can include an unstable "crate disambiguator" (hex value). The value changes when run in the Rust CI Windows environment. I added a sed filter to strip them out (in a prior commit), but sed also appears to fail in the same environment. Until I can figure out a workaround, I'm just going to ignore this specific test result. I added a FIXME to follow up later, but it's not that critical. I also saw an error with Windows GNU, but the IO error did not specify a path for the directory or file that triggered the error. I updated the error messages to provide more info for next, time but also noticed some other tests with similar steps did not fail. Looks spurious. Commit softdevteam#16: Modify rust-demangler to strip disambiguators by default Commit softdevteam#17: Remove std::process::exit from coverage tests Due to Issue #77553, programs that call std::process::exit() do not generate coverage results on Windows MSVC. Commit softdevteam#18: fix: test file paths exceeding Windows max path len
This change adds a rustc flag
--emit yk-tirwhich causes ykrustc todump the TIR in a textual format and exit.
Then we add a test new test suite kind which allows us to write tests
against the textual TIR dumps. It works in much the same way as the
existing MirOpt test suite.
Note that this needs a ykpack change to go in first. Raising a draft PR for initial discussion.
What do you think of the general approach?
[I think
generate_tir()can be tidied up some in light of this change, but I didn't want to do that in this PR].