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

JIT: workaround for unreliable change detection in fgReorderBlocks #48516

Merged
merged 2 commits into from
Feb 20, 2021

Conversation

AndyAyersMS
Copy link
Member

This method costs trees, which can in turn modify the IR by swapping operands.
As a result the bool value returned doesn't properly reflect whether any
changes happened.

This impacts proper reporting phase status by `optOptimizeLayout'. Since phase
status just gates post-phase dumps and checks, we'll just claim this phase
always modifies IR.

Fixes #48495.

This method costs trees, which can in turn modify the IR by swapping operands.
As a result the bool value returned doesn't properly reflect whether any
changes happened.

This impacts proper reporting phase status by `optOptimizeLayout'. Since phase
status just gates post-phase dumps and checks, we'll just claim this phase
always modifies IR.

Fixes dotnet#48495.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 19, 2021
@AndyAyersMS
Copy link
Member Author

cc @dotnet/jit-contrib

@AndyAyersMS
Copy link
Member Author

Looks like the preceding phase (invert loops) may have the same problem, given #48494.

So will look to extend this fix to cover that case too.

@AndyAyersMS
Copy link
Member Author

Kind of on the fence here. On the one had it would be nice to be able to cost trees without side effecting them; on the other hand an accurate costing (at least as accurate as it is ever going to be) more or less entails opportunistic swapping (and address mode marking).

So three options to pursue... I have chosen the simplest for now:

  • assume these phases always change IR (the only downside is extra dumps / checks in non-release)
  • update costing APIs to allow a side-effect free mode
  • update costing APIs to return whether they caused any side effects (other than setting costs)

@AndyAyersMS
Copy link
Member Author

I suppose there is a fourth option:

  • use the logic the current post-phase debug check as a way of detecting that a phase made changes. In particular the check that is firing here is that some new tree node was created.

I'm more in favor of having phases be deliberate in what they change, so decided not to pursue this one.

None of this is crucial for now, but at some point we may want to report finer-grained phase status and relying on to guide release behaviors.

@BruceForstall
Copy link
Member

I somewhat prefer the 3rd:

update costing APIs to return whether they caused any side effects (other than setting costs)
as long as it can also be checked somehow. If it's expensive, though, then going "conservative" and assuming changes doesn't seem too bad an alternative.

// it has no impact on a release build.
//
madeChanges = true;

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 add an additional state MODIFIED_TREE here instead of using MODIFIED_EVERYTHING

Copy link
Member Author

Choose a reason for hiding this comment

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

Right -- I originally had finer-grained status in mind, but wasn't quite sure what the right breakout should be, so just have everything/nothing for now.

Copy link
Contributor

@briansull briansull left a comment

Choose a reason for hiding this comment

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

Looks OK

@AndyAyersMS
Copy link
Member Author

/azp run runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@trylek
Copy link
Member

trylek commented Feb 19, 2021

Great, thank you! It would be great if you could run this change through the shiproom and push it to Preview 2 that's just forked.

@AndyAyersMS
Copy link
Member Author

It would be great if you could run this change through the shiproom

Sure.

@AndyAyersMS
Copy link
Member Author

I'm fairly sure the outerloop failures are unrelated to this change. But I'm reluctant to merge with things looking this red.

Lots of instances of tracing\\eventpipe\\eventsvalidation\\ThreadPool\\ThreadPool failing, likely #48543.

And some pal test failures on Linux, dups of #48496.

And a jit-format failure on Linux, looks like jit-format is crashing; the patch artifact is a zero sized file.

@AndyAyersMS
Copy link
Member Author

Local run of jit-format on linux was clean.

@AndyAyersMS
Copy link
Member Author

Looked again at the failures and don't see anything related. So am going to merge after all.

@AndyAyersMS AndyAyersMS merged commit da828a2 into dotnet:master Feb 20, 2021
@AndyAyersMS AndyAyersMS deleted the Fix49485 branch February 20, 2021 17:17
@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Feb 23, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assertion failed 'm_compGenTreeID == m_compiler->compGenTreeID'
5 participants