[Mem2Reg] Only lifetime canonicalize in OSSA.

Bail both on collecting stores and canonicalizing values if the function
being optimized doesn't have ownership.
This commit is contained in:
Nate Chandler
2023-07-31 16:16:28 -07:00
parent 53da6759de
commit f276ebf37e
2 changed files with 17 additions and 0 deletions

View File

@@ -2153,6 +2153,8 @@ void MemoryToRegisters::removeSingleBlockAllocation(AllocStackInst *asi) {
void MemoryToRegisters::collectStoredValues(AllocStackInst *asi,
StackList<SILValue> &owned,
StackList<SILValue> &guaranteed) {
if (!f.hasOwnership())
return;
for (auto *use : asi->getUses()) {
auto *user = use->getUser();
if (auto *si = dyn_cast<StoreInst>(user)) {
@@ -2166,6 +2168,8 @@ void MemoryToRegisters::collectStoredValues(AllocStackInst *asi,
void MemoryToRegisters::canonicalizeValueLifetimes(
StackList<SILValue> &owned, StackList<SILValue> &guaranteed,
BasicBlockSetVector &livePhiBlocks) {
if (!f.hasOwnership())
return;
if (Mem2RegDisableLifetimeCanonicalization)
return;