[llvm] [LoopVectorize] Compute BlockFrequencyInfo eagerly to fix assertion failure (PR #215237)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 23:45:13 PDT 2026


================
@@ -8478,9 +8478,13 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
 
   auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
   PSI = MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
-  GetBFI = [&AM, &F]() -> BlockFrequencyInfo & {
-    return AM.getResult<BlockFrequencyAnalysis>(F);
-  };
+  // Compute BFI eagerly rather than lazily. LoopVectorize may modify the
+  // function (vectorizing earlier loops) before requesting BFI for later loops.
+  // If BFI is computed lazily after such modifications, its dependency
+  // CycleAnalysis may be stale (holding pointers to deleted blocks), causing
----------------
aengelke wrote:

Can we alternatively explicitly invalidate CycleAnalysis in such cases?

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


More information about the llvm-commits mailing list