Skip to content

Commit a805179

Browse files
committed
[Mem2Reg] Never borrow lifetimed stored_borrows.
Extend the definition of isGuaranteedLexicalValue--by means of which Mem2Reg determines whether to borrow introducing a begin_borrow [lexical] of a value which is store_borrow'd to an alloc_stack [lexical]--to include every guaranteed lexical value.
1 parent b8c2269 commit a805179

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,8 @@ static bool lexicalLifetimeEnsured(AllocStackInst *asi) {
377377
}
378378

379379
static bool isGuaranteedLexicalValue(SILValue src) {
380-
if (src->getOwnershipKind() != OwnershipKind::Guaranteed) {
381-
return false;
382-
}
383-
if (isa<SILFunctionArgument>(src)) {
384-
return true;
385-
}
386-
if (auto *bbi = dyn_cast<BeginBorrowInst>(src)) {
387-
return bbi->isLexical();
388-
}
389-
return false;
380+
return src->getOwnershipKind() == OwnershipKind::Guaranteed &&
381+
src->isLexical();
390382
}
391383

392384
/// Returns true if we have enough information to end the lifetime.

0 commit comments

Comments
 (0)