Skip to content

Commit a3e7dd6

Browse files
committed
[IRGen] Insts with packs in ops/results may alloc.
Instead of assuming that the list of instructions known to allocate pack metadata is exhaustive and returning false from mayRequirePackMetadata for all others, consider the types of the results and operands of other instructions and look for packs.
1 parent 090b14e commit a3e7dd6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/IRGen/PackMetadataMarkerInserter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Inserter::shouldInsertMarkersForInstruction(SILInstruction *inst) {
9191
BuiltinValueKind::StartAsyncLetWithLocalBuffer ||
9292
bi->getBuiltinKind() == BuiltinValueKind::StartAsyncLet)
9393
return Inserter::FindResult::Unhandleable;
94-
return Inserter::FindResult::None;
94+
LLVM_FALLTHROUGH;
9595
}
9696
default:
9797
return inst->mayRequirePackMetadata() ? FindResult::Some : FindResult::None;

lib/SIL/IR/SILInstruction.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,27 @@ bool SILInstruction::mayRequirePackMetadata() const {
13361336
return ty->hasAnyPack();
13371337
}
13381338
default:
1339+
// Instructions that deallocate stack must not result in pack metadata
1340+
// materialization. If they did there would be no way to create the pack
1341+
// metadata on stack.
1342+
if (isDeallocatingStack())
1343+
return false;
1344+
1345+
// Check results and operands for packs. If a pack appears, lowering the
1346+
// instruction might result in pack metadata emission.
1347+
for (auto result : getResults()) {
1348+
if (result->getType().hasAnyPack())
1349+
return true;
1350+
}
1351+
for (auto operandTy : getOperandTypes()) {
1352+
if (operandTy.hasAnyPack())
1353+
return true;
1354+
}
1355+
for (auto &tdo : getTypeDependentOperands()) {
1356+
if (tdo.get()->getType().hasAnyPack())
1357+
return true;
1358+
}
1359+
13391360
return false;
13401361
}
13411362
}

0 commit comments

Comments
 (0)