-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: Add GT_SWIFT_ERROR_RET to represent loading error register upon return #100692
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
Changes from 22 commits
a9646c1
b328337
63eb15c
674d8f1
7d2e8fa
a342e00
6e50ea7
aa8c83c
9e310ec
15d39bf
873e15a
5d96892
24e8d0d
bf186b7
c381c48
70a69d7
de4457b
7096e23
927a55e
848704b
502f471
e8b1dbc
2dce428
38ad8a7
18df9c7
86a0825
41ec8f7
6d9d360
0cd339d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1586,7 +1586,7 @@ GenTree* Compiler::fgCreateMonitorTree(unsigned lvaMonAcquired, unsigned lvaThis | |
| } | ||
| #endif | ||
|
|
||
| if (block->KindIs(BBJ_RETURN) && block->lastStmt()->GetRootNode()->gtOper == GT_RETURN) | ||
| if (block->KindIs(BBJ_RETURN) && block->lastStmt()->GetRootNode()->OperIs(GT_RETURN)) | ||
| { | ||
| GenTreeUnOp* retNode = block->lastStmt()->GetRootNode()->AsUnOp(); | ||
| GenTree* retExpr = retNode->gtOp1; | ||
|
|
@@ -2559,6 +2559,55 @@ PhaseStatus Compiler::fgAddInternal() | |
| return madeChanges ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING; | ||
| } | ||
|
|
||
| #ifdef SWIFT_SUPPORT | ||
| //------------------------------------------------------------------------ | ||
| // fgAddSwiftErrorReturns: If this method uses Swift error handling, | ||
| // transform all GT_RETURN nodes into GT_SWIFT_ERROR_RET nodes | ||
| // to handle returning the error value alongside the normal return value. | ||
| // | ||
| // Returns: | ||
| // Suitable phase status. | ||
| // | ||
| PhaseStatus Compiler::fgAddSwiftErrorReturns() | ||
| { | ||
| if (lvaSwiftErrorArg == BAD_VAR_NUM) | ||
| { | ||
| // No Swift error handling in this method | ||
| return PhaseStatus::MODIFIED_NOTHING; | ||
| } | ||
|
|
||
| assert(lvaSwiftErrorLocal != BAD_VAR_NUM); | ||
| assert(info.compCallConv == CorInfoCallConvExtension::Swift); | ||
|
|
||
| for (BasicBlock* block : Blocks()) | ||
| { | ||
| if (block->KindIs(BBJ_RETURN)) | ||
| { | ||
| GenTree* const ret = block->lastNode(); | ||
| assert(ret->OperIs(GT_RETURN)); | ||
| ret->SetOperRaw(GT_SWIFT_ERROR_RET); | ||
| ret->AsOp()->gtOp2 = ret->AsOp()->gtOp1; | ||
|
|
||
| // If this is the merged return block, use the merged return error local as the error operand. | ||
| // Else, load the error value from the SwiftError pseudolocal (this will probably get promoted, anyway). | ||
| if (block == genReturnBB) | ||
| { | ||
| assert(genReturnErrorLocal == BAD_VAR_NUM); | ||
| genReturnErrorLocal = lvaGrabTemp(true DEBUGARG("Single return block SwiftError value")); | ||
| lvaGetDesc(genReturnErrorLocal)->lvType = genActualType(TYP_I_IMPL); | ||
| ret->AsOp()->gtOp1 = gtNewLclvNode(genReturnErrorLocal, TYP_I_IMPL); | ||
| } | ||
| else | ||
| { | ||
| ret->AsOp()->gtOp1 = gtNewLclFldNode(lvaSwiftErrorLocal, TYP_I_IMPL, 0); | ||
| } | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think it would be nice to do the replacement of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was my plan, though I was hitting asserts around
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point we don't have threaded IR nodes (the comment on
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thanks! |
||
|
|
||
| return PhaseStatus::MODIFIED_EVERYTHING; | ||
| } | ||
| #endif // SWIFT_SUPPORT | ||
|
|
||
| /*****************************************************************************/ | ||
| /*****************************************************************************/ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.