Skip to content

Commit

Permalink
Propagate basic block flags after a failed inline.
Browse files Browse the repository at this point in the history
This is a fllow-up to dotnet#37335 and dotnet#37840.

When an inline fails we replace `GT_RET_EXPR`with the
original `GT_CALL` node. `GT_RET_EXPR`may end up in
a basic block other than the original `GT_CALL` so we need
to propagate basic block flags.

Fixes dotnet#36588.
  • Loading branch information
erozenfeld committed Jun 22, 2020
1 parent 8bd04e0 commit cbabbf9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2686,7 +2686,7 @@ class Compiler
GenTree* gtNewMustThrowException(unsigned helper, var_types type, CORINFO_CLASS_HANDLE clsHnd);

GenTreeLclFld* gtNewLclFldNode(unsigned lnum, var_types type, unsigned offset);
GenTree* gtNewInlineCandidateReturnExpr(GenTree* inlineCandidate, var_types type);
GenTree* gtNewInlineCandidateReturnExpr(GenTree* inlineCandidate, var_types type, unsigned __int64 bbFlags);

GenTree* gtNewFieldRef(var_types typ, CORINFO_FIELD_HANDLE fldHnd, GenTree* obj = nullptr, DWORD offset = 0);

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6263,15 +6263,15 @@ GenTreeLclFld* Compiler::gtNewLclFldNode(unsigned lnum, var_types type, unsigned
return node;
}

GenTree* Compiler::gtNewInlineCandidateReturnExpr(GenTree* inlineCandidate, var_types type)
GenTree* Compiler::gtNewInlineCandidateReturnExpr(GenTree* inlineCandidate, var_types type, unsigned __int64 bbFlags)
{
assert(GenTree::s_gtNodeSizes[GT_RET_EXPR] == TREE_NODE_SZ_LARGE);

GenTreeRetExpr* node = new (this, GT_RET_EXPR) GenTreeRetExpr(type);

node->gtInlineCandidate = inlineCandidate;

node->bbFlags = 0;
node->bbFlags = bbFlags;

if (varTypeIsStruct(inlineCandidate) && !inlineCandidate->OperIsBlkOp())
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8809,7 +8809,7 @@ var_types Compiler::impImportCall(OPCODE opcode,
impAppendTree(call, (unsigned)CHECK_SPILL_ALL, impCurStmtOffs);

// TODO: Still using the widened type.
GenTree* retExpr = gtNewInlineCandidateReturnExpr(call, genActualType(callRetTyp));
GenTree* retExpr = gtNewInlineCandidateReturnExpr(call, genActualType(callRetTyp), compCurBB->bbFlags);

// Link the retExpr to the call so if necessary we can manipulate it later.
origCall->gtInlineCandidateInfo->retExpr = retExpr;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/indirectcalltransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ class IndirectCallTransformer
// we set all this up in FixupRetExpr().
if (oldRetExpr != nullptr)
{
GenTree* retExpr = compiler->gtNewInlineCandidateReturnExpr(call, call->TypeGet());
GenTree* retExpr = compiler->gtNewInlineCandidateReturnExpr(call, call->TypeGet(), thenBlock->bbFlags);
inlineInfo->retExpr = retExpr;

if (returnTemp != BAD_VAR_NUM)
Expand Down

0 comments on commit cbabbf9

Please sign in to comment.