-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SILGen: simplify cleanups and avoid critical edges. #19886
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2e71400
SILGen: Fix a variable name conflict.
atrick e04378f
SILGen: Always emit the cleanup block.
atrick f6f9acc
Add SILBuilder constructors that take a DebugScope.
atrick f73e6c7
Add a SILGenBuilder constructor that takes a new insertion point.
atrick 1c701b2
Simplify SILGen/Condition.
atrick c8e4d2b
SILGen KeyPath: Create a basic block to split the critical edge.
atrick 2ccc089
SILGenFunction::mergeCleanupBlocks.
atrick ba03bef
Fix test cases for SILGen after removing critical edges.
atrick a03d7bf
Add FIXME comments with suggestions to improve test case maintenance.
atrick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,12 @@ namespace Lowering { | |
|
||
/// A condition is the result of evaluating a boolean expression as | ||
/// control flow. | ||
/// | ||
/// For each Condition instance, `enterTrue` must be called before `complete`. | ||
/// If `enterFalse` is skipped, then an empty fall-through block is created. | ||
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. Nice comment! |
||
class LLVM_LIBRARY_VISIBILITY Condition { | ||
/// The blocks responsible for executing the true and false conditions. A | ||
/// block is non-null if that branch is possible, but it's only an independent | ||
/// block if both branches are possible. | ||
/// The blocks responsible for executing the true and false conditions. These | ||
/// are initialized non-null and set to null after being emitted. | ||
gottesmm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SILBasicBlock *TrueBB; | ||
SILBasicBlock *FalseBB; | ||
|
||
|
@@ -50,30 +52,39 @@ class LLVM_LIBRARY_VISIBILITY Condition { | |
SILBasicBlock *ContBB, | ||
SILLocation L) | ||
: TrueBB(TrueBB), FalseBB(FalseBB), ContBB(ContBB), Loc(L) | ||
gottesmm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{} | ||
|
||
bool hasTrue() const { return TrueBB; } | ||
bool hasFalse() const { return FalseBB; } | ||
|
||
/// enterTrue - Begin the emission of the true block. This should only be | ||
/// called if hasTrue() returns true. | ||
void enterTrue(SILGenFunction &SGF); | ||
|
||
/// exitTrue - End the emission of the true block. This must be called after | ||
/// enterTrue but before anything else on this Condition. | ||
void exitTrue(SILGenFunction &SGF, ArrayRef<SILValue> Args = {}); | ||
|
||
/// enterFalse - Begin the emission of the false block. This should only be | ||
/// called if hasFalse() returns true. | ||
void enterFalse(SILGenFunction &SGF); | ||
|
||
/// exitFalse - End the emission of the true block. This must be called after | ||
/// enterFalse but before anything else on this Condition. | ||
void exitFalse(SILGenFunction &SGF, ArrayRef<SILValue> Args = {}); | ||
|
||
{ | ||
assert((TrueBB != nullptr && FalseBB != nullptr) && | ||
"Requires non-null block pointers."); | ||
} | ||
|
||
/// enterTrue - Begin the emission of the true block. | ||
void enterTrue(SILGenFunction &SGF) { enter(SGF, TrueBB); } | ||
|
||
/// exitTrue - End the emission of the true block. | ||
void exitTrue(SILGenFunction &SGF, ArrayRef<SILValue> Args = {}) { | ||
exit(SGF, TrueBB, Args); | ||
TrueBB = nullptr; | ||
} | ||
|
||
/// enterFalse - Begin the emission of the false block. | ||
void enterFalse(SILGenFunction &SGF) { enter(SGF, FalseBB); } | ||
|
||
/// exitFalse - End the emission of the true block. | ||
void exitFalse(SILGenFunction &SGF, ArrayRef<SILValue> Args = {}) { | ||
exit(SGF, FalseBB, Args); | ||
FalseBB = nullptr; | ||
} | ||
|
||
/// complete - Complete this conditional execution. This should be called | ||
/// only after all other calls on this Condition have been made. | ||
/// This leaves SGF's SILGenBuilder at the continuation block. | ||
SILBasicBlock *complete(SILGenFunction &SGF); | ||
|
||
protected: | ||
void enter(SILGenFunction &SGF, SILBasicBlock *destBB); | ||
|
||
void exit(SILGenFunction &SGF, SILBasicBlock *destBB, | ||
ArrayRef<SILValue> Args = {}); | ||
}; | ||
|
||
/// A conditional value is one that depends on conditional execution. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.