Skip to content

Commit 6e270c6

Browse files
Merge pull request #81076 from nate-chandler/cherrypick/release/6.2/rdar149850921
6.2: [FSPL] Look through unchecked addr casts.
2 parents 1dfd519 + 3de77f6 commit 6e270c6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/SIL/Utils/FieldSensitivePrunedLiveness.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ SubElementOffset::computeForAddress(SILValue projectionDerivedFromRoot,
148148
continue;
149149
}
150150

151+
if (auto *uaci =
152+
dyn_cast<UncheckedAddrCastInst>(projectionDerivedFromRoot)) {
153+
projectionDerivedFromRoot = uaci->getOperand();
154+
continue;
155+
}
156+
151157
if (auto *sbi = dyn_cast<StoreBorrowInst>(projectionDerivedFromRoot)) {
152158
projectionDerivedFromRoot = sbi->getDest();
153159
continue;

test/SILOptimizer/moveonly_addresschecker.swift

+12
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22
// RUN: -enable-experimental-feature NoImplicitCopy \
33
// RUN: -enable-experimental-feature MoveOnlyClasses \
44
// RUN: -enable-experimental-feature LifetimeDependence \
5+
// RUN: -enable-experimental-feature BuiltinModule \
56
// RUN: -Xllvm -sil-print-final-ossa-module %s | %FileCheck %s
67

78
// RUN: %target-swift-emit-sil -O -sil-verify-all -verify \
89
// RUN: -enable-experimental-feature NoImplicitCopy \
910
// RUN: -enable-experimental-feature MoveOnlyClasses \
1011
// RUN: -enable-experimental-feature LifetimeDependence \
12+
// RUN: -enable-experimental-feature BuiltinModule \
1113
// RUN: %s
1214

1315
// REQUIRES: swift_feature_MoveOnlyClasses
1416
// REQUIRES: swift_feature_NoImplicitCopy
1517
// REQUIRES: swift_feature_LifetimeDependence
18+
// REQUIRES: swift_feature_BuiltinModule
1619

1720
// This file contains tests that used to crash due to verifier errors. It must
1821
// be separate from moveonly_addresschecker_diagnostics since when we fail on
1922
// the diagnostics in that file, we do not actually run the verifier.
2023

24+
import Builtin
25+
2126
struct TestTrivialReturnValue : ~Copyable {
2227
var i: Int = 5
2328

@@ -76,3 +81,10 @@ struct TestCoroAccessorOfCoroAccessor<T : ~Escapable> : ~Copyable & ~Escapable {
7681
}
7782
}
7883
}
84+
85+
@usableFromInline
86+
internal func unsafeBitCast<T: ~Escapable & ~Copyable, U>(
87+
_ x: consuming T, to type: U.Type
88+
) -> U {
89+
Builtin.reinterpretCast(x)
90+
}

0 commit comments

Comments
 (0)