Skip to content

JIT: Make BasicBlock::bbJumpKind private #92908

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

Merged
merged 5 commits into from
Oct 4, 2023

Conversation

amanasifkhalid
Copy link
Member

This is the beginning of a larger effort to disallow the use of BBJ_NONE (reserved for basic blocks that fall through) before the current method's block layout is finalized.

@AndyAyersMS PTAL, cc @dotnet/jit-contrib

@ghost ghost assigned amanasifkhalid Oct 2, 2023
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 2, 2023
@ghost
Copy link

ghost commented Oct 2, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

This is the beginning of a larger effort to disallow the use of BBJ_NONE (reserved for basic blocks that fall through) before the current method's block layout is finalized.

@AndyAyersMS PTAL, cc @dotnet/jit-contrib

Author: amanasifkhalid
Assignees: amanasifkhalid
Labels:

area-CodeGen-coreclr

Milestone: -


void setBBJumpKind(BBjumpKinds kind DEBUG_ARG(Compiler* comp))
{
#ifdef DEBUG
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'm probably getting ahead of myself here, but I'm thinking we will need to track whether BBJ_NONE is allowed or not in the current Compiler's state, so passing in a pointer to it will enable us to assert this state. I avoided making this a noway_assert to minimize TP diffs, and made comp a debug arg to avoid unused variable warnings in Release builds (though this approach also has the negative effect of removing this assert in Checked builds).

Copy link
Contributor

Choose a reason for hiding this comment

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

I would personally recommend using a verifier pattern (i. e. adding an assert somewhere in fgdiagnostic.cpp) for checking this property instead of the setters. It will make for less debug-only code overall.

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 like the cleanliness of your suggestion, but if we move this check to somewhere like Compiler::fgDebugCheckBBlist instead of checking every time bbJumpKind is updated, then is there any need to make bbJumpKind private? @AndyAyersMS

Copy link
Contributor

Choose a reason for hiding this comment

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

is there any need to make bbJumpKind private

Not strictly, but it is still an improvement.

https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/clr-jit-coding-conventions.md

15.5.1 Public data members
Do not declare public data members. Instead, public accessor functions should be exposed to access class members.

Copy link
Member

@AndyAyersMS AndyAyersMS Oct 3, 2023

Choose a reason for hiding this comment

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

Yes, please keep this field private.

Eventually we will probably do more work when the jump kind gets changed -- for instance calling add/remove ref on the appropriate blocks.

So having the extra comp argument here is also fine by me, it will prove useful down the road.

@@ -5260,7 +5260,7 @@ class AssertionPropFlowCallback
{
ASSERT_TP pAssertionOut;

if (predBlock->bbJumpKind == BBJ_COND && (predBlock->bbJumpDest == block))
if (predBlock->getBBJumpKind() == BBJ_COND && (predBlock->bbJumpDest == block))
Copy link
Member

Choose a reason for hiding this comment

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

Looks like most uses can be replaced with an existing block->KindIs(...) (it also supports 'params').

Also, should it be Get or get?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for catching that -- I'll push a revision converting all the bbJumpKind comparisons to KindIs().

I'm not sure what the case should be. Some BasicBlock methods (like KindIs) use Pascal case, while others (like makeBlockHot) use camel case.

Copy link
Contributor

Choose a reason for hiding this comment

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

The convention for all new code in the Jit is to use PascalCase, except in LSRA (where camelCase is used consistently).

@AndyAyersMS
Copy link
Member

SPMI replay error is infrastructure related:

OSError: [Errno 28] No space left on device

so maybe retry this bit?

@amanasifkhalid
Copy link
Member Author

Looks like the infrastructure issue didn't repro; CI is clean now.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

I skimmed through the diffs but did not check them all carefully.

@amanasifkhalid amanasifkhalid merged commit 1d352cb into dotnet:main Oct 4, 2023
amanasifkhalid added a commit that referenced this pull request Oct 6, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2023
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.

4 participants