Optimizer: make the hasOwnershipOperandsOrResults utility available in OwnershipOptUtils

This commit is contained in:
Erik Eckstein
2024-12-30 15:54:43 +01:00
parent c58f04f165
commit 48b913af4b
3 changed files with 18 additions and 15 deletions

View File

@@ -1951,3 +1951,18 @@ void swift::replacePhisWithIncomingValues(SILPassManager *pm, ArrayRef<SILPhiArg
}
replacePhisWithIncomingValuesFunction({pm->getSwiftPassInvocation()}, ArrayRef(bridgedPhis));
}
bool swift::hasOwnershipOperandsOrResults(SILInstruction *inst) {
if (!inst->getFunction()->hasOwnership())
return false;
for (SILValue result : inst->getResults()) {
if (result->getOwnershipKind() != OwnershipKind::None)
return true;
}
for (Operand &op : inst->getAllOperands()) {
if (op.get()->getOwnershipKind() != OwnershipKind::None)
return true;
}
return false;
}