Skip to content

Commit 13072cf

Browse files
authored
Merge pull request #29519 from gottesmm/pr-a38b5f72b7fe7f2e4482b0456b6e1cb080ec9540
2 parents a35cfa1 + 70a417c commit 13072cf

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

include/swift/SIL/BranchPropagatedUser.h

+12
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ class BranchPropagatedUser {
108108
llvm::PointerLikeTypeTraits<InnerTy>::NumLowBitsAvailable
109109
};
110110

111+
static ArrayRef<BranchPropagatedUser>
112+
convertFromInstArray(ArrayRef<SILInstruction *> instArray) {
113+
assert(llvm::all_of(
114+
instArray,
115+
[](SILInstruction *i) { return !isa<CondBranchInst>(i); }) &&
116+
"Passed cond branch to a non-BranchPropagatedUser API");
117+
auto *castData =
118+
reinterpret_cast<const BranchPropagatedUser *>(instArray.data());
119+
ArrayRef<BranchPropagatedUser> castArray(castData, instArray.size());
120+
return castArray;
121+
}
122+
111123
private:
112124
BranchPropagatedUser(SILInstruction *inst) : user(inst) {
113125
assert(!isa<CondBranchInst>(inst));

include/swift/SIL/OwnershipUtils.h

+3-18
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,9 @@ class LinearLifetimeChecker {
187187
bool validateLifetime(SILValue value,
188188
ArrayRef<SILInstruction *> consumingUses,
189189
ArrayRef<SILInstruction *> nonConsumingUses) {
190-
assert(llvm::all_of(
191-
consumingUses,
192-
[](SILInstruction *i) { return !isa<CondBranchInst>(i); }) &&
193-
"Passed cond branch to a non-BranchPropagatedUser API");
194-
assert(llvm::all_of(
195-
nonConsumingUses,
196-
[](SILInstruction *i) { return !isa<CondBranchInst>(i); }) &&
197-
"Passed cond branch to a non-BranchPropagatedUser API");
198-
auto *consumingUsesCast =
199-
reinterpret_cast<const BranchPropagatedUser *>(consumingUses.data());
200-
auto *nonConsumingUsesCast =
201-
reinterpret_cast<const BranchPropagatedUser *>(nonConsumingUses.data());
202-
ArrayRef<BranchPropagatedUser> consumingUsesCastArray(consumingUsesCast,
203-
consumingUses.size());
204-
ArrayRef<BranchPropagatedUser> nonConsumingUsesCastArray(
205-
nonConsumingUsesCast, nonConsumingUses.size());
206-
return validateLifetime(value, consumingUsesCastArray,
207-
nonConsumingUsesCastArray);
190+
return validateLifetime(
191+
value, BranchPropagatedUser::convertFromInstArray(consumingUses),
192+
BranchPropagatedUser::convertFromInstArray(nonConsumingUses));
208193
}
209194
};
210195

0 commit comments

Comments
 (0)