[llvm] [VPlan] Speed up VPSlotTracker by using ModuleSlotTracker (PR #139881)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri May 16 07:15:27 PDT 2025


================
@@ -1441,7 +1441,23 @@ void VPSlotTracker::assignName(const VPValue *V) {
   std::string Name;
   if (UV) {
     raw_string_ostream S(Name);
-    UV->printAsOperand(S, false);
+    if (MST) {
+      UV->printAsOperand(S, false, *MST);
+    } else if (isa<Instruction>(UV) && !UV->hasName()) {
+      // Lazily create the ModuleSlotTracker when we first hit an unnamed
+      // instruction
+      auto *IUV = cast<Instruction>(UV);
+      // This check is required to support unit tests with incomplete IR.
+      if (IUV->getParent()) {
+        MST = std::make_unique<ModuleSlotTracker>(IUV->getModule());
+        MST->incorporateFunction(*IUV->getFunction());
----------------
david-arm wrote:

Is an instruction that has a parent (i.e. a basic block) also guaranteed to have a function? I assume so, but just curious.

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


More information about the llvm-commits mailing list