Skip to content

Commit 52822de

Browse files
committed
[DeadObjectElim] Bail on invalid access path.
rdar://162237650
1 parent 9953b1e commit 52822de

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/SILOptimizer/Transforms/DeadObjectElimination.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ static bool onlyStoresToTailObjects(BuiltinInst *destroyArray,
351351

352352
// Check if the destroyArray destroys the tail elements of allocRef.
353353
auto destroyPath = AccessPath::compute(destroyArray->getArguments()[1]);
354+
if (!destroyPath.isValid())
355+
return false;
354356
AccessStorage storage = destroyPath.getStorage();
355357
if (auto *beginDealloc = dyn_cast<BeginDeallocRefInst>(storage.getRoot())) {
356358
destroyPath = AccessPath(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -c -O %s -target %target-swift-6.0-abi-triple
2+
3+
// REQUIRES: synchronization
4+
5+
import Synchronization
6+
7+
class Locked<T> {
8+
let mutex: Mutex<T>
9+
10+
init(_ rawValue: T) {
11+
mutex = Mutex(rawValue)
12+
}
13+
}
14+
15+
class Foo {}
16+
17+
_ = Locked(Foo())

0 commit comments

Comments
 (0)