Skip to content

Commit 28bf85f

Browse files
authored
Merge pull request #35312 from meg-gupta/cowoptossa
Enable COWArrayOpts on OSSA
2 parents 575b7fb + dae2530 commit 28bf85f

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)