DeadObjectElimination: Handle keypaths with non-trivial operands in OSSA

This commit is contained in:
Meghana Gupta
2023-07-21 13:49:57 -07:00
parent 41697b061c
commit 15e5364d25

View File

@@ -892,11 +892,20 @@ bool DeadObjectElimination::processKeyPath(KeyPathInst *KPI) {
return false;
}
// For simplicity just bail if the keypath has a non-trivial operands.
// TODO: don't bail but insert compensating destroys for such operands.
for (const Operand &Op : KPI->getPatternOperands()) {
if (!Op.get()->getType().isTrivial(*KPI->getFunction()))
return false;
// In non-ossa, bail out if we have non-trivial pattern operands
if (!KPI->getFunction()->hasOwnership()) {
for (const Operand &Op : KPI->getPatternOperands()) {
if (!Op.get()->getType().isTrivial(*KPI->getFunction()))
return false;
}
}
if (KPI->getFunction()->hasOwnership()) {
for (const Operand &Op : KPI->getPatternOperands()) {
if (Op.get()->getType().isTrivial(*KPI->getFunction()))
continue;
SILBuilderWithScope(KPI).createDestroyValue(KPI->getLoc(), Op.get());
}
}
// Remove the keypath and all of its users.