File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
llvm/lib/Transforms/Scalar Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -1104,16 +1104,17 @@ bool MemCpyOptPass::performCallSlotOptzn(Instruction *cpyLoad,
11041104bool MemCpyOptPass::processMemCpyMemCpyDependence (MemCpyInst *M,
11051105 MemCpyInst *MDep,
11061106 BatchAAResults &BAA) {
1107+ // We can only optimize non-volatile memcpy's.
1108+ if (MDep->isVolatile ())
1109+ return false ;
1110+
11071111 // If dep instruction is reading from our current input, then it is a noop
11081112 // transfer and substituting the input won't change this instruction. Just
11091113 // ignore the input and let someone else zap MDep. This handles cases like:
11101114 // memcpy(a <- a)
11111115 // memcpy(b <- a)
1112- if (M->getSource () == MDep->getSource ())
1113- return false ;
1114-
1115- // We can only optimize non-volatile memcpy's.
1116- if (MDep->isVolatile ())
1116+ // This also avoids infinite loops.
1117+ if (BAA.isMustAlias (MDep->getDest (), MDep->getSource ()))
11171118 return false ;
11181119
11191120 int64_t MForwardOffset = 0 ;
@@ -1177,10 +1178,6 @@ bool MemCpyOptPass::processMemCpyMemCpyDependence(MemCpyInst *M,
11771178 CopySourceAlign = commonAlignment (*CopySourceAlign, MForwardOffset);
11781179 }
11791180
1180- // Avoid infinite loops
1181- if (BAA.isMustAlias (M->getSource (), CopySource))
1182- return false ;
1183-
11841181 // Verify that the copied-from memory doesn't change in between the two
11851182 // transfers. For example, in:
11861183 // memcpy(a <- b)
You can’t perform that action at this time.
0 commit comments