Index: llvm/lib/Transforms/Scalar/LICM.cpp =================================================================== --- llvm/lib/Transforms/Scalar/LICM.cpp +++ llvm/lib/Transforms/Scalar/LICM.cpp @@ -401,7 +401,6 @@ bool Changed = false; assert(L->isLCSSAForm(*DT) && "Loop is not in LCSSA form."); - MSSA->ensureOptimizedUses(); // If this loop has metadata indicating that LICM is not to be performed then // just exit. @@ -1304,7 +1303,8 @@ if (auto *Accesses = MSSA->getBlockAccesses(BB)) { for (const auto &MA : *Accesses) if (const auto *MU = dyn_cast(&MA)) { - auto *MD = MU->getDefiningAccess(); + auto *MD = getClobberingMemoryAccess(*MSSA, BAA, Flags, + const_cast(MU)); if (!MSSA->isLiveOnEntryDef(MD) && CurLoop->contains(MD->getBlock())) return false;