@@ -119,6 +119,9 @@ static SILValue skipStructAndExtract(SILValue value) {
119
119
}
120
120
121
121
bool COWOptsPass::optimizeBeginCOW (BeginCOWMutationInst *BCM) {
122
+ LLVM_DEBUG (llvm::dbgs () << " Looking at: " );
123
+ LLVM_DEBUG (BCM->dump ());
124
+
122
125
SILFunction *function = BCM->getFunction ();
123
126
StackList<EndCOWMutationInst *> endCOWMutationInsts (function);
124
127
InstructionSet endCOWMutationsFound (function);
@@ -187,14 +190,20 @@ bool COWOptsPass::optimizeBeginCOW(BeginCOWMutationInst *BCM) {
187
190
// Don't immediately bail on a store instruction. Instead, remember
188
191
// it and check if it interferes with any (potential) load.
189
192
if (storeAddrsFound.insert (store->getDest ())) {
193
+ LLVM_DEBUG (llvm::dbgs () << " Found store escape, record: " );
194
+ LLVM_DEBUG (inst->dump ());
190
195
storeAddrs.push_back (store->getDest ());
191
196
numStoresFound += 1 ;
192
197
}
193
198
} else {
199
+ LLVM_DEBUG (llvm::dbgs () << " Found non-store escape, bailing out: " );
200
+ LLVM_DEBUG (inst->dump ());
194
201
return false ;
195
202
}
196
203
}
197
204
if (inst->mayReadFromMemory ()) {
205
+ LLVM_DEBUG (llvm::dbgs () << " Found a may read inst, record: " );
206
+ LLVM_DEBUG (inst->dump ());
198
207
potentialLoadInsts.push_back (inst);
199
208
numLoadsFound += 1 ;
200
209
}
@@ -225,8 +234,12 @@ bool COWOptsPass::optimizeBeginCOW(BeginCOWMutationInst *BCM) {
225
234
return false ;
226
235
for (SILInstruction *load : potentialLoadInsts) {
227
236
for (SILValue storeAddr : storeAddrs) {
228
- if (!AA || AA->mayReadFromMemory (load, storeAddr))
237
+ if (!AA || AA->mayReadFromMemory (load, storeAddr)) {
238
+ LLVM_DEBUG (llvm::dbgs () << " Found a store address aliasing with a load:" );
239
+ LLVM_DEBUG (load->dump ());
240
+ LLVM_DEBUG (storeAddr->dump ());
229
241
return false ;
242
+ }
230
243
}
231
244
}
232
245
}
0 commit comments