Skip to content

Commit 9807267

Browse files
authored
Merge pull request #64708 from meg-gupta/fixinfinite
Fix infinite loop in the new hasPointerEscape(SILValue) api
2 parents 54862c1 + 84d643f commit 9807267

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Diff for: lib/SIL/Utils/OwnershipUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ bool swift::hasPointerEscape(SILValue original) {
8282
return true;
8383
});
8484
}
85-
while (auto value = worklist.popAndForget()) {
85+
while (auto value = worklist.pop()) {
8686
for (auto use : value->getUses()) {
8787
switch (use->getOperandOwnership()) {
8888
case OperandOwnership::PointerEscape:

Diff for: test/SILOptimizer/ownership-utils-unit.sil

+29
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import Builtin
66

77
class C {}
88

9+
enum FakeOptional<T> {
10+
case none
11+
case some(T)
12+
}
13+
914
sil @getOwned : $@convention(thin) () -> (@owned C)
1015

1116
sil @borrow : $@convention(thin) (@guaranteed C) -> ()
@@ -42,3 +47,27 @@ exit(%instance : @owned $C):
4247
%retval = tuple ()
4348
return %retval : $()
4449
}
50+
51+
sil [ossa] @test_loop_phi : $@convention(thin) () -> () {
52+
entry:
53+
%instance_1 = enum $FakeOptional<C>, #FakeOptional.none!enumelt
54+
br loop_entry(%instance_1 : $FakeOptional<C>)
55+
56+
loop_entry(%18 : @owned $FakeOptional<C>):
57+
test_specification "has-pointer-escape @block.argument"
58+
br loop_body
59+
60+
loop_body:
61+
cond_br undef, loop_back, loop_exit
62+
63+
loop_back:
64+
br loop_entry(%18 : $FakeOptional<C>)
65+
66+
loop_exit:
67+
destroy_value %18 : $FakeOptional<C>
68+
br exit
69+
70+
exit:
71+
%retval = tuple ()
72+
return %retval : $()
73+
}

0 commit comments

Comments
 (0)