Skip to content

Commit 008647c

Browse files
Merge pull request #39783 from nate-chandler/loop-rotate/backedge-ownership
[LoopRotate] Use ownership for backedge block.
2 parents 1d93818 + a886c7f commit 008647c

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

lib/SILOptimizer/Utils/LoopUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ static SILBasicBlock *insertBackedgeBlock(SILLoop *L, DominanceInfo *DT,
127127
// the backedge block which correspond to any PHI nodes in the header block.
128128
SmallVector<SILValue, 6> BBArgs;
129129
for (auto *BBArg : Header->getArguments()) {
130-
BBArgs.push_back(
131-
BEBlock->createPhiArgument(BBArg->getType(), OwnershipKind::Owned));
130+
BBArgs.push_back(BEBlock->createPhiArgument(BBArg->getType(),
131+
BBArg->getOwnershipKind()));
132132
}
133133

134134
// Arbitrarily pick one of the predecessor's branch locations.

test/SILOptimizer/looprotate_nontrivial_ossa.sil

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,29 @@ bb3:
169169
return %res : $()
170170
}
171171

172+
// CHECK-LABEL: sil [ossa] @guaranteed_phi_argument : $@convention(thin) (@owned Klass) -> () {
173+
// CHECK: {{bb[0-9]+}}({{%[^,]+}} : @guaranteed $Klass):
174+
// CHECK-LABEL: } // end sil function 'guaranteed_phi_argument'
175+
sil [ossa] @guaranteed_phi_argument : $@convention(thin) (@owned Klass) -> () {
176+
entry(%instance : @owned $Klass):
177+
%lifetime_1 = begin_borrow [lexical] %instance : $Klass
178+
br loop_header(%lifetime_1 : $Klass)
179+
180+
loop_header(%lifetime_2 : @guaranteed $Klass):
181+
cond_br undef, loop_back_1, loop_back_2_or_exit
182+
183+
loop_back_1:
184+
br loop_header(%lifetime_2 : $Klass)
185+
186+
loop_back_2_or_exit:
187+
cond_br undef, loop_back_2, exit
188+
189+
loop_back_2:
190+
br loop_header(%lifetime_2 : $Klass)
191+
192+
exit:
193+
end_borrow %lifetime_2 : $Klass
194+
destroy_value %instance : $Klass
195+
%retval = tuple ()
196+
return %retval : $()
197+
}

0 commit comments

Comments
 (0)