Skip to content

Commit 2e586bb

Browse files
committed
Enable ArrayPropertyOpt on OSSA
1 parent b5c4702 commit 2e586bb

File tree

5 files changed

+699
-12
lines changed

5 files changed

+699
-12
lines changed

lib/SIL/Utils/BasicBlockUtils.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ void swift::getEdgeArgs(TermInst *T, unsigned edgeIdx, SILBasicBlock *newEdgeBB,
197197
if (!succBB->getNumArguments())
198198
return;
199199
args.push_back(newEdgeBB->createPhiArgument(
200-
succBB->getArgument(0)->getType(), OwnershipKind::Owned));
200+
succBB->getArgument(0)->getType(),
201+
succBB->getArgument(0)->getOwnershipKind()));
201202
return;
202203
}
203204
case SILInstructionKind::CheckedCastAddrBranchInst: {
@@ -206,7 +207,8 @@ void swift::getEdgeArgs(TermInst *T, unsigned edgeIdx, SILBasicBlock *newEdgeBB,
206207
if (!succBB->getNumArguments())
207208
return;
208209
args.push_back(newEdgeBB->createPhiArgument(
209-
succBB->getArgument(0)->getType(), OwnershipKind::Owned));
210+
succBB->getArgument(0)->getType(),
211+
succBB->getArgument(0)->getOwnershipKind()));
210212
return;
211213
}
212214
case SILInstructionKind::CheckedCastValueBranchInst: {
@@ -215,7 +217,8 @@ void swift::getEdgeArgs(TermInst *T, unsigned edgeIdx, SILBasicBlock *newEdgeBB,
215217
if (!succBB->getNumArguments())
216218
return;
217219
args.push_back(newEdgeBB->createPhiArgument(
218-
succBB->getArgument(0)->getType(), OwnershipKind::Owned));
220+
succBB->getArgument(0)->getType(),
221+
succBB->getArgument(0)->getOwnershipKind()));
219222
return;
220223
}
221224

@@ -225,7 +228,8 @@ void swift::getEdgeArgs(TermInst *T, unsigned edgeIdx, SILBasicBlock *newEdgeBB,
225228
if (!succBB->getNumArguments())
226229
return;
227230
args.push_back(newEdgeBB->createPhiArgument(
228-
succBB->getArgument(0)->getType(), OwnershipKind::Owned));
231+
succBB->getArgument(0)->getType(),
232+
succBB->getArgument(0)->getOwnershipKind()));
229233
return;
230234
}
231235

lib/SILOptimizer/LoopTransforms/ArrayPropertyOpt.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class ArrayPropertiesAnalysis {
223223
/// Strip the struct load and the address projection to the location
224224
/// holding the array struct.
225225
SILValue stripArrayStructLoad(SILValue V) {
226-
if (auto LI = dyn_cast<LoadInst>(V)) {
226+
if (auto LI = dyn_cast<LoadInst>(lookThroughCopyValueInsts(V))) {
227227
auto Val = LI->getOperand();
228228
// We could have two arrays in a surrounding container so we can only
229229
// strip off the 'array struct' project.
@@ -752,10 +752,6 @@ class SwiftArrayPropertyOptPass : public SILFunctionTransform {
752752
void run() override {
753753
auto *Fn = getFunction();
754754

755-
// FIXME: Add support for ownership.
756-
if (Fn->hasOwnership())
757-
return;
758-
759755
// Don't hoist array property calls at Osize.
760756
if (Fn->optimizeForSize())
761757
return;
@@ -789,7 +785,6 @@ class SwiftArrayPropertyOptPass : public SILFunctionTransform {
789785

790786
// Specialize the identified loop nest based on the 'array.props' calls.
791787
if (HasChanged) {
792-
LLVM_DEBUG(getFunction()->viewCFG());
793788
DominanceInfo *DT = DA->get(getFunction());
794789

795790
// Process specialized loop-nests in loop-tree post-order (bottom-up).
@@ -802,8 +797,6 @@ class SwiftArrayPropertyOptPass : public SILFunctionTransform {
802797
// Verify that no illegal critical edges were created.
803798
getFunction()->verifyCriticalEdges();
804799

805-
LLVM_DEBUG(getFunction()->viewCFG());
806-
807800
// We preserve the dominator tree. Let's invalidate everything
808801
// else.
809802
DA->lockInvalidation();

0 commit comments

Comments
 (0)