Skip to content

Commit 059421e

Browse files
committed
[mem-access-utils] Allow for getStackInitAllocStackUse to recognize an always take from a unconditional_checked_cast_addr as a destroy_addr
1 parent 6bb9253 commit 059421e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/SIL/Utils/MemAccessUtils.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "swift/SIL/SILUndef.h"
1818
#include "swift/SIL/DynamicCasts.h"
1919
#include "swift/SIL/Consumption.h"
20+
#include "swift/SIL/SILInstruction.h"
2021
#include "llvm/Support/Debug.h"
2122

2223
using namespace swift;
@@ -1579,6 +1580,18 @@ swift::getSingleInitAllocStackUse(AllocStackInst *asi,
15791580
switch (user->getKind()) {
15801581
default:
15811582
break;
1583+
case SILInstructionKind::UnconditionalCheckedCastAddrInst: {
1584+
auto *uccai = cast<UnconditionalCheckedCastAddrInst>(user);
1585+
// Only handle the case where we are doing a take of our alloc_stack as a
1586+
// source value. If we are the dest, then something else is happening!
1587+
// Break!
1588+
if (use->get() == uccai->getDest())
1589+
break;
1590+
// Ok, we are the Src and are performing a take. Treat it as a destroy!
1591+
if (destroyingUses)
1592+
destroyingUses->push_back(use);
1593+
continue;
1594+
}
15821595
case SILInstructionKind::CheckedCastAddrBranchInst: {
15831596
auto *ccabi = cast<CheckedCastAddrBranchInst>(user);
15841597
// We only handle the case where we are doing a take of our alloc_stack as

0 commit comments

Comments
 (0)