Skip to content

Commit f564732

Browse files
authored
Merge pull request #74374 from jckarter/dead-before-live-def-block-assertion-failure
MoveOnlyAddressChecker: Turn assertion into early exit.
2 parents fb307ff + bb4c0d3 commit f564732

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,13 +2934,13 @@ bool GlobalLivenessChecker::testInstVectorLiveness(
29342934
continue;
29352935
case IsLive::LiveOut: {
29362936
LLVM_DEBUG(llvm::dbgs() << " Live out block!\n");
2937-
// If we see a live out block that is also a def block, we need to fa
2938-
#ifndef NDEBUG
2937+
// If we see a live out block that is also a def block, skip.
29392938
SmallBitVector defBits(addressUseState.getNumSubelements());
29402939
liveness.isDefBlock(block, errorSpan, defBits);
2941-
assert((defBits & errorSpan).none() &&
2942-
"If in def block... we are in liveness block");
2943-
#endif
2940+
if (!(defBits & errorSpan).none()) {
2941+
LLVM_DEBUG(llvm::dbgs() << " Also a def block; skipping!\n");
2942+
continue;
2943+
}
29442944
[[clang::fallthrough]];
29452945
}
29462946
case IsLive::LiveWithin:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//RUN: %target-swift-frontend -emit-sil -verify %s
2+
3+
@_silgen_name("cond")
4+
func cond() -> Bool
5+
6+
struct Foo: ~Copyable {}
7+
8+
func consume(_: consuming Foo) {}
9+
10+
func test1(_ x: inout Foo, _ y: consuming Foo) { // expected-error{{missing reinitialization}}
11+
consume(x) // expected-note{{consumed here}}
12+
if cond() {
13+
return
14+
} else {
15+
x = y
16+
}
17+
}
18+
19+
func test2(_ x: inout Foo, _ y: consuming Foo) { // expected-error{{missing reinitialization}}
20+
consume(x) // expected-note{{consumed here}}
21+
if cond() {
22+
x = y
23+
} else {
24+
return
25+
}
26+
}

0 commit comments

Comments
 (0)