Skip to content

Commit 8d55e09

Browse files
committed
[SSADestroyHoisting] Lifetimes alter arg hoisting.
Arguments whose lifetimes are not lexical should be hoisted without respect to deinit barriers. On the other hand, inout arguments explicitly annotated @_lexical should respect deinit barriers.
1 parent eb3f800 commit 8d55e09

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/SILOptimizer/Transforms/SSADestroyHoisting.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,17 +966,20 @@ void SSADestroyHoisting::run() {
966966
remainingDestroyAddrs, deleter);
967967
}
968968
// Arguments enclose everything.
969-
for (auto *arg : getFunction()->getArguments()) {
969+
for (auto *uncastArg : getFunction()->getArguments()) {
970+
auto *arg = cast<SILFunctionArgument>(uncastArg);
970971
if (arg->getType().isAddress()) {
971-
auto convention = cast<SILFunctionArgument>(arg)->getArgumentConvention();
972+
auto convention = arg->getArgumentConvention();
972973
// This is equivalent to writing
973974
//
974975
// convention == SILArgumentConvention::Indirect_Inout
975976
//
976977
// but communicates the rationale: in order to ignore deinit barriers, the
977978
// address must be exclusively accessed and be a modification.
978-
bool ignoreDeinitBarriers = convention.isInoutConvention() &&
979-
convention.isExclusiveIndirectParameter();
979+
bool ignoredByConvention = convention.isInoutConvention() &&
980+
convention.isExclusiveIndirectParameter();
981+
auto lifetime = arg->getLifetime();
982+
bool ignoreDeinitBarriers = ignoredByConvention || lifetime.isEagerMove();
980983
changed |= hoistDestroys(arg, ignoreDeinitBarriers, remainingDestroyAddrs,
981984
deleter);
982985
}

0 commit comments

Comments
 (0)