[llvm] [MemCpyOpt] Avoid infinite loops in `MemCpyOptPass::processMemCpyMemCpyDependence` (PR #103218)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 07:47:53 PDT 2024


================
@@ -1198,6 +1198,10 @@ bool MemCpyOptPass::processMemCpyMemCpyDependence(MemCpyInst *M,
       CopySourceAlign = commonAlignment(*CopySourceAlign, MForwardOffset);
   }
 
+  // Avoid infinite loops
+  if (BAA.isMustAlias(M->getSource(), CopySource))
----------------
dtcxzyw wrote:

I tried to change this check into `BAA.isMustAlias(M->getSource(), MDep->getSource())`. But it doesn't work.

> Also, do you think it would make sense to also remove the no-op memcpy, if we already have to check for them anyway?

Yeah, it's definitely a better approach. But before doing this, we should prove that `ptr getelementptr inbounds (i8, ptr @g2, i64 16)` and ` ptr getelementptr inbounds nuw (i8, ptr @g2, i64 16)` must alias.


https://github.com/llvm/llvm-project/pull/103218


More information about the llvm-commits mailing list