-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[isolation-regions] Eliminate unnecessary heap allocations used for temporary values #68712
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
[isolation-regions] Eliminate unnecessary heap allocations used for temporary values #68712
Conversation
…slation loop. I did this by introducing a builder construct that has a SmallVector within it that we append into instead of returning std::vector. I also used some passed in SmallVectors in other places as well with large enough sizes that most times we will not allocate.
…he non-error path.
Transfer is the terminology that we are using for something be transferred across an isolation boundary, not consume. This also eliminates confusion with consume which is a term being used around ownership.
@swift-ci smoke test |
|
||
struct PartitionOpBuilder { | ||
/// Parent translator that contains state. | ||
PartitionOpTranslator *translater; |
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.
Nitpick: translator not translater
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.
I'll fix this in a follow on.
return {}; | ||
void getApplyResults(const SILInstruction *inst, | ||
SmallVectorImpl<SILValue> &foundResults) { | ||
if (isa<ApplyInst, BeginApplyInst, BuiltinInst, PartialApplyInst>(inst)) { |
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.
Whoa I didn't know isa<> was variadic
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.
(I didn't know either)
// PartitionOpKind represents the different kinds of PartitionOps that | ||
// SILInstructions can be translated to | ||
/// PartitionOpKind represents the different kinds of PartitionOps that | ||
/// SILInstructions can be translated to |
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.
It might help if the comments for each case gave an example of an actual instruction that lowers to this operation?
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.
I'll add that in a follow on.
I am splitting this off of a different commit that I decided to do in a slightly different manner. This PR just eliminates all of the temporary std::vectors being passed around in the hot loop of the pass in favor of a builder type that stores internally a SmallVector that should be large enough for handling the PartitionOps produced by any instruction.