[llvm] [VPlan] Speed up VPSlotTracker by using ModuleSlotTracker (PR #139881)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 10 01:05:40 PDT 2025
================
@@ -1546,6 +1540,34 @@ void VPSlotTracker::assignNames(const VPBasicBlock *VPBB) {
assignName(Def);
}
+std::string VPSlotTracker::getName(const VPValue *V) {
+ auto *UV = V->getUnderlyingValue();
+ auto *VPI = dyn_cast_or_null<VPInstruction>(V->getDefiningRecipe());
+ if (!UV)
+ return VPI->getName().str();
+
+ std::string Name;
+ raw_string_ostream S(Name);
+ if (MST) {
----------------
fhahn wrote:
Might be simpler to handle all cases that don't require constructing a new MST first, with early exit
```suggestion
if (MST || UV->hasName() || !isa<Instruction>(UV)) {
UV->printAsOperand(S, false);
return Name;
}
// 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());
} else {
MST = std::make_unique<ModuleSlotTracker>(nullptr);
}
UV->printAsOperand(S, false, *MST);
return Name;
```
https://github.com/llvm/llvm-project/pull/139881
More information about the llvm-commits
mailing list