Skip to content

Commit dae2530

Browse files
committed
Enable COWArrayOpts on OSSA
Additional handling of copy_value/destroy_value/load[copy]/ begin_borrow/end_borrow is needed to support OSSA. TODO: Support handling of 2d array in the pass for OSSA. Currently hoisting of loads and borrows are not supported in OSSA
1 parent 4a4a6b2 commit dae2530

File tree

4 files changed

+1297
-79
lines changed

4 files changed

+1297
-79
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ class SILInstruction
541541
SILValue getOperand(unsigned Num) const {
542542
return getAllOperands()[Num].get();
543543
}
544+
Operand &getOperandRef(unsigned Num) { return getAllOperands()[Num]; }
544545
void setOperand(unsigned Num, SILValue V) { getAllOperands()[Num].set(V); }
545546
void swapOperands(unsigned Num1, unsigned Num2) {
546547
getAllOperands()[Num1].swap(getAllOperands()[Num2]);

lib/SILOptimizer/LoopTransforms/ArrayOpt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class StructUseCollector {
125125
if (!ElementAddressUsers.empty())
126126
return false;
127127
for (SILInstruction *user : StructAddressUsers) {
128+
// ignore load users
129+
if (isa<LoadInst>(user))
130+
continue;
128131
if (user != use1 && user != use2)
129132
return false;
130133
}
@@ -184,6 +187,7 @@ class StructUseCollector {
184187
// Found a use of the struct at the given access path.
185188
if (auto *LoadI = dyn_cast<LoadInst>(UseInst)) {
186189
StructLoads.push_back(LoadI);
190+
StructAddressUsers.push_back(LoadI);
187191
continue;
188192
}
189193

0 commit comments

Comments
 (0)