Skip to content
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
12 changes: 12 additions & 0 deletions include/swift/SIL/BranchPropagatedUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ class BranchPropagatedUser {
llvm::PointerLikeTypeTraits<InnerTy>::NumLowBitsAvailable
};

static ArrayRef<BranchPropagatedUser>
convertFromInstArray(ArrayRef<SILInstruction *> instArray) {
assert(llvm::all_of(
instArray,
[](SILInstruction *i) { return !isa<CondBranchInst>(i); }) &&
"Passed cond branch to a non-BranchPropagatedUser API");
auto *castData =
reinterpret_cast<const BranchPropagatedUser *>(instArray.data());
ArrayRef<BranchPropagatedUser> castArray(castData, instArray.size());
return castArray;
}

private:
BranchPropagatedUser(SILInstruction *inst) : user(inst) {
assert(!isa<CondBranchInst>(inst));
Expand Down
21 changes: 3 additions & 18 deletions include/swift/SIL/OwnershipUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,9 @@ class LinearLifetimeChecker {
bool validateLifetime(SILValue value,
ArrayRef<SILInstruction *> consumingUses,
ArrayRef<SILInstruction *> nonConsumingUses) {
assert(llvm::all_of(
consumingUses,
[](SILInstruction *i) { return !isa<CondBranchInst>(i); }) &&
"Passed cond branch to a non-BranchPropagatedUser API");
assert(llvm::all_of(
nonConsumingUses,
[](SILInstruction *i) { return !isa<CondBranchInst>(i); }) &&
"Passed cond branch to a non-BranchPropagatedUser API");
auto *consumingUsesCast =
reinterpret_cast<const BranchPropagatedUser *>(consumingUses.data());
auto *nonConsumingUsesCast =
reinterpret_cast<const BranchPropagatedUser *>(nonConsumingUses.data());
ArrayRef<BranchPropagatedUser> consumingUsesCastArray(consumingUsesCast,
consumingUses.size());
ArrayRef<BranchPropagatedUser> nonConsumingUsesCastArray(
nonConsumingUsesCast, nonConsumingUses.size());
return validateLifetime(value, consumingUsesCastArray,
nonConsumingUsesCastArray);
return validateLifetime(
value, BranchPropagatedUser::convertFromInstArray(consumingUses),
BranchPropagatedUser::convertFromInstArray(nonConsumingUses));
}
};

Expand Down