Skip to content

Commit b93ed3e

Browse files
Merge pull request #81081 from swiftlang/revert-80839-moveonly-trivial-field-as-reinitialize
Revert "MoveOnlyChecker: Treat trivial stores as reinitializations rather than initializations."
2 parents 72c2750 + e4d3207 commit b93ed3e

File tree

6 files changed

+7
-42
lines changed

6 files changed

+7
-42
lines changed

lib/SIL/Utils/FieldSensitivePrunedLiveness.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,6 @@ void FieldSensitiveMultiDefPrunedLiveRange::findBoundariesInBlock(
15681568
return getBlockLiveness(predBlock, bitNo) ==
15691569
FieldSensitivePrunedLiveBlocks::IsLive::LiveOut;
15701570
})) {
1571-
PRUNED_LIVENESS_LOG(llvm::dbgs() << "Marking ourself as boundary edge: bb"
1572-
<< block->getDebugID() << '\n');
15731571
boundary.getBoundaryEdgeBits(block).set(bitNo);
15741572
}
15751573
}

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,7 @@ static void convertMemoryReinitToInitForm(SILInstruction *memInst,
341341
}
342342
case SILInstructionKind::StoreInst: {
343343
auto *si = cast<StoreInst>(memInst);
344-
if (si->getOwnershipQualifier() != StoreOwnershipQualifier::Trivial) {
345-
si->setOwnershipQualifier(StoreOwnershipQualifier::Init);
346-
}
344+
si->setOwnershipQualifier(StoreOwnershipQualifier::Init);
347345
dest = si->getDest();
348346
break;
349347
}
@@ -367,8 +365,7 @@ static bool isReinitToInitConvertibleInst(SILInstruction *memInst) {
367365
}
368366
case SILInstructionKind::StoreInst: {
369367
auto *si = cast<StoreInst>(memInst);
370-
return si->getOwnershipQualifier() == StoreOwnershipQualifier::Assign
371-
|| si->getOwnershipQualifier() == StoreOwnershipQualifier::Trivial;
368+
return si->getOwnershipQualifier() == StoreOwnershipQualifier::Assign;
372369
}
373370
}
374371
}
@@ -2161,7 +2158,7 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
21612158
}
21622159
return true;
21632160
}
2164-
2161+
21652162
// Then handle destroy_addr specially. We want to as part of our dataflow to
21662163
// ignore destroy_addr, so we need to track it separately from other uses.
21672164
if (auto *dvi = dyn_cast<DestroyAddrInst>(user)) {

lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ bool noncopyable::memInstMustInitialize(Operand *memOper) {
213213
}
214214
case SILInstructionKind::StoreInst: {
215215
auto qual = cast<StoreInst>(memInst)->getOwnershipQualifier();
216-
return qual == StoreOwnershipQualifier::Init;
216+
return qual == StoreOwnershipQualifier::Init ||
217+
qual == StoreOwnershipQualifier::Trivial;
217218
}
218219
case SILInstructionKind::BuiltinInst: {
219220
auto bi = cast<BuiltinInst>(memInst);
@@ -263,9 +264,7 @@ bool noncopyable::memInstMustReinitialize(Operand *memOper) {
263264
}
264265
case SILInstructionKind::StoreInst:
265266
return cast<StoreInst>(memInst)->getOwnershipQualifier() ==
266-
StoreOwnershipQualifier::Assign
267-
|| cast<StoreInst>(memInst)->getOwnershipQualifier() ==
268-
StoreOwnershipQualifier::Trivial;
267+
StoreOwnershipQualifier::Assign;
269268

270269
#define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
271270
case SILInstructionKind::Store##Name##Inst: \
@@ -508,13 +507,6 @@ struct SimpleTemporaryAllocStackElimVisitor
508507
// tell these projections apart from projections from earlier allocations.
509508
return state.setFinalUser(op);
510509
}
511-
512-
if (auto *si = dyn_cast<StoreInst>(user);
513-
si && si->getOwnershipQualifier() == StoreOwnershipQualifier::Trivial) {
514-
// Bail on trivial stores.
515-
LLVM_DEBUG(llvm::dbgs() << "Found trivial store: " << *user);
516-
return false;
517-
}
518510

519511
if (auto *cai = dyn_cast<CopyAddrInst>(user)) {
520512
// If we already found a copy, bail. We always only visit one of these

test/SILGen/inlinearray_reabstraction.swift

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/SILOptimizer/moveonly_addresschecker.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ bb0(%0 : @owned $Klass, %1 : @owned $Klass):
367367
// CHECK: bb0([[ARG0:%.*]] : ${{.*}}, [[ARG1:%.*]] :
368368
// CHECK: debug_value [[ARG0]]
369369
// CHECK: debug_value [[ARG1]]
370+
// CHECK: destroy_addr [[ARG1]]
370371
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [static] [[ARG1]]
371372
// CHECK: [[GEP:%.*]] = struct_element_addr [[ACCESS]]
372-
// CHECK: destroy_addr [[ARG1]]
373373
// CHECK: store [[ARG0]] to [trivial] [[GEP]]
374374
// CHECK: end_access [[ACCESS]]
375375
// CHECK: } // end sil function 'myBufferViewSetter'

test/SILOptimizer/moveonly_addresschecker_trivial_member_assign.swift

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)