Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a9646c1
Add GT_SWIFT_ERROR_RET
amanasifkhalid Apr 5, 2024
b328337
Cleanup
amanasifkhalid Apr 5, 2024
63eb15c
Style
amanasifkhalid Apr 5, 2024
674d8f1
Style; comments
amanasifkhalid Apr 5, 2024
7d2e8fa
Binop implementation
amanasifkhalid Apr 8, 2024
a342e00
Update comment
amanasifkhalid Apr 8, 2024
6e50ea7
Merge from main
amanasifkhalid Apr 8, 2024
aa8c83c
Comments
amanasifkhalid Apr 8, 2024
9e310ec
Style
amanasifkhalid Apr 8, 2024
15d39bf
Add GetReturnValue helper
amanasifkhalid Apr 8, 2024
873e15a
Handle GT_SWIFT_ERROR_RET in LSRA
amanasifkhalid Apr 8, 2024
5d96892
Overzealous opt
amanasifkhalid Apr 9, 2024
24e8d0d
Feedback
amanasifkhalid Apr 9, 2024
bf186b7
Store error to local during return merging
amanasifkhalid Apr 10, 2024
c381c48
Handle GT_SWIFT_ERROR_RET in morph
amanasifkhalid Apr 10, 2024
70a69d7
Move GT_SWIFT_ERROR_RET creation to phase
amanasifkhalid Apr 10, 2024
de4457b
Handle remaining GT_RETURN-specific code
amanasifkhalid Apr 10, 2024
7096e23
Style
amanasifkhalid Apr 10, 2024
927a55e
Add comment
amanasifkhalid Apr 10, 2024
848704b
Remove ifdef
amanasifkhalid Apr 10, 2024
502f471
Fix store ordering
amanasifkhalid Apr 10, 2024
e8b1dbc
Style
amanasifkhalid Apr 10, 2024
2dce428
Do SwiftError local conversion in phase
amanasifkhalid Apr 10, 2024
38ad8a7
Delete assert
amanasifkhalid Apr 10, 2024
18df9c7
Fix build
amanasifkhalid Apr 10, 2024
86a0825
Fix codegen on arm64
amanasifkhalid Apr 11, 2024
41ec8f7
Feedback
amanasifkhalid Apr 11, 2024
6d9d360
Update BADCODE message
amanasifkhalid Apr 11, 2024
0cd339d
Feedback
amanasifkhalid Apr 12, 2024
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
2 changes: 1 addition & 1 deletion src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2632,7 +2632,7 @@ PhaseStatus Compiler::fgAddSwiftErrorReturns()
{
assert(genReturnErrorLocal == BAD_VAR_NUM);
genReturnErrorLocal = lvaGrabTemp(true DEBUGARG("Single return block SwiftError value"));
lvaGetDesc(genReturnErrorLocal)->lvType = genActualType(TYP_I_IMPL);
lvaGetDesc(genReturnErrorLocal)->lvType = TYP_I_IMPL;
ret->AsOp()->gtOp1 = gtNewLclvNode(genReturnErrorLocal, TYP_I_IMPL);
}
else
Expand Down
17 changes: 4 additions & 13 deletions src/coreclr/jit/ifconversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,7 @@ bool OptIfConversionDsc::IfConvertCheckThenFlow()
if (thenBlock->KindIs(BBJ_RETURN))
{
assert(m_finalBlock == nullptr);
#ifdef SWIFT_SUPPORT
if (m_comp->lvaSwiftErrorArg != BAD_VAR_NUM)
{
m_mainOper = GT_SWIFT_ERROR_RET;
}
else
#endif // SWIFT_SUPPORT
{
m_mainOper = GT_RETURN;
}
m_mainOper = GT_RETURN;
}
else
{
Expand Down Expand Up @@ -586,7 +577,7 @@ bool OptIfConversionDsc::optIfConvert()
{
return false;
}
assert(m_thenOperation.node->OperIs(GT_STORE_LCL_VAR, GT_RETURN, GT_SWIFT_ERROR_RET));
assert(m_thenOperation.node->OperIs(GT_STORE_LCL_VAR, GT_RETURN));
if (m_doElseConversion)
{
if (!IfConvertCheckStmts(m_startBlock->GetTrueTarget(), &m_elseOperation))
Expand Down Expand Up @@ -644,7 +635,7 @@ bool OptIfConversionDsc::optIfConvert()
}
else
{
assert((m_mainOper == GT_RETURN) || (m_mainOper == GT_SWIFT_ERROR_RET));
assert(m_mainOper == GT_RETURN);
thenCost = m_thenOperation.node->AsOp()->GetReturnValue()->GetCostEx();
if (m_doElseConversion)
{
Expand Down Expand Up @@ -704,7 +695,7 @@ bool OptIfConversionDsc::optIfConvert()
}
else
{
assert((m_mainOper == GT_RETURN) || (m_mainOper == GT_SWIFT_ERROR_RET));
assert(m_mainOper == GT_RETURN);
assert(m_doElseConversion);
assert(m_thenOperation.node->TypeGet() == m_elseOperation.node->TypeGet());

Expand Down
13 changes: 5 additions & 8 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,8 @@ GenTree* Lowering::LowerNode(GenTree* node)
break;

case GT_SWIFT_ERROR_RET:
LowerNode(node->gtGetOp1());

FALLTHROUGH;
case GT_RETURN:
LowerRet(node->AsUnOp());
LowerRet(node->AsOp());
break;

case GT_RETURNTRAP:
Expand Down Expand Up @@ -4545,16 +4542,16 @@ void Lowering::LowerJmpMethod(GenTree* jmp)
}
}

// Lower GT_RETURN node to insert PInvoke method epilog if required.
void Lowering::LowerRet(GenTreeUnOp* ret)
// Lower GT_RETURN/GT_SWIFT_ERROR_RET node to insert PInvoke method epilog if required.
void Lowering::LowerRet(GenTreeOp* ret)
{
assert(ret->OperIs(GT_RETURN, GT_SWIFT_ERROR_RET));

JITDUMP("lowering return node\n");
DISPNODE(ret);
JITDUMP("============\n");

GenTree* retVal = ret->AsOp()->GetReturnValue();
GenTree* retVal = ret->GetReturnValue();
// There are two kinds of retyping:
// - A simple bitcast can be inserted when:
// - We're returning a floating type as an integral type or vice-versa, or
Expand All @@ -4576,7 +4573,7 @@ void Lowering::LowerRet(GenTreeUnOp* ret)
#endif

GenTree* bitcast = comp->gtNewBitCastNode(ret->TypeGet(), retVal);
ret->AsOp()->SetReturnValue(bitcast);
ret->SetReturnValue(bitcast);
BlockRange().InsertBefore(ret, bitcast);
ContainCheckBitCast(bitcast);
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lower.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Lowering final : public Phase
bool TryLowerConditionToFlagsNode(GenTree* parent, GenTree* condition, GenCondition* code);
GenTreeCC* LowerNodeCC(GenTree* node, GenCondition condition);
void LowerJmpMethod(GenTree* jmp);
void LowerRet(GenTreeUnOp* ret);
void LowerRet(GenTreeOp* ret);
void LowerStoreLocCommon(GenTreeLclVarCommon* lclVar);
void LowerRetStruct(GenTreeUnOp* ret);
void LowerRetSingleRegStructLclVar(GenTreeUnOp* ret);
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8755,6 +8755,18 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
if (fgGlobalMorph && varTypeIsSmall(info.compRetType) && (retVal != nullptr) && !retVal->TypeIs(TYP_VOID) &&
fgCastNeeded(retVal, info.compRetType))
{
#ifdef SWIFT_SUPPORT
// Morph error operand if tree is a GT_SWIFT_ERROR_RET node
if (tree->OperIs(GT_SWIFT_ERROR_RET))
{
GenTree* const errorVal = fgMorphTree(tree->gtGetOp1());
tree->AsOp()->gtOp1 = errorVal;

// Propagate side effect flags
tree->SetAllEffectsFlags(errorVal);
}
#endif // SWIFT_SUPPORT

// Small-typed return values are normalized by the callee
retVal = gtNewCastNode(TYP_INT, retVal, false, info.compRetType);

Expand Down