@@ -119,6 +119,9 @@ static SILValue skipStructAndExtract(SILValue value) {
119119}
120120
121121bool COWOptsPass::optimizeBeginCOW (BeginCOWMutationInst *BCM) {
122+ LLVM_DEBUG (llvm::dbgs () << " Looking at: " );
123+ LLVM_DEBUG (BCM->dump ());
124+
122125 SILFunction *function = BCM->getFunction ();
123126 StackList<EndCOWMutationInst *> endCOWMutationInsts (function);
124127 InstructionSet endCOWMutationsFound (function);
@@ -187,14 +190,20 @@ bool COWOptsPass::optimizeBeginCOW(BeginCOWMutationInst *BCM) {
187190 // Don't immediately bail on a store instruction. Instead, remember
188191 // it and check if it interferes with any (potential) load.
189192 if (storeAddrsFound.insert (store->getDest ())) {
193+ LLVM_DEBUG (llvm::dbgs () << " Found store escape, record: " );
194+ LLVM_DEBUG (inst->dump ());
190195 storeAddrs.push_back (store->getDest ());
191196 numStoresFound += 1 ;
192197 }
193198 } else {
199+ LLVM_DEBUG (llvm::dbgs () << " Found non-store escape, bailing out: " );
200+ LLVM_DEBUG (inst->dump ());
194201 return false ;
195202 }
196203 }
197204 if (inst->mayReadFromMemory ()) {
205+ LLVM_DEBUG (llvm::dbgs () << " Found a may read inst, record: " );
206+ LLVM_DEBUG (inst->dump ());
198207 potentialLoadInsts.push_back (inst);
199208 numLoadsFound += 1 ;
200209 }
@@ -225,8 +234,12 @@ bool COWOptsPass::optimizeBeginCOW(BeginCOWMutationInst *BCM) {
225234 return false ;
226235 for (SILInstruction *load : potentialLoadInsts) {
227236 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 ());
229241 return false ;
242+ }
230243 }
231244 }
232245 }
0 commit comments