[llvm] [VPlan] Create and re-use ModuleSlotTracker for metadata printing. (PR #203982)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 02:12:29 PDT 2026


================
@@ -1613,6 +1613,17 @@ void VPSlotTracker::assignNames(const VPBasicBlock *VPBB) {
       assignName(Def);
 }
 
+ModuleSlotTracker &VPSlotTracker::getOrCreateMST(const Module *Mod,
+                                                 const Function *F) {
+  if (!MST)
+    MST = std::make_unique<ModuleSlotTracker>(Mod);
+  // Incorporate the function even if the MST already existed; this is a no-op
+  // if \p F is already incorporated.
+  if (F)
+    MST->incorporateFunction(*F);
----------------
fhahn wrote:

The original version could lead to differnet results, if we print recipes without underlying instructions. 

In https://github.com/llvm/llvm-project/pull/223952, we get the module/function from the plan, which should avoid this in practice (the only case where we can have a plan w/o a corresponding function is manual construction via C++ unit tests)

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


More information about the llvm-commits mailing list