[llvm] [MemCpyOpt] move SrcAlloca to the entry if transformation is performed (PR #67226)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 23 02:12:36 PDT 2023


================
@@ -1600,7 +1592,11 @@ bool MemCpyOptPass::performStackMoveOptzn(Instruction *Load, Instruction *Store,
   if (!CaptureTrackingWithModRef(SrcAlloca, SrcModRefCallback))
     return false;
 
-  // We can do the transformation. First, align the allocas appropriately.
+  // We can do the transformation. First, move the SrcAlloca to the entry point.
+  // This is safe because any static alloca is in EntryBB.
+  SrcAlloca->moveBefore(*SrcAlloca->getParent(),
+                        SrcAlloca->getParent()->getFirstInsertionPt());
----------------
nikic wrote:

I think it would be better to only move the alloca if necessary.

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


More information about the llvm-commits mailing list