File tree 2 files changed +15
-18
lines changed
2 files changed +15
-18
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,18 @@ class BranchPropagatedUser {
108
108
llvm::PointerLikeTypeTraits<InnerTy>::NumLowBitsAvailable
109
109
};
110
110
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
+
111
123
private:
112
124
BranchPropagatedUser (SILInstruction *inst) : user(inst) {
113
125
assert (!isa<CondBranchInst>(inst));
Original file line number Diff line number Diff line change @@ -187,24 +187,9 @@ class LinearLifetimeChecker {
187
187
bool validateLifetime (SILValue value,
188
188
ArrayRef<SILInstruction *> consumingUses,
189
189
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));
208
193
}
209
194
};
210
195
You can’t perform that action at this time.
0 commit comments