Skip to content

Commit 4f6f8d9

Browse files
committed
[NFC] MoveOnly: Map operand to list of ranges.
1 parent 2ab2252 commit 4f6f8d9

File tree

4 files changed

+305
-222
lines changed

4 files changed

+305
-222
lines changed

include/swift/SIL/FieldSensitivePrunedLiveness.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ struct TypeTreeLeafTypeRange {
304304
///
305305
/// This is a subset of (usually equal to) the bits of op->getType() in \p
306306
/// rootValue.
307-
static std::optional<TypeTreeLeafTypeRange> get(Operand *op,
308-
SILValue rootValue);
307+
static void get(Operand *op, SILValue rootValue,
308+
SmallVectorImpl<TypeTreeLeafTypeRange> &ranges);
309309

310310
static void constructProjectionsForNeededElements(
311311
SILValue rootValue, SILInstruction *insertPt,

lib/SIL/Utils/FieldSensitivePrunedLiveness.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,19 @@ void TypeTreeLeafTypeRange::constructFilteredProjections(
473473
llvm_unreachable("Not understand subtype");
474474
}
475475

476-
std::optional<TypeTreeLeafTypeRange>
477-
TypeTreeLeafTypeRange::get(Operand *op, SILValue rootValue) {
476+
void TypeTreeLeafTypeRange::get(
477+
Operand *op, SILValue rootValue,
478+
SmallVectorImpl<TypeTreeLeafTypeRange> &ranges) {
478479
auto projectedValue = op->get();
479480
auto startEltOffset = SubElementOffset::compute(projectedValue, rootValue);
480481
if (!startEltOffset)
481-
return std::nullopt;
482+
return;
482483

483484
// A drop_deinit only consumes the deinit bit of its operand.
484485
if (isa<DropDeinitInst>(op->getUser())) {
485486
auto upperBound = *startEltOffset + TypeSubElementCount(projectedValue);
486-
return {{upperBound - 1, upperBound}};
487+
ranges.push_back({upperBound - 1, upperBound});
488+
return;
487489
}
488490

489491
// An `inject_enum_addr` only initializes the enum tag.
@@ -499,7 +501,8 @@ TypeTreeLeafTypeRange::get(Operand *op, SILValue rootValue) {
499501
}
500502
// TODO: account for deinit component if enum has deinit.
501503
assert(!projectedValue->getType().isValueTypeWithDeinit());
502-
return {{payloadUpperBound, upperBound}};
504+
ranges.push_back({payloadUpperBound, upperBound});
505+
return;
503506
}
504507

505508
// Uses that borrow a value do not involve the deinit bit.
@@ -512,9 +515,9 @@ TypeTreeLeafTypeRange::get(Operand *op, SILValue rootValue) {
512515
deinitBitOffset = 1;
513516
}
514517

515-
return {{*startEltOffset, *startEltOffset +
516-
TypeSubElementCount(projectedValue) -
517-
deinitBitOffset}};
518+
ranges.push_back({*startEltOffset, *startEltOffset +
519+
TypeSubElementCount(projectedValue) -
520+
deinitBitOffset});
518521
}
519522

520523
void TypeTreeLeafTypeRange::constructProjectionsForNeededElements(

0 commit comments

Comments
 (0)