Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Implement more TIR lowerings. #18

Merged
merged 1 commit into from
May 7, 2019
Merged

Implement more TIR lowerings. #18

merged 1 commit into from
May 7, 2019

Conversation

vext01
Copy link
Member

@vext01 vext01 commented May 1, 2019

This is a whole load more TIR lowerings. The TIR graphs are starting to look more complete, although there's still a lot more to do. I only stopped here because the changes are getting large, and more edits can come in later PRs.

There's one part of this code (which I will point out), which i'm likely to change. It involves a type-parameterised MIR struct, which I think ultimately we will make concrete in TIR. However, I want to see the outcome of this upstream PR first:
rust-lang/rust#60441

There's a ykpack change to accompany this:
ykjit/yk#3


/// Projection -> Pack
impl<'tcx, T> ToPack<ykpack::Projection<Box<ykpack::Place>, ykpack::LocalIndex>>
for (&ConvCx<'_, 'tcx, '_>, &Projection<'tcx, Place<'tcx>, Local, T>)
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we are taking a parameterised MIR Projection and from it making a parameterised TIR projection. I'd like to make the TIR projection concrete, especially since the MIR counterpart is only every constructed under one guise. The upstream PR suggests making the MIR struct concrete.

Copy link
Member

Choose a reason for hiding this comment

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

OK.

@@ -13,6 +13,7 @@ test = false
[dependencies]
rustc = { path = "../librustc" }
rustc_yk_link = { path = "../librustc_yk_link" }
ykpack = { git = "https://github.com/softdevteam/yk" }
#ykpack = { git = "https://github.com/softdevteam/yk" }
ykpack = { path = "../../../yk/ykpack" }
Copy link
Member Author

Choose a reason for hiding this comment

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

As usual, we mustn't forget to back this hunk out.

vext01 added a commit to vext01/yk_pv that referenced this pull request May 1, 2019
@@ -10,14 +9,17 @@
//! This module converts MIR into Yorick TIR (Tracing IR).
//! Note that we preserve the MIR block structure when lowering to TIR.
//!
//! Note also that TIR is currently untyped.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is worth stating: TIR is many things (and isn't many other things), and that'll be in flux for a while. This particular property seems to me only one of many.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. TBH I don't think we will get far without types anyway.

@@ -264,6 +267,8 @@ impl<'tcx> ToPack<ykpack::Terminator> for (&ConvCx<'_, 'tcx, '_>, &Terminator<'t
unwind_bb: unwind_bb.map(|bb| u32::from(bb)),
},
TerminatorKind::Call{ref func, cleanup: cleanup_bb, ref destination, .. } => {
// In MIR, a call instruction accepts an arbitrary operand, but in TIR we special
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand this (I'm not saying it's badly phrased... I just don't understand it!).

Copy link
Member Author

Choose a reason for hiding this comment

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

In mir they have Call(Operand) where Operand is really general. It can express things which I don't think you can even call.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see.

match *op {
Operand::Move(place) | Operand::Copy(place)
=> ykpack::Operand::Place((*ccx, place).to_pack()),
_ => ykpack::Operand::Unimplemented, // FIXME
Copy link
Member

Choose a reason for hiding this comment

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

Bad formatting. Also I think we should make this unimplemeted shouldn't we? Or will that stop nearly every program from compiling?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want to crash, I just want to see an unimplemented node in my CFG.

Copy link
Member Author

Choose a reason for hiding this comment

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

(I have a tool for drawing the cfg from a serialised pack)

Copy link
Member

Choose a reason for hiding this comment

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

OK.

Copy link
Member Author

Choose a reason for hiding this comment

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

WRT to formatting, how would you have done it? The second line is a continuation of the first, hence the indent. Joining the lines upsets the tidy check.

Copy link
Member

Choose a reason for hiding this comment

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

Ah! Ignore me.

ykpack::Statement::Unimplemented(ykpack::UnimplementedStatement::Retag),
// Type ascription.
// https://github.com/rust-lang/rfcs/pull/803
StatementKind::AscribeUserType(..) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! They can map to our Nop instruction then!

@vext01
Copy link
Member Author

vext01 commented May 3, 2019

I think this is ready for re-review.

The ykpack change should go in first, then we should flip the dependency back before merging this.

@vext01 vext01 marked this pull request as ready for review May 3, 2019 09:10
@ltratt
Copy link
Member

ltratt commented May 3, 2019

Please squash.

vext01 added a commit to ykjit/yk that referenced this pull request May 4, 2019
@vext01 vext01 force-pushed the yk-more-bytecodes branch from 537549d to 120187e Compare May 4, 2019 14:27
@vext01
Copy link
Member Author

vext01 commented May 4, 2019

Squashed. Once the ykpack change is merged, we can flip the dependency, squash again, and then r+.

@ltratt
Copy link
Member

ltratt commented May 4, 2019

I suggest squashing the dependency in now so that I can merge these even if you're not available when I am. [Given how long ykrustc takes to build, it can only be a good thing!]

@bjorn3
Copy link
Collaborator

bjorn3 commented May 4, 2019

[Given how long ykrustc takes to build, it can only be a good thing!]

How much is rustc itself patched? If you only patched the codegen backend, you may compile the codegen backend separately and then use -Zcodegen-backend=/path/to/librustc_codegen_llvm.dylib to load it in an unpatched rustc nightly.

@vext01
Copy link
Member Author

vext01 commented May 4, 2019

@bjorn3 I'll look into it, but we've made some pretty invasive changes.

@vext01
Copy link
Member Author

vext01 commented May 4, 2019

I suggest squashing the dependency in now

I can do it now, but we'll still need another commit. We need the post-merge commit ID to silence the tidy checker. All non-crates.io deps need to be listed in a whitelist with an exact commit ID :(

This is why I was holding off.

bors bot added a commit to ykjit/yk that referenced this pull request May 4, 2019
3: Implement more TIR data structures. r=ltratt a=vext01

This is a companion commit to:
softdevteam/ykrustc#18

Co-authored-by: Edd Barrett <[email protected]>
vext01 added a commit to ykjit/yk that referenced this pull request May 4, 2019
bors bot added a commit to ykjit/yk that referenced this pull request May 4, 2019
3: Implement more TIR data structures. r=ltratt a=vext01

This is a companion commit to:
softdevteam/ykrustc#18

Co-authored-by: Edd Barrett <[email protected]>
@vext01
Copy link
Member Author

vext01 commented May 6, 2019

820b008 make the necessary dependency adjustments. OK to squash?

(Not sure why GH is displaying things in the order it is...)

@ltratt
Copy link
Member

ltratt commented May 6, 2019

Please squash.

@vext01 vext01 force-pushed the yk-more-bytecodes branch from 820b008 to 920f699 Compare May 6, 2019 14:54
@vext01
Copy link
Member Author

vext01 commented May 6, 2019

splat

@ltratt
Copy link
Member

ltratt commented May 6, 2019

bors r+

bors bot added a commit that referenced this pull request May 6, 2019
18: Implement more TIR lowerings. r=ltratt a=vext01

This is a whole load more TIR lowerings. The TIR graphs are starting to look more complete, although there's still a lot more to do. I only stopped here because the changes are getting large, and more edits can come in later PRs.

There's one part of this code (which I will point out), which i'm likely to change. It involves a type-parameterised MIR struct, which I think ultimately we will make concrete in TIR. However, I want to see the outcome of this upstream PR first:
rust-lang/rust#60441

There's a ykpack change to accompany this:
ykjit/yk#3

Co-authored-by: Edd Barrett <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 6, 2019

Build failed

@vext01
Copy link
Member Author

vext01 commented May 7, 2019

My bad. Although I remembered to fix the ykpack tests, I forgot the test in ykrustc.

OK to squash?

@ltratt
Copy link
Member

ltratt commented May 7, 2019

Please squash.

@vext01 vext01 force-pushed the yk-more-bytecodes branch from 4fd289c to 5242934 Compare May 7, 2019 08:38
@vext01
Copy link
Member Author

vext01 commented May 7, 2019

splat

@ltratt
Copy link
Member

ltratt commented May 7, 2019

bors r+

bors bot added a commit that referenced this pull request May 7, 2019
18: Implement more TIR lowerings. r=ltratt a=vext01

This is a whole load more TIR lowerings. The TIR graphs are starting to look more complete, although there's still a lot more to do. I only stopped here because the changes are getting large, and more edits can come in later PRs.

There's one part of this code (which I will point out), which i'm likely to change. It involves a type-parameterised MIR struct, which I think ultimately we will make concrete in TIR. However, I want to see the outcome of this upstream PR first:
rust-lang/rust#60441

There's a ykpack change to accompany this:
ykjit/yk#3

Co-authored-by: Edd Barrett <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 7, 2019

Build succeeded

@bors bors bot merged commit 5242934 into master May 7, 2019
@bors bors bot deleted the yk-more-bytecodes branch May 7, 2019 13:25
bors bot pushed a commit that referenced this pull request Sep 22, 2019
simplify is_vxworks_pure_dynamic()
vext01 pushed a commit to vext01/ykrustc that referenced this pull request Oct 12, 2020
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants