Skip to content

Use BBF_IMPORTER for new blocks in helperexpansion.cpp #116359

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/coreclr/jit/helperexpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ bool Compiler::fgExpandRuntimeLookupsForCall(BasicBlock** pBlock, Statement* stm
}

GenTree* ctxTree = call->gtArgs.GetArgByIndex(0)->GetNode();
GenTree* sigNode = call->gtArgs.GetArgByIndex(1)->GetNode();

// Prepare slotPtr tree (TODO: consider sharing this part with impRuntimeLookup)
GenTree* slotPtrTree = gtCloneExpr(ctxTree);
Expand Down Expand Up @@ -442,6 +441,23 @@ bool Compiler::fgExpandRuntimeLookupsForCall(BasicBlock** pBlock, Statement* stm
fallbackBb->inheritWeightPercentage(nullcheckBb, 20);
}

if (!prevBb->HasFlag(BBF_INTERNAL))
{
nullcheckBb->RemoveFlags(BBF_INTERNAL);
nullcheckBb->SetFlags(BBF_IMPORTED);

fastPathBb->RemoveFlags(BBF_INTERNAL);
fastPathBb->SetFlags(BBF_IMPORTED);

Copy link
Contributor

Choose a reason for hiding this comment

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

@EgorBo, If we do INTERNAL -> IMPORTED for fallbackBb as well, it fixes the issue. Is that an okay change? :)

Suggested change
fallbackBb->RemoveFlags(BBF_INTERNAL);
fallbackBb->SetFlags(BBF_IMPORTED);

if (needsSizeCheck)
{
sizeCheckBb->RemoveFlags(BBF_INTERNAL);
sizeCheckBb->SetFlags(BBF_IMPORTED);
}

assert(!block->HasFlag(BBF_INTERNAL));
}

// All blocks are expected to be in the same EH region
assert(BasicBlock::sameEHRegion(prevBb, block));
assert(BasicBlock::sameEHRegion(prevBb, nullcheckBb));
Expand Down Expand Up @@ -1546,6 +1562,14 @@ bool Compiler::fgExpandStaticInitForCall(BasicBlock** pBlock, Statement* stmt, G
isInitedBb->inheritWeight(prevBb);
helperCallBb->inheritWeightPercentage(isInitedBb, 0);

if (!prevBb->HasFlag(BBF_INTERNAL))
{
isInitedBb->RemoveFlags(BBF_INTERNAL);
isInitedBb->SetFlags(BBF_IMPORTED);

assert(!block->HasFlag(BBF_INTERNAL));
}

// All blocks are expected to be in the same EH region
assert(BasicBlock::sameEHRegion(prevBb, block));
assert(BasicBlock::sameEHRegion(prevBb, isInitedBb));
Expand Down
Loading