Skip to content

Commit f327f23

Browse files
authored
Merge pull request #64990 from meg-gupta/fixlexicallifetimecompletion
Fix dead end block collection while completing lexical lifetimes
2 parents eb62b55 + 8346eb3 commit f327f23

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lib/SIL/Utils/OSSALifetimeCompletion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static bool endLifetimeAtUnreachableBlocks(SILValue value,
129129
changed = true;
130130
}
131131
for (auto *successor : block->getSuccessorBlocks()) {
132-
deadEndBlocks.push(successor);
132+
deadEndBlocks.pushIfNotVisited(successor);
133133
}
134134
}
135135
return changed;

test/SILOptimizer/ossa_lifetime_completion.sil

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,44 @@ bb3:
102102
return %r : $()
103103
}
104104

105+
// Ensure no assert fires while inserting dead end blocks to the worklist
106+
sil [ossa] @testLexicalLifetimeCompletion : $@convention(thin) (@owned C) -> () {
107+
bb0(%0 : @owned $C):
108+
test_specification "ossa-lifetime-completion @argument"
109+
debug_value %0 : $C, let, name "newElements", argno 1
110+
cond_br undef, bb1, bb2
111+
112+
bb1:
113+
cond_br undef, bb3, bb4
114+
115+
bb2:
116+
cond_br undef, bb9, bb10
117+
118+
bb3:
119+
br bb8
120+
121+
bb4:
122+
cond_br undef, bb5, bb6
123+
124+
bb5:
125+
br bb7
126+
127+
bb6:
128+
br bb7
129+
130+
bb7:
131+
unreachable
132+
133+
bb8:
134+
%77 = apply undef(%0) : $@convention(method) (@guaranteed C) -> ()
135+
destroy_value %0 : $C
136+
%79 = tuple ()
137+
return %79 : $()
138+
139+
bb9:
140+
br bb8
141+
142+
bb10:
143+
br bb8
144+
}
145+

0 commit comments

Comments
 (0)