Skip to content

Handle partial_apply and mark_dependence in Temp RVO #29927

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion lib/SILOptimizer/Transforms/CopyForwarding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,10 @@ bool TempRValueOptPass::collectLoads(
<< *user);
return false;

case SILInstructionKind::PartialApplyInst: {
loadInsts.insert(user);
return true;
}
case SILInstructionKind::ApplyInst:
case SILInstructionKind::TryApplyInst: {
ApplySite apply(user);
Expand Down Expand Up @@ -1873,7 +1877,7 @@ bool TempRValueOptPass::tryOptimizeCopyIntoTemp(CopyAddrInst *copyInst) {
continue;

// Destroys and deallocations are allowed to be in a different block.
if (isa<DestroyAddrInst>(user) || isa<DeallocStackInst>(user))
if (isa<DestroyAddrInst>(user) || isa<DeallocStackInst>(user) || isa<MarkDependenceInst>(user))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have to check the uses of the mark_dependence instruction?

Copy link
Contributor Author

@meg-gupta meg-gupta Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Looks like I do need to look at its uses. And one of its uses is another partial_apply which is marked as having side effects in AliasAnalysis.

continue;

if (!collectLoads(useOper, user, tempObj, copyInst->getSrc(), loadInsts))
Expand Down