Skip to content

Commit 55b6ff1

Browse files
committed
[pmo] Expand an assert that validates that we never handlePrimitiveValues when promoting takes.
The key thing to note here is that when we are processing a take, we validate that at all destroy points we have a fully available value. So we should never hit this code path which is correct. This assert just makes the assumption clearer in the small when reading code locally in handlePrimitiveValue.
1 parent ea9d043 commit 55b6ff1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,10 @@ SILValue AvailableValueAggregator::aggregateValues(SILType LoadTy,
567567
return aggregateStructSubElts(SD, LoadTy, Address, FirstElt);
568568

569569
// Otherwise, we have a non-aggregate primitive. Load or extract the value.
570+
//
571+
// NOTE: We should never call this when taking since when taking we know that
572+
// our underlying value is always fully available.
573+
assert(!isTake());
570574
return handlePrimitiveValue(LoadTy, Address, FirstElt);
571575
}
572576

@@ -696,17 +700,18 @@ SILValue AvailableValueAggregator::aggregateStructSubElts(StructDecl *sd,
696700
return B.createStruct(Loc, loadTy, resultElts);
697701
}
698702

699-
// We have looked through all of the aggregate values and finally found a
700-
// "primitive value". If the value is available, use it (extracting if we need
701-
// to), otherwise emit a load of the value with the appropriate qualifier.
703+
// We have looked through all of the aggregate values and finally found a value
704+
// that is not available without transforming, i.e. a "primitive value". If the
705+
// value is available, use it (extracting if we need to), otherwise emit a load
706+
// of the value with the appropriate qualifier.
702707
SILValue AvailableValueAggregator::handlePrimitiveValue(SILType loadTy,
703708
SILValue address,
704709
unsigned firstElt) {
705-
auto &val = AvailableValueList[firstElt];
710+
assert(!isTake() && "Should only take fully available values?!");
706711

707712
// If the value is not available, load the value and update our use list.
713+
auto &val = AvailableValueList[firstElt];
708714
if (!val) {
709-
assert(!isTake() && "Should only take fully available values?!");
710715
LoadInst *load = ([&]() {
711716
if (B.hasOwnership()) {
712717
return B.createTrivialLoadOr(Loc, address,

0 commit comments

Comments
 (0)