Skip to content

[6.0] MoveOnlyAddressChecker: Turn assertion into early exit. #74376

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
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
10 changes: 5 additions & 5 deletions lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2933,13 +2933,13 @@ bool GlobalLivenessChecker::testInstVectorLiveness(
continue;
case IsLive::LiveOut: {
LLVM_DEBUG(llvm::dbgs() << " Live out block!\n");
// If we see a live out block that is also a def block, we need to fa
#ifndef NDEBUG
// If we see a live out block that is also a def block, skip.
SmallBitVector defBits(addressUseState.getNumSubelements());
liveness.isDefBlock(block, errorSpan, defBits);
assert((defBits & errorSpan).none() &&
"If in def block... we are in liveness block");
#endif
if (!(defBits & errorSpan).none()) {
LLVM_DEBUG(llvm::dbgs() << " Also a def block; skipping!\n");
continue;
}
[[clang::fallthrough]];
}
case IsLive::LiveWithin:
Expand Down
26 changes: 26 additions & 0 deletions test/SILOptimizer/moveonly_addresschecker_branch_order.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//RUN: %target-swift-frontend -emit-sil -verify %s

@_silgen_name("cond")
func cond() -> Bool

struct Foo: ~Copyable {}

func consume(_: consuming Foo) {}

func test1(_ x: inout Foo, _ y: consuming Foo) { // expected-error{{missing reinitialization}}
consume(x) // expected-note{{consumed here}}
if cond() {
return
} else {
x = y
}
}

func test2(_ x: inout Foo, _ y: consuming Foo) { // expected-error{{missing reinitialization}}
consume(x) // expected-note{{consumed here}}
if cond() {
x = y
} else {
return
}
}