Skip to content

Commit 928bcf3

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 471c978 commit 928bcf3

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
@@ -1318,6 +1318,27 @@ bool SILInstruction::mayRequirePackMetadata() const {
13181318
return ty->hasAnyPack();
13191319
}
13201320
default:
1321+
// Instructions that deallocate stack must not result in pack metadata
1322+
// materialization. If they did there would be no way to create the pack
1323+
// metadata on stack.
1324+
if (isDeallocatingStack())
1325+
return false;
1326+
1327+
// Check results and operands for packs. If a pack appears, lowering the
1328+
// instruction might result in pack metadata emission.
1329+
for (auto result : getResults()) {
1330+
if (result->getType().hasAnyPack())
1331+
return true;
1332+
}
1333+
for (auto operandTy : getOperandTypes()) {
1334+
if (operandTy.hasAnyPack())
1335+
return true;
1336+
}
1337+
for (auto &tdo : getTypeDependentOperands()) {
1338+
if (tdo.get()->getType().hasAnyPack())
1339+
return true;
1340+
}
1341+
13211342
return false;
13221343
}
13231344
}

0 commit comments

Comments
 (0)