Skip to content

[LoopRotate] Use ownership for backedge block. #39783

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
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lib/SILOptimizer/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ static SILBasicBlock *insertBackedgeBlock(SILLoop *L, DominanceInfo *DT,
// the backedge block which correspond to any PHI nodes in the header block.
SmallVector<SILValue, 6> BBArgs;
for (auto *BBArg : Header->getArguments()) {
BBArgs.push_back(
BEBlock->createPhiArgument(BBArg->getType(), OwnershipKind::Owned));
BBArgs.push_back(BEBlock->createPhiArgument(BBArg->getType(),
BBArg->getOwnershipKind()));
}

// Arbitrarily pick one of the predecessor's branch locations.
Expand Down
26 changes: 26 additions & 0 deletions test/SILOptimizer/looprotate_nontrivial_ossa.sil
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,29 @@ bb3:
return %res : $()
}

// CHECK-LABEL: sil [ossa] @guaranteed_phi_argument : $@convention(thin) (@owned Klass) -> () {
// CHECK: {{bb[0-9]+}}({{%[^,]+}} : @guaranteed $Klass):
// CHECK-LABEL: } // end sil function 'guaranteed_phi_argument'
sil [ossa] @guaranteed_phi_argument : $@convention(thin) (@owned Klass) -> () {
entry(%instance : @owned $Klass):
%lifetime_1 = begin_borrow [lexical] %instance : $Klass
br loop_header(%lifetime_1 : $Klass)

loop_header(%lifetime_2 : @guaranteed $Klass):
cond_br undef, loop_back_1, loop_back_2_or_exit

loop_back_1:
br loop_header(%lifetime_2 : $Klass)

loop_back_2_or_exit:
cond_br undef, loop_back_2, exit

loop_back_2:
br loop_header(%lifetime_2 : $Klass)

exit:
end_borrow %lifetime_2 : $Klass
destroy_value %instance : $Klass
%retval = tuple ()
return %retval : $()
}