[clang] [llvm] [PromoteMemToReg] Insert store undef when removing lifetime markers (PR #191909)

Alexandre Isoard via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 14 09:17:08 PDT 2026


================
@@ -546,9 +546,32 @@ static void removeIntrinsicUsers(AllocaInst *AI) {
           Inst->dropDroppableUse(UU);
           continue;
         }
+
+        // Replace lifetime markers with a store of undef so that mem2reg sees
+        // the alloca as having an undefined value at that point. This allows
+        // it to break unnecessary back-edge PHI nodes created when the alloca
+        // is reused across loop iterations.
+        if (auto *II = dyn_cast<IntrinsicInst>(Inst))
----------------
isoard-amd wrote:

So, this entire `for`-loop is unreachable?

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


More information about the cfe-commits mailing list